microsoft/semantic-kernel · error · InvalidOperationException
AZURE_OPENAI_ENDPOINT is not set.
Error message
AZURE_OPENAI_ENDPOINT is not set.
What it means
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.
Source
Thrown at dotnet/samples/AgentFrameworkMigration/AgentOrchestrations/Step02_Sequential/Program.cs:14
// Copyright (c) Microsoft. All rights reserved.
using Azure.AI.OpenAI;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Workflows;
using Microsoft.Extensions.AI;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.Agents.Orchestration;
using Microsoft.SemanticKernel.Agents.Orchestration.Sequential;
using Microsoft.SemanticKernel.Agents.Runtime.InProcess;
var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT is not set.");
var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? "gpt-4o-mini";
var 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}.";
// This sample compares running sequential orchestrations using
// Semantic Kernel and the Agent Framework.
Console.WriteLine("=== Semantic Kernel Sequential Orchestration ===");
await SKSequentialOrchestration();
Console.WriteLine("\n=== Agent Framework Sequential Agent Workflow ===");
await AFSequentialAgentWorkflow();
# region SKSequentialOrchestration
#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.
async Task SKSequentialOrchestration()
{
SequentialOrchestration orchestration = new([
GetSKTranslationAgent("French"),View on GitHub (pinned to c028a0c7dc)
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
Example fix
// before
var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT is not set.");
// after — fail with actionable guidance
var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT");
if (string.IsNullOrWhiteSpace(endpoint))
throw new InvalidOperationException(
"AZURE_OPENAI_ENDPOINT is not set. " +
"Set it: export AZURE_OPENAI_ENDPOINT='https://<resource>.cognitiveservices.azure.com/'"); Defensive patterns
Strategy: validation
Validate before calling
var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT");
if (string.IsNullOrWhiteSpace(endpoint))
{
Console.Error.WriteLine("AZURE_OPENAI_ENDPOINT is not set.");
Console.Error.WriteLine("Set: export AZURE_OPENAI_ENDPOINT='https://<resource>.cognitiveservices.azure.com/'");
return;
} Type guard
static bool IsAzureOpenAIEndpointConfigured() =>
!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")); Try / catch
try
{
var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")
?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT is not set.");
}
catch (InvalidOperationException ex) when (ex.Message.Contains("AZURE_OPENAI_ENDPOINT"))
{
Console.Error.WriteLine($"{ex.Message} See README.md for setup.");
return;
} Prevention
- 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
When it happens
Trigger: Executing AgentOrchestrations/Step02_Sequential without AZURE_OPENAI_ENDPOINT in the process environment. The throw at line 14 prevents both SKSequentialOrchestration() and AFSequentialAgentWorkflow() from running.
Common situations: 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.
Related errors
- AZURE_OPENAI_ENDPOINT is not set.
- AZURE_OPENAI_ENDPOINT is not set.
- AZURE_OPENAI_ENDPOINT is not set.
- AZURE_OPENAI_ENDPOINT is not set.
- AZURE_OPENAI_ENDPOINT is not set.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/d24aaa541ee6e989.
Report an issue: GitHub.