Skip to content

Commit 92522b7

Browse files
committed
Update code sample
1 parent 7b9f771 commit 92522b7

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,8 @@ The Azure Identity library for .NET allows you to authenticate via managed ident
9090
- Use `ManagedIdentityCredential` directly
9191
- **How it works:** The time interval between retries starts at 0.8 seconds, and a maximum of five retries are attempted, by default. This mode is optimized for resilience but introduces potentially unwanted delays in the development inner loop.
9292

93-
To change the default retry settings, use the <xref:Azure.Core.ClientOptions.Retry%2A> property. For example, retry a maximum of three times, with a starting interval of 0.5 seconds:
94-
95-
# [DefaultAzureCredential](#tab/dac)
96-
97-
:::code language="csharp" source="../snippets/authentication/best-practices/CCA/Program.cs" id="snippet_retries_dac" highlight="4-8":::
98-
99-
# [ManagedIdentityCredential](#tab/mic)
93+
To change the default retry settings, use the <xref:Azure.Core.ClientOptions.Retry%2A> property on `DefaultAzureCredentialOptions` or `ManagedIdentityCredentialOptions`. For example, retry a maximum of three times, with a starting interval of 0.5 seconds:
10094

10195
:::code language="csharp" source="../snippets/authentication/best-practices/CCA/Program.cs" id="snippet_retries_mic" highlight="5-9":::
10296

103-
---
104-
10597
For more information on customizing retry policies, see [Setting a custom retry policy](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Configuration.md#setting-a-custom-retry-policy).

docs/azure/sdk/snippets/authentication/best-practices/CCA/Program.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
});
3737
#endregion snippet_credential_reuse_AspNetCore
3838

39-
#region snippet_retries_mic
39+
#region snippet_retries
4040
ManagedIdentityCredentialOptions miCredentialOptions = new(
4141
ManagedIdentityId.FromUserAssignedClientId(clientId)
4242
)
@@ -51,20 +51,6 @@
5151
ManagedIdentityCredential miCredential = new(miCredentialOptions);
5252
#endregion
5353

54-
#region snippet_retries_dac
55-
DefaultAzureCredentialOptions dacOptions = new()
56-
{
57-
ManagedIdentityClientId = clientId,
58-
Retry =
59-
{
60-
MaxRetries = 3,
61-
Delay = TimeSpan.FromSeconds(0.5),
62-
}
63-
};
64-
65-
DefaultAzureCredential credential = new(dacOptions);
66-
#endregion
67-
6854
builder.Services.AddEndpointsApiExplorer();
6955

7056
var app = builder.Build();

0 commit comments

Comments
 (0)