{"record":{"id":"d24aaa541ee6e989","repo":"microsoft/semantic-kernel","slug":"azure-openai-endpoint-is-not-set-d24aaa","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/AgentOrchestrations/Step02_Sequential/Program.cs","lineNumber":14,"sourceCode":"﻿// Copyright (c) Microsoft. All rights reserved.\n\nusing Azure.AI.OpenAI;\nusing Azure.Identity;\nusing Microsoft.Agents.AI;\nusing Microsoft.Agents.AI.Workflows;\nusing Microsoft.Extensions.AI;\nusing Microsoft.SemanticKernel;\nusing Microsoft.SemanticKernel.Agents;\nusing Microsoft.SemanticKernel.Agents.Orchestration;\nusing Microsoft.SemanticKernel.Agents.Orchestration.Sequential;\nusing Microsoft.SemanticKernel.Agents.Runtime.InProcess;\n\nvar endpoint = Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\") ?? throw new InvalidOperationException(\"AZURE_OPENAI_ENDPOINT is not set.\");\nvar deploymentName = Environment.GetEnvironmentVariable(\"AZURE_OPENAI_DEPLOYMENT_NAME\") ?? \"gpt-4o-mini\";\n\nvar agentInstructions = \"You are a translation assistant who only responds in {0}. Respond to any input by outputting the name of the input language and then translating the input to {0}.\";\n\n// This sample compares running sequential orchestrations using\n// Semantic Kernel and the Agent Framework.\nConsole.WriteLine(\"=== Semantic Kernel Sequential Orchestration ===\");\nawait SKSequentialOrchestration();\n\nConsole.WriteLine(\"\\n=== Agent Framework Sequential Agent Workflow ===\");\nawait AFSequentialAgentWorkflow();\n\n# region SKSequentialOrchestration\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.\nasync Task SKSequentialOrchestration()\n{\n    SequentialOrchestration orchestration = new([\n        GetSKTranslationAgent(\"French\"),","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/samples/AgentFrameworkMigration/AgentOrchestrations/Step02_Sequential/Program.cs#L1-L32","documentation":"The Sequential Orchestration migration sample throws InvalidOperationException when AZURE_OPENAI_ENDPOINT is unset. This sample demonstrates the translation-assistant pipeline pattern, comparing SK's SequentialOrchestration with the Agent Framework's sequential agent workflow. Both paths require the endpoint to build chat clients via AzureCliCredential.","triggerScenarios":"Executing AgentOrchestrations/Step02_Sequential without AZURE_OPENAI_ENDPOINT in the process environment. The throw at line 14 prevents both SKSequentialOrchestration() and AFSequentialAgentWorkflow() from running.","commonSituations":"Running in a container or CI without env var injection; switching between sample folders and assuming the variable persists; the README mentions interactive prompting (line 346) but the code throws instead.","solutions":["Set AZURE_OPENAI_ENDPOINT to your Azure OpenAI resource URL before running","Optionally set AZURE_OPENAI_DEPLOYMENT_NAME (defaults to gpt-4o-mini)","Verify az login has been run for the AzureCliCredential token","Confirm the variable is exported in the same shell session where dotnet run executes"],"exampleFix":"// before\nvar endpoint = Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\") ?? throw new InvalidOperationException(\"AZURE_OPENAI_ENDPOINT is not set.\");\n\n// after — fail with actionable guidance\nvar endpoint = Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\");\nif (string.IsNullOrWhiteSpace(endpoint))\n    throw new InvalidOperationException(\n        \"AZURE_OPENAI_ENDPOINT is not set. \" +\n        \"Set it: export AZURE_OPENAI_ENDPOINT='https://<resource>.cognitiveservices.azure.com/'\");","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.\");\n    Console.Error.WriteLine(\"Set: export AZURE_OPENAI_ENDPOINT='https://<resource>.cognitiveservices.azure.com/'\");\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} See README.md for setup.\");\n    return;\n}","preventionTips":["Source a shared env-var script (e.g. setenv.sh) before running any orchestration sample","Document the same AZURE_OPENAI_ENDPOINT requirement across all AgentOrchestration samples in one place","Add a pre-flight check that validates both the endpoint and az login status before running","Use a wrapper script that sets defaults and runs dotnet run"],"tags":["configuration","csharp","azure-openai","semantic-kernel","environment-variables","agent-orchestration"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}