microsoft/aspire · critical · InvalidOperationException
Endpoint and connection string are missing. It should be…
Error message
Endpoint and connection string are missing. It should be provided in 'ConnectionStrings:{connectionName}' or under the 'Endpoint' and 'ConnectionString' key in the '{DefaultConfigSectionName}' configuration section. What it means
Azure App Configuration requires either an endpoint (with AAD/credential auth) or a connection string. After applying configureSettings, if both MicrosoftAppConfigurationSettings.Endpoint and ConnectionString are still null, Aspire throws because AddAzureAppConfiguration cannot construct a client. The values can come from the connection string binding or the 'Aspire:Microsoft:Extensions:Configuration:AzureAppConfiguration' section.
Solutions
- Add the App Configuration resource reference in the AppHost so 'ConnectionStrings:{connectionName}' is injected.
- Or set Endpoint (e.g. https://<store>.azconfig.io) in the 'Aspire:Microsoft:Extensions:Configuration:AzureAppConfiguration' section.
- Or set ConnectionString directly in that configuration section or via the connection string binding.
- Confirm the connectionName argument matches the configuration key.
Example fix
// before (appsettings.json)
{ }
// after
{ "ConnectionStrings": { "appconfig": "https://mystore.azconfig.io" } }
// AppHost: builder.AddProject<Projects.Api>("api").WithReference(appConfiguration); Defensive patterns
Strategy: validation
Validate before calling
// fail fast before AddAzureAppConfiguration
var cs = builder.Configuration.GetConnectionString(connectionName);
var section = builder.Configuration.GetSection("Aspire:Microsoft:Extensions:Configuration:AzureAppConfiguration");
if (cs is null && section["Endpoint"] is null && section["ConnectionString"] is null)
{
throw new InvalidOperationException($"App Configuration endpoint/connection string missing for '{connectionName}'.");
} Type guard
bool HasAppConfigInfo(string? cs, string? endpoint, string? connStr) => !string.IsNullOrEmpty(cs) || endpoint is not null || connStr is not null;
Try / catch
try { builder.AddAzureAppConfiguration(connectionName); }
catch (InvalidOperationException ex) when (ex.Message.Contains("Endpoint and connection string are missing")) { logger.LogCritical(ex, "Azure App Configuration not set for {ConnectionName}", connectionName); throw; } Prevention
- Reference the App Configuration resource in the AppHost with WithReference.
- Provide the store endpoint (https://<store>.azconfig.io) for managed-identity scenarios.
- Validate config presence in a startup guard so failures are immediate and clear.
When it happens
Trigger: Calling AddAzureAppConfiguration(connectionName) where ConnectionStrings:{connectionName} is missing AND settings.Endpoint/ConnectionString are not provided in the DefaultConfigSectionName configuration section.
Common situations: Forgetting WithReference(azureAppConfig) in the AppHost so no connection string is injected; local dev appsettings missing the endpoint; connection name typo; relying on DefaultAzureCredential without providing the endpoint URI.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- A DbContext could not be configured. Ensure valid…
- A MilvusClient could not be configured. Ensure valid…
- A BlobServiceClient could not be configured. Ensure valid…
- A BlobServiceClient could not be configured. Ensure valid…
- A ChatCompletionsClient could not be configured. Ensure…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/0ea95ed0742f9aaa.
Report an issue: GitHub.
Appendix: source
Thrown at src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/AspireAppConfigurationExtensions.cs:70
{
ArgumentNullException.ThrowIfNull(builder);
ArgumentException.ThrowIfNullOrEmpty(connectionName);
IConfigurationSection configSection = builder.Configuration.GetSection(DefaultConfigSectionName);
var settings = new AzureAppConfigurationSettings();
configSection.Bind(settings);
if (builder.Configuration.GetConnectionString(connectionName) is string connectionString)
{
((IConnectionStringSettings)settings).ParseConnectionString(connectionString);
}
configureSettings?.Invoke(settings);
if (settings.Endpoint is null && settings.ConnectionString is null)
{
throw new InvalidOperationException($"Endpoint and connection string are missing. It should be provided in 'ConnectionStrings:{connectionName}' or under the 'Endpoint' and 'ConnectionString' key in the '{DefaultConfigSectionName}' configuration section.");
}
builder.Configuration.AddAzureAppConfiguration(
options =>
{
if (settings.ConnectionString is null)
{
options.Connect(settings.Endpoint, settings.Credential ?? AzureCredentialHelper.CreateDefaultAzureCredential());
}
else
{
options.Connect(settings.ConnectionString);
if (settings.AnonymousAccess)
{
// remove the Authorization header to send anonymous requests
options.ConfigureClientOptions(clientOptions =>
clientOptions.AddPolicy(new RemoveAuthorizationHeaderPolicy(), HttpPipelinePosition.PerRetry));
}View on GitHub (pinned to 25830f84bd)