Skip to content

Commit b88224b

Browse files
Edits
1 parent 005c794 commit b88224b

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

articles/storage/common/storage-srp-dotnet-retry.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,35 @@ ms.custom: template-how-to, devguide-csharp, devx-track-dotnet
1515

1616
# Implement a retry policy for Azure Storage management APIs in .NET
1717

18-
When working with Azure Storage management plane APIs, handling transient faults and rate limits effectively is crucial for building resilient applications. The scale targets are different between the Storage resource provider and the data plane, so it's important to configure retry options based on where the request is being sent.
19-
In this article, you learn how to configure retry options for an application that calls management plane APIs.
18+
When working with Azure Storage management plane APIs, handling transient faults and rate limits effectively is crucial for building resilient applications. The [scale targets](scalability-targets-resource-provider.md) are different between the Storage resource provider and the data plane, so it's important to configure retry options based on where the request is being sent. In this article, you learn how to configure retry options for an application that calls management plane APIs.
2019

21-
### Configure retry options
20+
## Configure retry options
2221

22+
Retry policies for management plane operations can be configured programmatically, offering control over how retry options are applied to various service requests and scenarios.
2323

24+
The following table lists the properties of the [RetryOptions](/dotnet/api/azure.core.retryoptions) class, along with the type, a brief description, and the default value if you make no changes. You should be proactive in tuning the values of these properties to meet the needs of your app.
2425

25-
## Use the default retry policy
26+
| Property | Type | Description | Default value |
27+
| --- | --- | --- | --- |
28+
| [Delay](/dotnet/api/azure.core.retryoptions.delay) | [TimeSpan](/dotnet/api/system.timespan) | The delay between retry attempts for a fixed approach or the delay on which to base calculations for a backoff-based approach. If the service provides a Retry-After response header, the next retry is delayed by the duration specified by the header value. | 0.8 second |
29+
| [MaxDelay](/dotnet/api/azure.core.retryoptions.maxdelay) | [TimeSpan](/dotnet/api/system.timespan) | The maximum permissible delay between retry attempts when the service doesn't provide a Retry-After response header. If the service provides a Retry-After response header, the next retry is delayed by the duration specified by the header value. | 1 minute |
30+
| [MaxRetries](/dotnet/api/azure.core.retryoptions.maxretries) | int | The maximum number of retry attempts before giving up. | 3 |
31+
| [Mode](/dotnet/api/azure.core.retryoptions.mode) | [RetryMode](/dotnet/api/azure.core.retrymode) | The approach to use for calculating retry delays. | Exponential |
32+
| [NetworkTimeout](/dotnet/api/azure.core.retryoptions.networktimeout) | [TimeSpan](/dotnet/api/system.timespan) | The timeout applied to an individual network operation. | 100 seconds |
2633

27-
The default retry policy in the Azure Storage management library for .NET is designed to handle transient faults automatically. This policy uses an exponential backoff strategy, which increases the delay between retries after each failed attempt. The default settings are typically sufficient for most scenarios, providing a balance between retry attempts and wait times.
34+
In this code example for Blob Storage, we configure the retry options in the `Retry` property of the [BlobClientOptions](/dotnet/api/azure.storage.blobs.blobclientoptions) class. Then, we create a client object for the blob service using the retry options.
2835

29-
In this example, the `ArmClient` uses the default retry policy defined in `ArmClientOptions`.
36+
### Use the default retry policy
3037

3138
```csharp
32-
// Blank configuration options for the ArmClient
33-
ArmClientOptions armClientOptions = new() { };
34-
3539
// Authenticate to Azure and create the top-level ArmClient
3640
ArmClient armClient = new(new DefaultAzureCredential(), subscriptionId, armClientOptions);
3741
```
3842

39-
## Set the Retry-After header
43+
### Set the Retry-After header
4044

41-
When you reach the rate limit for Azure Storage management plane APIs, you receive an HTTP status code 429 Too Many Requests. The response includes a Retry-After header, which specifies the number of seconds your application should wait before sending the next request. This approach ensures that your application respects the rate limits imposed by the service.
45+
When you reach the rate limit for Azure Storage management plane APIs, you receive an HTTP status code `429 Too Many Requests`. The response includes a `Retry-After` header, which specifies the number of seconds your application should wait before sending the next request. This approach ensures that your application respects the rate limits imposed by the service.
4246

43-
Example
4447
In this example, the application reads the Retry-After header and waits for the specified duration before retrying the request.
4548

4649
```csharp
@@ -53,7 +56,7 @@ if (response.StatusCode == HttpStatusCode.TooManyRequests)
5356
}
5457
```
5558

56-
## Configure a custom retry policy
59+
### Configure a custom retry policy
5760

5861
A custom retry policy allows you to define specific retry logic tailored to your application's needs. This approach provides greater control over the retry behavior, such as setting custom intervals, maximum retry attempts, and handling specific exceptions.
5962

@@ -74,6 +77,6 @@ ArmClientOptions armClientOptions = new()
7477
ArmClient armClient = new(new DefaultAzureCredential(), subscriptionId, armClientOptions);
7578
```
7679

77-
Choosing the right retry strategy depends on your application's requirements and the specific scenarios you need to handle. The default retry policy offers simplicity and is suitable for most cases. Using the Retry-After header ensures compliance with rate limits, while a custom retry policy provides the highest level of control and customization.
80+
Choosing the right retry strategy depends on your application's requirements and the specific scenarios you need to handle. The default retry policy offers simplicity and is suitable for most cases. Using the `Retry-After` header ensures compliance with rate limits, while a custom retry policy provides the highest level of control and customization.
7881

7982
By understanding these differences, you can implement an effective retry strategy that enhances the resilience and reliability of your .NET applications interacting with Azure Storage management plane APIs.

0 commit comments

Comments
 (0)