Skip to content

Commit 5f066a5

Browse files
committed
fixes
1 parent 5232ba7 commit 5f066a5

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

docs/azure/sdk/authentication/best-practices.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ For information on this approach, see [Authenticate using Microsoft Entra ID](/d
2525

2626
Other types of .NET apps can reuse credential instances as follows:
2727

28-
:::code language="csharp" source="../snippets/auth-best-practices/Program.cs" id="snippet_credential_reuse_noDac" highlight="7, 11" :::
28+
:::code language="csharp" source="../snippets/auth-best-practices/Program.cs" id="snippet_credential_reuse_noDac" highlight="8, 12" :::
2929

3030
## Understand the managed identity retry strategy
3131

3232
The Azure Identity library for .NET allows you to authenticate via managed identity with `ManagedIdentityCredential`. The way you use `ManagedIdentityCredential` impacts the applied retry strategy:
3333

3434
- When used via `DefaultAzureCredential`:
3535
- No retries are attempted when token acquisition fails.
36-
- When used via any other approach, such as through `ChainedTokenCredential` or `ManagedIdentityCredential` directly:
36+
- When used via any other approach, such as `ChainedTokenCredential` or `ManagedIdentityCredential` directly:
3737
- The time interval between retries starts at 0.8 seconds, and a maximum of five retries are attempted.
3838
- When the Azure service to which you're authenticating provides a `Retry-After` response header, the next retry is delayed by the duration specified in that header's value.
3939
- When the service doesn't provide a `Retry-After` header, the maximum permissible delay between retries is 1 minute.
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11

2-
`DefaultAzureCredential` is the easiest way to get started with the Azure Identity library, but with that convenience comes certain tradeoffs. Perhaps the most significant tradeoff is the credential chain's indeterministic behavior - that is, the specific credential in the [chain](/dotnet/api/azure.identity.defaultazurecredential?view=azure-dotnet) that will succeed and be used for request authentication can't be guaranteed ahead of time. In a production environment, this unpredictability can introduce significant and sometimes subtle problems. Once you deploy your app to Azure, you should understand the app's authentication requirements.
2+
`DefaultAzureCredential` is the most approachable way to get started with the Azure Identity library, but that convenience also introduces certain tradeoffs. For example, the specific credential in the [chain](/dotnet/api/azure.identity.defaultazurecredential?view=azure-dotnet) that will succeed and be used for request authentication can't be guaranteed ahead of time. In a production environment, this unpredictability can introduce significant and sometimes subtle problems.
33

44
For example, consider the following hypothetical sequence of events:
55

6-
1. An organization's security team mandates that all apps use managed identity to authenticate to Azure resources.
6+
1. An organization's security team mandates all apps use managed identity to authenticate to Azure resources.
77
1. For months, a .NET app hosted on an Azure Virtual Machine (VM) successfully uses `DefaultAzureCredential` to authenticate via managed identity.
88
1. Unbeknownst to the support team, a developer installs the Azure CLI on that VM and runs the `az login` command to sign-in to Azure.
9-
1. Authentication via the original managed identity unexpectedly begins to fail due to changes in the Azure environment.
10-
1. `DefaultAzureCredential` skips `ManagedIdentityCredential` and searches for the next available credential, which is the Azure CLI credentials.
9+
1. Due to a change in the Azure environment, Authentication via the original managed identity unexpectedly begins to fail.
10+
1. `DefaultAzureCredential` skips the failed `ManagedIdentityCredential` and searches for the next available credential, which is the Azure CLI credentials.
1111
1. Because logging is disabled by default, nobody is aware of this failure, as `DefaultAzureCredential` recovers gracefully.
1212

13-
`DefaultAzureCredential` can also introduce the following challenges:
13+
`DefaultAzureCredential` also introduces the following challenges in some scenarios:
1414

15-
- **Debugging challenges**: When authentication fails, it can be challenging to debug and identify the offending credential. You must enable logging to see the progression from one credential to the next and the success/failure status of each. For more information, see [Debug a chained credential](/dotnet/azure/sdk/authentication/credential-chains?tabs=dac#debug-a-chained-credential).
16-
- **Performance overhead**: The process of sequentially trying multiple credentials can introduce performance overhead. For example, when running on a local development machine, managed identity is unavailable. Consequently, `ManagedIdentityCredential` always fails in the local development environment, unless explicitly disabled via its corresponding `Exclude`-prefixed property.
15+
- **Debugging challenges**: When authentication fails, it can be difficult to debug and identify the offending credential. You must enable logging to see the progression from one credential to the next and the success or failure status of each. For more information, see [Debug a chained credential](/dotnet/azure/sdk/authentication/credential-chains?tabs=dac#debug-a-chained-credential).
16+
- **Performance overhead**: Sequentially attempting multiple credentials can introduce performance overhead. For example, when running on a local development machine, managed identity is unavailable. Consequently, `ManagedIdentityCredential` always fails in the local development environment, unless explicitly disabled via its corresponding `Exclude`-prefixed property.
1717

18-
To prevent these types of subtle issues or silent failures in production apps, strongly consider moving from `DefaultAzureCredential` to one of the following solutions:
18+
To prevent these types of subtle issues or silent failures in production apps, strongly consider moving from `DefaultAzureCredential` to one of the following deterministic solutions:
1919

2020
- A specific `TokenCredential` implementation, such as `ManagedIdentityCredential`. See the [**Derived** list](/dotnet/api/azure.core.tokencredential?view=azure-dotnet&preserve-view=true#definition) for options.
2121
- A pared-down `ChainedTokenCredential` implementation optimized for the Azure environment in which your app runs. `ChainedTokenCredential` essentially creates a specific allow-list of acceptable credential options, such as `ManagedIdentity` for production and `VisualStudioCredential` for development.
2222

23-
Consider the following `DefaultAzureCredential` example:
23+
For example, consider the following `DefaultAzureCredential` configuration:
2424

25-
:::code language="csharp" source="../snippets/authentication/credential-chains/Program.cs" id="snippet_Dac" highlight="6":::
25+
:::code language="csharp" source="../snippets/authentication/credential-chains/Program.cs" id="snippet_Dac" highlight="6,7":::
2626

27-
Replace the preceding code with the following `ChainedTokenCredential` implementation, specifying your desired credentials:
27+
Replace the preceding code with the following `ChainedTokenCredential` implementation to intentionally specify your desired credentials:
2828

29-
:::code language="csharp" source="../snippets/authentication/credential-chains/Program.cs" id="snippet_Dac" highlight="snippet_Ctc":::
29+
:::code language="csharp" source="../snippets/authentication/credential-chains/Program.cs" id="snippet_Ctc" highlight="6-8":::

0 commit comments

Comments
 (0)