{"record":{"id":"206f40c7b19c13f1","repo":"microsoft/semantic-kernel","slug":"azure-openai-endpoint-is-not-set-206f40","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/Step01_Basics/Program.cs","lineNumber":13,"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.Agents.OpenAI;\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\") ?? \"gpt-4o\";\nvar userInput = \"Tell me a joke about a pirate.\";\n\nConsole.WriteLine($\"User Input: {userInput}\");\n\nawait SKAgentAsync();\nawait SKAgent_As_AFAgentAsync();\nawait AFAgentAsync();\n\nasync Task SKAgentAsync()\n{\n    Console.WriteLine(\"\\n=== SK Agent ===\\n\");\n\n    var responseClient = new AzureOpenAIClient(new Uri(endpoint), new AzureCliCredential())\n        .GetResponsesClient();\n    OpenAIResponseAgent agent = new(responseClient, deploymentName)\n    {\n        Name = \"Joker\",","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/samples/AgentFrameworkMigration/AzureOpenAIResponses/Step01_Basics/Program.cs#L1-L31","documentation":"The Azure OpenAI Responses Basics migration sample throws InvalidOperationException when AZURE_OPENAI_ENDPOINT is not set. This sample uses the OpenAI Responses API (OpenAI.Responses namespace) via Azure OpenAI, comparing SK's OpenAIResponseAgent with the Agent Framework equivalent. The OPENAI001 and SKEXP0110 pragmas suppress preview-API warnings.","triggerScenarios":"Running AzureOpenAIResponses/Step01_Basics without AZURE_OPENAI_ENDPOINT. The throw at line 13 fires before SKAgentAsync, SKAgent_As_AFAgentAsync, or AFAgentAsync execute.","commonSituations":"Confusing the Responses API sample with the standard chat completion sample (same env var, different agent type); the deployed model does not support the Responses API; running without az login for AzureCliCredential.","solutions":["Set AZURE_OPENAI_ENDPOINT to your Azure OpenAI resource URL","Optionally set AZURE_OPENAI_DEPLOYMENT_NAME (defaults to gpt-4o)","Ensure the deployed model supports the Responses API","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. Azure OpenAI Responses samples require it.\");","handlingStrategy":"validation","validationCode":"var endpoint = Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\");\nif (string.IsNullOrWhiteSpace(endpoint))\n{\n    Console.Error.WriteLine(\"AZURE_OPENAI_ENDPOINT is not set. Required for Responses API samples.\");\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":["Ensure the deployed model supports the OpenAI Responses API (preview feature)","Suppress OPENAI001 and SKEXP0110 warnings as the samples do, since Responses agent types are experimental","Run az login for AzureCliCredential","Verify the endpoint is for Azure OpenAI, not Azure AI Foundry"],"tags":["configuration","csharp","azure-openai","semantic-kernel","environment-variables","responses-api","agent-framework-migration"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}