{"record":{"id":"96041099f512ed83","repo":"microsoft/semantic-kernel","slug":"azure-openai-endpoint-is-not-set","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/Step01_Concurrent/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.Concurrent;\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 concurrent orchestrations using\n// Semantic Kernel and the Agent Framework.\nConsole.WriteLine(\"=== Semantic Kernel Concurrent Orchestration ===\");\nawait SKConcurrentOrchestration();\n\nConsole.WriteLine(\"\\n=== Agent Framework Concurrent Agent Workflow ===\");\nawait AFConcurrentAgentWorkflow();\n\n# region SKConcurrentOrchestration\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 SKConcurrentOrchestration()\n{\n    ConcurrentOrchestration orchestration = new([\n        GetSKTranslationAgent(\"French\"),","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/samples/AgentFrameworkMigration/AgentOrchestrations/Step01_Concurrent/Program.cs#L1-L32","documentation":"The Concurrent Orchestration migration sample throws InvalidOperationException at startup when the AZURE_OPENAI_ENDPOINT environment variable is null. This sample compares Semantic Kernel's ConcurrentOrchestration against the Agent Framework's concurrent agent workflow. The endpoint is used with AzureCliCredential to construct an AzureOpenAIChatClient.","triggerScenarios":"Running dotnet run in AgentOrchestrations/Step01_Concurrent without setting AZURE_OPENAI_ENDPOINT in the environment. The null-coalescing throw fires immediately at line 14, before any orchestration logic executes.","commonSituations":"First run of the sample without reading the README's Environment Variables section; setting the variable in one terminal session but running in another; forgetting to export the variable in bash (set without export); .env file not loaded by the console host.","solutions":["Set AZURE_OPENAI_ENDPOINT to your Azure OpenAI resource URL (e.g. https://my-resource.cognitiveservices.azure.com/)","Optionally set AZURE_OPENAI_DEPLOYMENT_NAME (defaults to gpt-4o-mini)","Ensure you are logged into Azure CLI (az login) since the sample uses AzureCliCredential","On Windows use $env:AZURE_OPENAI_ENDPOINT = '...'; on bash/macOS use export AZURE_OPENAI_ENDPOINT='...'"],"exampleFix":"// before\nvar endpoint = Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\") ?? throw new InvalidOperationException(\"AZURE_OPENAI_ENDPOINT is not set.\");\n\n// after — helpful prompt with fallback\nvar endpoint = Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\");\nif (string.IsNullOrWhiteSpace(endpoint))\n{\n    Console.Write(\"Enter your Azure OpenAI endpoint: \");\n    endpoint = Console.ReadLine()?.Trim() ?? throw new InvalidOperationException(\"Endpoint is required.\");\n}","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(\"Example: 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);\n    Console.Error.WriteLine(\"Set: export AZURE_OPENAI_ENDPOINT='https://<resource>.cognitiveservices.azure.com/'\");\n    return;\n}","preventionTips":["Create a .env file or shell script with all required env vars and source it before running samples","Add a startup guard that checks all required env vars and prints a consolidated error before any agent logic","Set env vars in Properties/launchSettings.json for Visual Studio debugging","Run az login before executing any sample that uses AzureCliCredential"],"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"}