Skip to content

AzureAppConfiguration().AsExisting fails with "missing subscription configuration" despite correct env vars and ARM read permissions #10022

@JanKinable

Description

@JanKinable

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I am encountering an issue where builder.AddAzureAppConfiguration("config").AsExisting(configName, configResourceGroupName) consistently fails with a 'missing subscription configuration' error, even when all required environment variables (AZURE_SUBSCRIPTION_ID, AZURE_LOCATION) are correctly set and visible to the AppHost process, and the Azure identity has confirmed management plane (ARM) read permissions for the resource.

Expected Behavior

  • The Aspire AppHost should successfully discover and register the existing Azure App Configuration resource by performing an Azure Resource Manager (ARM) lookup.
  • The application should start without any errors related to App Configuration discovery, and the App Configuration resource should be correctly integrated into the Aspire application model.

Steps To Reproduce

  1. Create a new .NET Aspire Starter Application (or integrate into an existing one).
  2. Add the Microsoft.Net.Aspire.Hosting.Azure NuGet package to the AppHost project.
  3. In the Azure subscription, create an Azure App Configuration resource named from an exisitng one within a existing resource group for the known location.
  4. Ensure the Azure CLI (or Azure PowerShell) is logged in with an account that has "Owner" or "Contributor" role on the subscription/resource group, or at least "Reader" on the App Configuration resource. (Crucially, confirm this identity has Microsoft.AppConfiguration/configurationStores/read permission).
  5. In the Aspire AppHost Program.cs, add the following code:
// Program.cs in AppHost project

// ... (any existing usings or builder initialization)

// BEGIN Debugging Output - Confirming Environment Variables
Console.WriteLine("--- AppHost Environment Variables ---");
Console.WriteLine($"AZURE_SUBSCRIPTION_ID: {Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID")}");
Console.WriteLine($"AZURE_LOCATION: {Environment.GetEnvironmentVariable("AZURE_LOCATION")}");
Console.WriteLine($"DOTNET_ENVIRONMENT: {Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT")}");
Console.WriteLine("--- End AppHost Environment Variables ---");
// END Debugging Output

var configName = builder.AddParameter("name-of-the-appconfiguration");
var configResourceGroupName = builder.AddParameter("name-of-the-resourcegroup");
var appConfig = builder.AddAzureAppConfiguration("config")
                        .AsExisting(configName, configResourceGroupName);

// ... (rest of your AppHost setup)
  1. Set the AZURE_SUBSCRIPTION_ID and AZURE_LOCATION environment variables for the AppHost process.
    azd env set AZURE_SUBSCRIPTION_ID "c1bcd...04a"
    azd env set AZURE_LOCATION "West Europe" # Note exact casing and space

Exceptions (if any)

Resource could not be provisioned because Azure subscription, location, and resource group information is missing. See https://aka.ms/dotnet/aspire/azure/provisioning for more details.

.NET Version info

  • Aspire Version: 9.3.1
  • Target framework: net9.0
  • .net SDK version: 9.0.3
  • Operation system: Windows 11
  • IDE: Microsoft Visual Studio Community 2022 (64-bit) - Version 17.14.7

Anything else?

  • Confirmation the env where correctly set (via console output)
  • Confirmation of successful ARM Read Access by running the az resource show --name --resource-group --resource-type Microsoft.AppConfiguration/configurationStores --subscription c1bcd...1d04a

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-integrationsIssues pertaining to Aspire Integrations packages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions