microsoft/aspire · error · MissingConfigurationException
An azure location/region is required. Set the…
Error message
An azure location/region is required. Set the Azure:Location configuration value.
What it means
After resolving the subscription, CreateProvisioningContextAsync requires a default location/region in which resources will be deployed. When options.Location is null or empty it throws MissingConfigurationException directing you to set the Azure:Location configuration value.
Solutions
- Add "Azure": { "Location": "westus2" } to appsettings.json or user secrets of the AppHost.
- Set the AZURE_LOCATION / Azure__Location environment variable before provisioning.
- Run through `azd provision`/`azd up`, which supplies the location from the azure.yaml environment.
- Or set options.Location programmatically in the provisioning options configuration.
Example fix
// before dotnet run --project AppHost // after AZURE_LOCATION=westus2 dotnet run --project AppHost
Defensive patterns
Strategy: validation
Validate before calling
var location = configuration["Azure:Location"];
if (string.IsNullOrEmpty(location))
{
throw new InvalidOperationException("Set Azure:Location (appsettings or AZURE_LOCATION env var) before provisioning.");
} Try / catch
try { await provider.CreateProvisioningContextAsync(ct); } catch (MissingConfigurationException ex) when (ex.Message.Contains("location")) { /* configure Azure:Location and retry */ } Prevention
- Run via `azd up` so AZURE_LOCATION is provided automatically.
- Export AZURE_LOCATION in CI pipelines that provision Azure resources.
- Validate config (subscription + location) at AppHost startup rather than mid-provisioning.
When it happens
Trigger: Provisioning Azure resources with no Azure:Location config entry (appsettings.json, environment variable Azure__Location, or azd-picked region) and no options.Location set programmatically.
Common situations: Running the AppHost outside `azd` (azd normally injects the location); CI runs without AZURE_LOCATION set; empty-string location from a config placeholder.
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
- An Azure subscription id is required. Set the…
- Azure provisioning options can't be changed because the…
- Azure provisioning options were not provided.
- AzureProvisioningFailureException (request failure details…
- A BlobServiceClient could not be configured. Ensure valid…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/67a006867bceff02.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Azure/Provisioning/Internal/BaseProvisioningContextProvider.cs:111
var subscriptionId = _options.SubscriptionId ?? throw new MissingConfigurationException("An Azure subscription id is required. Set the Azure:SubscriptionId configuration value.");
var credential = _tokenCredentialProvider.TokenCredential;
if (_tokenCredentialProvider is DefaultTokenCredentialProvider defaultProvider)
{
defaultProvider.LogCredentialType();
}
var armClient = _armClientProvider.GetArmClient(credential, subscriptionId);
var (subscriptionResource, tenantResource) = await armClient.GetSubscriptionAndTenantAsync(cancellationToken).ConfigureAwait(false);
_logger.LogInformation("Default subscription: {name} ({subscriptionId})", subscriptionResource.DisplayName, subscriptionResource.Id);
_logger.LogInformation("Tenant: {tenantId}", tenantResource.TenantId);
if (string.IsNullOrEmpty(_options.Location))
{
throw new MissingConfigurationException("An azure location/region is required. Set the Azure:Location configuration value.");
}
// Acquire Azure state section for reading/writing configuration
var azureStateSection = await _deploymentStateManager.AcquireSectionAsync("Azure", cancellationToken).ConfigureAwait(false);
string resourceGroupName;
bool createIfAbsent;
if (string.IsNullOrEmpty(_options.ResourceGroup))
{
// Generate an resource group name since none was provided
// Create a unique resource group name and save it in deployment state
resourceGroupName = GetDefaultResourceGroupName();
createIfAbsent = true;
azureStateSection.Data["ResourceGroup"] = resourceGroupName;
}View on GitHub (pinned to 25830f84bd)