Dave New
Dave New

Reputation: 40002

Retry policy on blob leasing

I am setting a retry policy on the CloudBlobClient, like this:

// Instantiating the client with an exponential retry policy
var client = cloudStorageAccount.CreateCloudBlobClient();
client.DefaultRequestOptions = new BlobRequestOptions()
{
    RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(1), 3)
};

// Getting a reference to the desired blob
var blobContainer = client.GetContainerReference("leases");
var blob = blobContainer.GetBlockBlobReference("someblob");

When acquiring a lease on a blob, will this retry policy be implicitly performed on this lease transaction?

blob.AcquireLease(TimeSpan.FromSeconds(60), leaseId);

Or do I need to explicitly specify the retry policy:

blob.AcquireLease(TimeSpan.FromSeconds(60), leaseId, null, new BlobRequestOptions() { RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(1), 3) });

Upvotes: 1

Views: 1407

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136136

When acquiring a lease on a blob, will this retry policy be implicitly performed on this lease transaction?

Yes. If you take a look at the source code for AcquireLease, you will notice that the method calls ApplyDefaults method of BlobRequestOptions class which picks the options from service client if no options are specified.

Upvotes: 3

Related Questions