Skip to content

Commit f33513f

Browse files
authored
Document AZURE_TOKEN_CREDENTIALS env var in credential chains doc (#46495)
* Document AZURE_TOKEN_CREDENTIALS env var in credential chains doc * Update mermaid diagram * Add more clarity * React to feedback
1 parent c5e0427 commit f33513f

File tree

5 files changed

+83
-2
lines changed

5 files changed

+83
-2
lines changed

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

Lines changed: 19 additions & 2 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: conceptual
5-
ms.date: 02/13/2025
5+
ms.date: 05/30/2025
66
---
77

88
# Credential chains in the Azure Identity library for .NET
@@ -70,7 +70,11 @@ In its simplest form, you can use the parameterless version of `DefaultAzureCred
7070
7171
### How to customize DefaultAzureCredential
7272

73-
To remove a credential from `DefaultAzureCredential`, use the corresponding `Exclude`-prefixed property in [DefaultAzureCredentialOptions](/dotnet/api/azure.identity.defaultazurecredentialoptions?view=azure-dotnet&preserve-view=true#properties). For example:
73+
The following sections describe strategies for omitting credentials from the chain.
74+
75+
#### Exclude an individual credential
76+
77+
To exclude an individual credential from `DefaultAzureCredential`, use the corresponding `Exclude`-prefixed property in [DefaultAzureCredentialOptions](/dotnet/api/azure.identity.defaultazurecredentialoptions?view=azure-dotnet&preserve-view=true#properties). For example:
7478

7579
:::code language="csharp" source="../snippets/authentication/credential-chains/Program.cs" id="snippet_DacExcludes" highlight="11-13":::
7680

@@ -93,6 +97,19 @@ As more `Exclude`-prefixed properties are set to `true` (credential exclusions a
9397

9498
---
9599

100+
#### Exclude a credential type category
101+
102+
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:
103+
104+
:::image type="content" source="../media/mermaidjs/DefaultAzureCredentialEnvVarProd.svg" alt-text="DefaultAzureCredential with AZURE_TOKEN_CREDENTIALS set to 'prod'":::
105+
106+
When a value of `dev` is used, the chain looks as follows:
107+
108+
:::image type="content" source="../media/mermaidjs/DefaultAzureCredentialEnvVarDev.svg" alt-text="DefaultAzureCredential with AZURE_TOKEN_CREDENTIALS set to 'dev'":::
109+
110+
> [!IMPORTANT]
111+
> The `AZURE_TOKEN_CREDENTIALS` environment variable is supported in `Azure.Identity` package versions 1.14.0 and later.
112+
96113
## ChainedTokenCredential overview
97114

98115
[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:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
ms.topic: include
3+
ms.date: 05/30/2025
4+
---
5+
6+
```mermaid
7+
%% STEPS TO GENERATE IMAGE
8+
%% =======================
9+
%% 1. Install mermaid CLI v10.9.1 (see https://github.com/mermaid-js/mermaid-cli/blob/master/README.md):
10+
%% npm i -g @mermaid-js/[email protected]
11+
%% 2. Run command: mmdc -i DefaultAzureCredentialEnvVarDev.md -o ../../media/mermaidjs/DefaultAzureCredentialEnvVarDev.svg
12+
13+
%%{
14+
init: {
15+
'theme': 'base',
16+
'themeVariables': {
17+
'tertiaryBorderColor': '#fff',
18+
'tertiaryColor': '#fff'
19+
}
20+
}
21+
}%%
22+
23+
flowchart LR;
24+
accTitle: DefaultAzureCredential authentication flow without deployed service credentials;
25+
accDescr: Flowchart showing the credential chain implemented by DefaultAzureCredential when AZURE_TOKEN_CREDENTIALS is set to "dev";
26+
27+
D(Visual Studio):::developer --> E(Azure CLI):::developer --> F(Azure PowerShell):::developer --> G(Azure Developer CLI):::developer;
28+
29+
%% Define styles for credential type boxes
30+
classDef developer fill:#F5AF6F, stroke:#EB7C39, stroke-width:2px;
31+
```
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
ms.topic: include
3+
ms.date: 05/30/2025
4+
---
5+
6+
```mermaid
7+
%% STEPS TO GENERATE IMAGE
8+
%% =======================
9+
%% 1. Install mermaid CLI v10.9.1 (see https://github.com/mermaid-js/mermaid-cli/blob/master/README.md):
10+
%% npm i -g @mermaid-js/[email protected]
11+
%% 2. Run command: mmdc -i DefaultAzureCredentialEnvVarProd.md -o ../../media/mermaidjs/DefaultAzureCredentialEnvVarProd.svg
12+
13+
%%{
14+
init: {
15+
'theme': 'base',
16+
'themeVariables': {
17+
'tertiaryBorderColor': '#fff',
18+
'tertiaryColor': '#fff'
19+
}
20+
}
21+
}%%
22+
23+
flowchart LR;
24+
accTitle: DefaultAzureCredential authentication flow without developer tool credentials;
25+
accDescr: Flowchart showing the credential chain implemented by DefaultAzureCredential when AZURE_TOKEN_CREDENTIALS is set to "prod";
26+
27+
A(Environment):::deployed --> B(Workload Identity):::deployed --> C(Managed Identity):::deployed;
28+
29+
%% Define styles for credential type boxes
30+
classDef deployed fill:#95C37E, stroke:#71AD4C, stroke-width:2px;
31+
```

0 commit comments

Comments
 (0)