Default Azure credential
When an Aspire Azure client integration needs to authenticate with an Azure service, it uses a credential. If no credential is explicitly configured, Aspire uses a default credential that is optimized for both local development and production environments in Azure.
Default credential behavior
Section titled “Default credential behavior”Starting in Aspire 13.2, the default credential behavior was updated to follow Azure SDK authentication best practices and use deterministic credentials in production environments. Rather than using the parameterless DefaultAzureCredential constructor, Aspire detects the runtime environment and selects the most appropriate credential:
AZURE_TOKEN_CREDENTIALSis set: When theAZURE_TOKEN_CREDENTIALSenvironment variable is present, aDefaultAzureCredentialis created using that environment variable to customize the credential chain. Aspire’s Azure hosting integrations set this variable automatically when deploying to Azure Container Apps or Azure App Service.- Running in Azure (without
AZURE_TOKEN_CREDENTIALS): When Aspire detects that the application is running in Azure by the presence of theAZURE_CLIENT_IDenvironment variable, it usesManagedIdentityCredential. This ensures deterministic, efficient authentication in production. - Local development: When no Azure environment is detected, a
DefaultAzureCredentialconfigured for development is used. This credential excludesEnvironmentCredential,WorkloadIdentityCredential, andManagedIdentityCredential—leaving only credentials applicable to developer machines, such as the Azure CLI, Visual Studio, or Azure Developer CLI credentials.
Override the default credential
Section titled “Override the default credential”If you need to use a different credential in your application, you can provide your own by configuring the integration’s settings. For example, to use EnvironmentCredential with Azure Blob Storage:
builder.AddAzureBlobServiceClient( "blobs", settings => { settings.Credential = new EnvironmentCredential(); });Each Aspire Azure client integration exposes a Credential property in its settings that you can set to any TokenCredential instance.