Skip to content

Commit 48cedca

Browse files
Update credential chains doc for Azure Identity v1.15.0 release (#47948)
* Update credential chains doc for Azure Identity v1.15.0 release * Add new section * Update file names * Add missing images * Fix cred name * Update docs/azure/sdk/authentication/credential-chains.md Co-authored-by: Christopher Scott <chriscott@hotmail.com> --------- Co-authored-by: Christopher Scott <chriscott@hotmail.com>
1 parent 0c33dbd commit 48cedca

19 files changed

+80
-33
lines changed

docs/azure/sdk/authentication/credential-chains.md

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: 'Credential chains in the Azure Identity library for .NET'
33
description: 'This article describes the DefaultAzureCredential and ChainedTokenCredential classes in the Azure Identity library.'
44
ms.topic: concept-article
5-
ms.date: 05/30/2025
5+
ms.date: 08/13/2025
66
---
77

88
# Credential chains in the Azure Identity library for .NET
@@ -13,7 +13,7 @@ The Azure Identity library provides *credentials*&mdash;public classes derived f
1313

1414
At runtime, a credential chain attempts to authenticate using the sequence's first credential. If that credential fails to acquire an access token, the next credential in the sequence is attempted, and so on, until an access token is successfully obtained. The following sequence diagram illustrates this behavior:
1515

16-
:::image type="content" source="../media/mermaidjs/ChainSequence.svg" alt-text="Credential chain sequence diagram":::
16+
:::image type="content" source="../media/mermaidjs/chain-sequence.svg" alt-text="Credential chain sequence diagram":::
1717

1818
## Why use credential chains
1919

@@ -37,7 +37,7 @@ There are two disparate philosophies to credential chaining:
3737

3838
[DefaultAzureCredential](/dotnet/api/azure.identity.defaultazurecredential?view=azure-dotnet&preserve-view=true) is an opinionated, preconfigured chain of credentials. It's designed to support many environments, along with the most common authentication flows and developer tools. In graphical form, the underlying chain looks like this:
3939

40-
:::image type="content" source="../media/mermaidjs/DefaultAzureCredentialAuthFlow.svg" alt-text="DefaultAzureCredential auth flowchart":::
40+
:::image type="content" source="../media/mermaidjs/default-azure-credential-authentication-flow-inline.svg" alt-text="Diagram that shows DefaultAzureCredential authentication flow." lightbox="../media/mermaidjs/default-azure-credential-authentication-flow-expanded.png":::
4141

4242
The order in which `DefaultAzureCredential` attempts credentials follows.
4343

@@ -47,19 +47,24 @@ The order in which `DefaultAzureCredential` attempts credentials follows.
4747
| 2 | [Workload Identity][wi-cred] |If the app is deployed to an Azure host with Workload Identity enabled, authenticate that account. | Yes |
4848
| 3 | [Managed Identity][mi-cred] |If the app is deployed to an Azure host with Managed Identity enabled, authenticate the app to Azure using that Managed Identity. | Yes |
4949
| 4 | [Visual Studio][vs-cred] |If the developer authenticated to Azure by logging into Visual Studio, authenticate the app to Azure using that same account. | Yes |
50-
| 5 | [Azure CLI][az-cred] |If the developer authenticated to Azure using Azure CLI's `az login` command, authenticate the app to Azure using that same account. | Yes |
51-
| 6 | [Azure PowerShell][pwsh-cred] |If the developer authenticated to Azure using Azure PowerShell's `Connect-AzAccount` cmdlet, authenticate the app to Azure using that same account. | Yes |
52-
| 7 | [Azure Developer CLI][azd-cred] |If the developer authenticated to Azure using Azure Developer CLI's `azd auth login` command, authenticate with that account. | Yes |
53-
| 8 | [Interactive browser][int-cred] |If enabled, interactively authenticate the developer via the current system's default browser. | No |
50+
| 5 | [Visual Studio Code][vsc-cred] |If the developer authenticated via Visual Studio Code's [Azure Resources extension][vsc-ext] and the [Azure.Identity.Broker package][broker-pkg] is installed, authenticate that account. | Yes |
51+
| 6 | [Azure CLI][az-cred] |If the developer authenticated to Azure using Azure CLI's `az login` command, authenticate the app to Azure using that same account. | Yes |
52+
| 7 | [Azure PowerShell][pwsh-cred] |If the developer authenticated to Azure using Azure PowerShell's `Connect-AzAccount` cmdlet, authenticate the app to Azure using that same account. | Yes |
53+
| 8 | [Azure Developer CLI][azd-cred] |If the developer authenticated to Azure using Azure Developer CLI's `azd auth login` command, authenticate with that account. | Yes |
54+
| 9 | [Interactive browser][int-cred] |If enabled, interactively authenticate the developer via the current system's default browser. | No |
55+
| 10 | [Broker][int-cred] |Authenticates using the default account logged into the OS via a broker. Requires that the [Azure.Identity.Broker package][broker-pkg] is installed. | Yes |
5456

5557
[env-cred]: /dotnet/api/azure.identity.environmentcredential?view=azure-dotnet&preserve-view=true
5658
[wi-cred]: /dotnet/api/azure.identity.workloadidentitycredential?view=azure-dotnet&preserve-view=true
5759
[mi-cred]: /dotnet/api/azure.identity.managedidentitycredential?view=azure-dotnet&preserve-view=true
5860
[vs-cred]: /dotnet/api/azure.identity.visualstudiocredential?view=azure-dotnet&preserve-view=true
61+
[vsc-cred]: /dotnet/api/azure.identity.visualstudiocodecredential?view=azure-dotnet&preserve-view=true
5962
[az-cred]: /dotnet/api/azure.identity.azureclicredential?view=azure-dotnet&preserve-view=true
6063
[pwsh-cred]: /dotnet/api/azure.identity.azurepowershellcredential?view=azure-dotnet&preserve-view=true
6164
[azd-cred]: /dotnet/api/azure.identity.azuredeveloperclicredential?view=azure-dotnet&preserve-view=true
6265
[int-cred]: /dotnet/api/azure.identity.interactivebrowsercredential?view=azure-dotnet&preserve-view=true
66+
[vsc-ext]: https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azureresourcegroups
67+
[broker-pkg]: https://www.nuget.org/packages/Azure.Identity.Broker
6368

6469
In its simplest form, you can use the parameterless version of `DefaultAzureCredential` as follows:
6570

@@ -70,7 +75,7 @@ In its simplest form, you can use the parameterless version of `DefaultAzureCred
7075
7176
### How to customize DefaultAzureCredential
7277

73-
The following sections describe strategies for omitting credentials from the chain.
78+
The following sections describe strategies for controlling which credentials are included in the chain.
7479

7580
#### Exclude an individual credential
7681

@@ -80,7 +85,7 @@ To exclude an individual credential from `DefaultAzureCredential`, use the corre
8085

8186
In the preceding code sample, `EnvironmentCredential`, `ManagedIdentityCredential`, and `WorkloadIdentityCredential` are removed from the credential chain. As a result, the first credential to be attempted is `VisualStudioCredential`. The modified chain contains only development-time credentials and looks like this:
8287

83-
:::image type="content" source="../media/mermaidjs/DefaultAzureCredentialExcludes.svg" alt-text="DefaultAzureCredential using Excludes properties":::
88+
:::image type="content" source="../media/mermaidjs/default-azure-credential-excludes.svg" alt-text="DefaultAzureCredential using Excludes properties":::
8489

8590
> [!NOTE]
8691
> `InteractiveBrowserCredential` is excluded by default and therefore isn't shown in the preceding diagram. To include `InteractiveBrowserCredential`, either pass `true` to constructor <xref:Azure.Identity.DefaultAzureCredential.%23ctor%28System.Boolean%29> or set property <xref:Azure.Identity.DefaultAzureCredentialOptions.ExcludeInteractiveBrowserCredential%2A?displayProperty=nameWithType> to `false`.
@@ -101,15 +106,33 @@ As more `Exclude`-prefixed properties are set to `true` (credential exclusions a
101106

102107
To exclude all `Developer tool` or `Deployed service` credentials, set environment variable `AZURE_TOKEN_CREDENTIALS` to `prod` or `dev`, respectively. When a value of `prod` is used, the underlying credential chain looks as follows:
103108

104-
:::image type="content" source="../media/mermaidjs/DefaultAzureCredentialEnvVarProd.svg" alt-text="DefaultAzureCredential with AZURE_TOKEN_CREDENTIALS set to 'prod'":::
109+
:::image type="content" source="../media/mermaidjs/default-azure-credential-environment-variable-production.svg" alt-text="DefaultAzureCredential with AZURE_TOKEN_CREDENTIALS set to 'prod'":::
105110

106111
When a value of `dev` is used, the chain looks as follows:
107112

108-
:::image type="content" source="../media/mermaidjs/DefaultAzureCredentialEnvVarDev.svg" alt-text="DefaultAzureCredential with AZURE_TOKEN_CREDENTIALS set to 'dev'":::
113+
:::image type="content" source="../media/mermaidjs/default-azure-credential-environment-variable-development.svg" alt-text="DefaultAzureCredential with AZURE_TOKEN_CREDENTIALS set to 'dev'":::
109114

110115
> [!IMPORTANT]
111116
> The `AZURE_TOKEN_CREDENTIALS` environment variable is supported in `Azure.Identity` package versions 1.14.0 and later.
112117
118+
#### Use a specific credential
119+
120+
To exclude all credentials except for one, set environment variable `AZURE_TOKEN_CREDENTIALS` to the credential name. For example, you can reduce the `DefaultAzureCredential` chain to `VisualStudioCredential` by setting `AZURE_TOKEN_CREDENTIALS` to `VisualStudioCredential`. The string comparison is performed in a case-insensitive manner. Valid string values for the environment variable include:
121+
122+
- `AzureCliCredential`
123+
- `AzureDeveloperCliCredential`
124+
- `AzurePowerShellCredential`
125+
- `BrokerCredential`
126+
- `EnvironmentCredential`
127+
- `InteractiveBrowserCredential`
128+
- `ManagedIdentityCredential`
129+
- `VisualStudioCredential`
130+
- `VisualStudioCodeCredential`
131+
- `WorkloadIdentityCredential`
132+
133+
> [!IMPORTANT]
134+
> The `AZURE_TOKEN_CREDENTIALS` environment variable supports individual credential names in `Azure.Identity` package versions 1.15.0 and later.
135+
113136
## ChainedTokenCredential overview
114137

115138
[ChainedTokenCredential](/dotnet/api/azure.identity.chainedtokencredential?view=azure-dotnet&preserve-view=true) is an empty chain to which you add credentials to suit your app's needs. For example:
@@ -118,7 +141,7 @@ When a value of `dev` is used, the chain looks as follows:
118141

119142
The preceding code sample creates a tailored credential chain comprised of two development-time credentials. `AzurePowerShellCredential` is attempted first, followed by `VisualStudioCredential`, if necessary. In graphical form, the chain looks like this:
120143

121-
:::image type="content" source="../media/mermaidjs/ChainedTokenCredentialAuthFlow.svg" alt-text="ChainedTokenCredential":::
144+
:::image type="content" source="../media/mermaidjs/chained-token-credential-authentication-flow.svg" alt-text="ChainedTokenCredential":::
122145

123146
> [!TIP]
124147
> For improved performance, optimize credential ordering in `ChainedTokenCredential` from most to least used credential.

docs/azure/sdk/media/mermaidjs/DefaultAzureCredentialAuthFlow.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/azure/sdk/media/mermaidjs/DefaultAzureCredentialEnvVarDev.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)