microsoft/autogen · critical · ConfigurationErrorsException
Orleans:CosmosDBConnectionString is missing from configurati
Error message
Orleans:CosmosDBConnectionString is missing from configuration. This is required for persistence in production environments.
What it means
ConfigurationErrorsException thrown by the Orleans runtime hosting extension when the environment is not development and 'Orleans:CosmosDBConnectionString' is absent from configuration. In production mode the silo is configured with Cosmos DB clustering/persistence, which is impossible without the connection string, so startup aborts.
Source
Thrown at dotnet/src/Microsoft.AutoGen/RuntimeGateway.Grpc/Services/Orleans/OrleansRuntimeHostingExtenions.cs:41
{
// Development mode or local mode uses in-memory storage and streams
if (builder.Environment.IsDevelopment())
{
siloBuilder.UseLocalhostClustering()
.AddMemoryStreams("StreamProvider")
.AddMemoryGrainStorage("PubSubStore")
.AddMemoryGrainStorage("AgentRegistryStore")
.AddMemoryGrainStorage("AgentStateStore");
siloBuilder.UseInMemoryReminderService();
siloBuilder.UseDashboard(x => x.HostSelf = true);
siloBuilder.UseInMemoryReminderService();
}
else
{
var cosmosDbconnectionString = builder.Configuration.GetValue<string>("Orleans:CosmosDBConnectionString") ??
throw new ConfigurationErrorsException(
"Orleans:CosmosDBConnectionString is missing from configuration. This is required for persistence in production environments.");
siloBuilder.Configure<SiloMessagingOptions>(options =>
{
options.ResponseTimeout = TimeSpan.FromMinutes(3);
options.SystemResponseTimeout = TimeSpan.FromMinutes(3);
});
siloBuilder.Configure<ClientMessagingOptions>(options =>
{
options.ResponseTimeout = TimeSpan.FromMinutes(3);
});
siloBuilder.UseCosmosClustering(o =>
{
o.ConfigureCosmosClient(cosmosDbconnectionString);
o.ContainerName = "AutoGen";
o.DatabaseName = "clustering";
o.IsResourceCreationEnabled = true;
});View on GitHub (pinned to 027ecf0a37)
Solutions
- Provide the key exactly as 'Orleans:CosmosDBConnectionString' in the production configuration source (appsettings.Production.json, environment variable Orleans__CosmosDBConnectionString, or KeyVault).
- Verify with a startup log or config dump (never log the value) that the key resolves before the silo builder runs.
- For local non-development testing, either set the connection string or keep the environment as Development to get the in-memory stores.
Example fix
# before export ASPNETCORE_ENVIRONMENT=Production # Orleans:CosmosDBConnectionString unset -> startup throws # after export ASPNETCORE_ENVIRONMENT=Production export Orleans__CosmosDBConnectionString="AccountEndpoint=...;AccountKey=...;"
Defensive patterns
Strategy: validation
Validate before calling
var connectionString = builder.Configuration.GetValue<string>("Orleans:CosmosDBConnectionString");
if (!builder.Environment.IsDevelopment() && string.IsNullOrWhiteSpace(connectionString))
{
throw new InvalidOperationException(
"Refusing to start in production without Orleans:CosmosDBConnectionString. Set Orleans__CosmosDBConnectionString or configure KeyVault.");
} Prevention
- Set Orleans__CosmosDBConnectionString as an environment variable in every non-development deployment.
- Wire a KeyVault configuration provider in Program.cs before the Orleans hosting extension runs.
- Add a deployment smoke test that boots the gateway in Production mode with secrets from the same source as real deploys.
When it happens
Trigger: Running the Grpc runtime gateway with ASPNETCORE_ENVIRONMENT set to Production (anything other than the development branch) while the Orleans:CosmosDBConnectionString configuration key is missing from appsettings, environment variables, user secrets, or KeyVault.
Common situations: Deploying to a container or Azure App Service where the environment flips to Production but secrets were only in local user-secrets; a typo in the key (e.g. 'Orleans:CosmosDbConnectionString'); KeyVault configuration provider not registered in the production host; CI smoke tests that set Production without secrets.
Related errors
- Please set OPENAI_API_KEY environment variable.
- Please set OPENAI_API_KEY environment variable.
- BING_API_KEY environment variable is not set
- Missing MISTRAL_API_KEY environment variable.
- Please set OPENAI_API_KEY environment variable.
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/35586b1bc4f5514f.
Report an issue: GitHub.