{"record":{"id":"67a006867bceff02","repo":"microsoft/aspire","slug":"an-azure-location-region-is-required-set-the-azure-location","errorCode":null,"errorMessage":"An azure location/region is required. Set the Azure:Location configuration value.","messagePattern":"An azure location/region is required\\. Set the Azure:Location configuration value\\.","errorType":"validation","errorClass":"MissingConfigurationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure/Provisioning/Internal/BaseProvisioningContextProvider.cs","lineNumber":111,"sourceCode":"        var subscriptionId = _options.SubscriptionId ?? throw new MissingConfigurationException(\"An Azure subscription id is required. Set the Azure:SubscriptionId configuration value.\");\n\n        var credential = _tokenCredentialProvider.TokenCredential;\n\n        if (_tokenCredentialProvider is DefaultTokenCredentialProvider defaultProvider)\n        {\n            defaultProvider.LogCredentialType();\n        }\n\n        var armClient = _armClientProvider.GetArmClient(credential, subscriptionId);\n\n        var (subscriptionResource, tenantResource) = await armClient.GetSubscriptionAndTenantAsync(cancellationToken).ConfigureAwait(false);\n\n        _logger.LogInformation(\"Default subscription: {name} ({subscriptionId})\", subscriptionResource.DisplayName, subscriptionResource.Id);\n        _logger.LogInformation(\"Tenant: {tenantId}\", tenantResource.TenantId);\n\n        if (string.IsNullOrEmpty(_options.Location))\n        {\n            throw new MissingConfigurationException(\"An azure location/region is required. Set the Azure:Location configuration value.\");\n        }\n\n        // Acquire Azure state section for reading/writing configuration\n        var azureStateSection = await _deploymentStateManager.AcquireSectionAsync(\"Azure\", cancellationToken).ConfigureAwait(false);\n\n        string resourceGroupName;\n        bool createIfAbsent;\n\n        if (string.IsNullOrEmpty(_options.ResourceGroup))\n        {\n            // Generate an resource group name since none was provided\n            // Create a unique resource group name and save it in deployment state\n            resourceGroupName = GetDefaultResourceGroupName();\n\n            createIfAbsent = true;\n\n            azureStateSection.Data[\"ResourceGroup\"] = resourceGroupName;\n        }","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure/Provisioning/Internal/BaseProvisioningContextProvider.cs#L93-L129","documentation":"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.","triggerScenarios":"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.","commonSituations":"Running the AppHost outside `azd` (azd normally injects the location); CI runs without AZURE_LOCATION set; empty-string location from a config placeholder.","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."],"exampleFix":"// before\ndotnet run --project AppHost\n// after\nAZURE_LOCATION=westus2 dotnet run --project AppHost","handlingStrategy":"validation","validationCode":"var location = configuration[\"Azure:Location\"];\nif (string.IsNullOrEmpty(location))\n{\n    throw new InvalidOperationException(\"Set Azure:Location (appsettings or AZURE_LOCATION env var) before provisioning.\");\n}","typeGuard":null,"tryCatchPattern":"try { await provider.CreateProvisioningContextAsync(ct); } catch (MissingConfigurationException ex) when (ex.Message.Contains(\"location\")) { /* configure Azure:Location and retry */ }","preventionTips":["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."],"tags":["azure","configuration","provisioning","region"],"backgroundTag":"missing-required-config","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}