In the Microsoft.WindowsAzure.Storage (the legacy Azure SDK for .NET), we could set the retry policy for a BlobClient to be an IRetryPolicy like so:
var blobClient = this.storageAccount.CreateCloudBlobClient();
blobClient.DefaultRequestOptions.RetryPolicy = TransientFactory.GetStorageRetryPolicy().AsAzureStorageClientRetryPolicy();
However, in the new version of the SDK, with BlobClients being directly created without having to go through a CloudStorageAccount, how can we do this?
The furthest I have been able to get using the docs is to manually set max retries:
var blobClientOptions = new BlobClientOptions();
blobClientOptions.Retry.MaxRetries = 4;
var blobServiceClient = new BlobServiceClient("connection_string", options: blobClientOptions);
Instead of manually setting retry parameters, is it possible set the RetryPolicy on a BlobClient or BlobServiceClient?
The usage you post is exactly the way we use. We could set the retry policy in two positions.
One is how you post: set the retry policy when creating blob client.
One set the retry policy when creating BlobServiceClient
:
var blobServiceClient = new BlobServiceClient
(connectionString:storageAccountConnectionString, options: blobClientOptions);
Follow here.