{"record":{"id":"e0eb2235316e498d","repo":"microsoft/semantic-kernel","slug":"azure-openai-endpoint-is-not-set-e0eb22","errorCode":null,"errorMessage":"AZURE_OPENAI_ENDPOINT is not set.","messagePattern":"AZURE_OPENAI_ENDPOINT is not set\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/samples/AgentFrameworkMigration/AzureOpenAIResponses/Step02_ReasoningModel/Program.cs","lineNumber":15,"sourceCode":"﻿// Copyright (c) Microsoft. All rights reserved.\n\nusing Azure.AI.OpenAI;\nusing Azure.Identity;\nusing Microsoft.Agents.AI;\nusing Microsoft.Extensions.AI;\nusing Microsoft.SemanticKernel;\nusing Microsoft.SemanticKernel.Agents.OpenAI;\nusing Microsoft.SemanticKernel.ChatCompletion;\nusing OpenAI.Responses;\n\n#pragma warning disable OPENAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.\n#pragma warning disable SKEXP0110 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.\n\nvar endpoint = Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\") ?? throw new InvalidOperationException(\"AZURE_OPENAI_ENDPOINT is not set.\");\nvar deploymentName = System.Environment.GetEnvironmentVariable(\"AZURE_OPENAI_DEPLOYMENT_NAME\") ?? \"o4-mini\";\nvar userInput =\n    \"\"\"\n    Instructions:\n    - Given the React component below, think about it and change it so that nonfiction books have red\n        text. \n    - Return only the code in your reply\n    - Do not include any additional formatting, such as markdown code blocks\n    - For formatting, use four space tabs, and do not allow any lines of code to \n        exceed 80 columns\n    const books = [\n        { title: 'Dune', category: 'fiction', id: 1 },\n        { title: 'Frankenstein', category: 'fiction', id: 2 },\n        { title: 'Moneyball', category: 'nonfiction', id: 3 },\n    ];\n    export default function BookList() {\n        const listItems = books.map(book =>\n        <li>","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/samples/AgentFrameworkMigration/AzureOpenAIResponses/Step02_ReasoningModel/Program.cs#L1-L33","documentation":"The Azure OpenAI Responses ReasoningModel migration sample throws InvalidOperationException when AZURE_OPENAI_ENDPOINT is missing. This sample uses a reasoning model (default deployment o4-mini) via the Responses API to transform a React component. Reasoning models have different token and parameter characteristics that the Responses API exposes.","triggerScenarios":"Running AzureOpenAIResponses/Step02_ReasoningModel without AZURE_OPENAI_ENDPOINT. The throw at line 15 fires before the React component prompt is sent.","commonSituations":"The o4-mini deployment does not exist in the Azure OpenAI resource (AZURE_OPENAI_DEPLOYMENT_NAME defaults to o4-mini here, not gpt-4o); reasoning models may not be available in all regions; the Responses API preview may not be enabled on the resource.","solutions":["Set AZURE_OPENAI_ENDPOINT to your Azure OpenAI resource URL","Set AZURE_OPENAI_DEPLOYMENT_NAME to a reasoning model deployment (defaults to o4-mini)","Ensure the reasoning model (e.g. o4-mini) is deployed in your Azure OpenAI resource","Run az login for AzureCliCredential"],"exampleFix":"// before\nvar endpoint = Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\") ?? throw new InvalidOperationException(\"AZURE_OPENAI_ENDPOINT is not set.\");\n\n// after\nvar endpoint = Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\");\nif (string.IsNullOrWhiteSpace(endpoint))\n    throw new InvalidOperationException(\n        \"AZURE_OPENAI_ENDPOINT is not set. Deploy a reasoning model (e.g. o4-mini) first.\");","handlingStrategy":"validation","validationCode":"var endpoint = Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\");\nvar deployment = Environment.GetEnvironmentVariable(\"AZURE_OPENAI_DEPLOYMENT_NAME\") ?? \"o4-mini\";\nif (string.IsNullOrWhiteSpace(endpoint))\n{\n    Console.Error.WriteLine(\"AZURE_OPENAI_ENDPOINT is not set. Deploy a reasoning model (e.g. o4-mini).\");\n    return;\n}","typeGuard":"static bool IsAzureOpenAIEndpointConfigured() =>\n    !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\"));","tryCatchPattern":"try\n{\n    var endpoint = Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\")\n        ?? throw new InvalidOperationException(\"AZURE_OPENAI_ENDPOINT is not set.\");\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"AZURE_OPENAI_ENDPOINT\"))\n{\n    Console.Error.WriteLine(ex.Message);\n    return;\n}","preventionTips":["This sample defaults to o4-mini — ensure a reasoning model is deployed in your Azure OpenAI resource","Verify the Responses API supports the reasoning model you deployed","Run az login for AzureCliCredential","Reasoning models may not be available in all Azure regions — check region availability"],"tags":["configuration","csharp","azure-openai","semantic-kernel","environment-variables","responses-api","reasoning-model","agent-framework-migration"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}