diff --git a/docs/azure/sdk/authentication/credential-chains.md b/docs/azure/sdk/authentication/credential-chains.md index 6f068f36e2b49..d4f610d331f05 100644 --- a/docs/azure/sdk/authentication/credential-chains.md +++ b/docs/azure/sdk/authentication/credential-chains.md @@ -2,7 +2,7 @@ title: 'Credential chains in the Azure Identity library for .NET' description: 'This article describes the DefaultAzureCredential and ChainedTokenCredential classes in the Azure Identity library.' ms.topic: concept-article -ms.date: 08/13/2025 +ms.date: 11/05/2025 --- # Credential chains in the Azure Identity library for .NET @@ -112,7 +112,9 @@ When a value of `dev` is used, the chain looks as follows: :::image type="content" source="../media/mermaidjs/default-azure-credential-environment-variable-development.svg" alt-text="DefaultAzureCredential with AZURE_TOKEN_CREDENTIALS set to 'dev'"::: -To ensure the environment variable is defined and set to a supported string, use constructor overload . +To ensure the environment variable is defined and set to a supported string, use constructor overload : + +:::code language="csharp" source="../snippets/authentication/credential-chains/Program.cs" id="snippet_DacEnvVar" highlight="8-9"::: #### Use a specific credential @@ -132,7 +134,9 @@ To exclude all credentials except for one, set environment variable `AZURE_TOKEN > [!IMPORTANT] > The `AZURE_TOKEN_CREDENTIALS` environment variable supports individual credential names in `Azure.Identity` package versions 1.15.0 and later. -To ensure the environment variable is defined and set to a supported string, use constructor overload . +To ensure the environment variable is defined and set to a supported string, use constructor overload : + +:::code language="csharp" source="../snippets/authentication/credential-chains/Program.cs" id="snippet_DacEnvVar" highlight="8-9"::: ## ChainedTokenCredential overview diff --git a/docs/azure/sdk/snippets/authentication/credential-chains/Program.cs b/docs/azure/sdk/snippets/authentication/credential-chains/Program.cs index 81b83a5efccda..dfbe405318ca4 100644 --- a/docs/azure/sdk/snippets/authentication/credential-chains/Program.cs +++ b/docs/azure/sdk/snippets/authentication/credential-chains/Program.cs @@ -32,6 +32,20 @@ }); #endregion snippet_Dac +#region snippet_DacEnvVar +builder.Services.AddAzureClients(clientBuilder => +{ + clientBuilder.AddSecretClient( + new Uri($"https://{keyVaultName}.vault.azure.net")); + clientBuilder.AddBlobServiceClient( + new Uri($"https://{storageAccountName}.blob.core.windows.net")); + + DefaultAzureCredential credential = new( + DefaultAzureCredential.DefaultEnvironmentVariableName); + clientBuilder.UseCredential(credential); +}); +#endregion snippet_DacEnvVar + #region snippet_DacExcludes builder.Services.AddAzureClients(clientBuilder => {