重试 blob 租赁政策

Retry policy on blob leasing

我正在 CloudBlobClient 上设置重试策略,如下所示:

// 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");

在 blob 上获取租约时,是否会对该租约事务隐式执行此重试策略?

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

或者我是否需要明确指定重试策略:

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

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

是的。如果您查看 AcquireLease, you will notice that the method calls ApplyDefaults method of BlobRequestOptions class 的源代码,如果未指定任何选项,它会从服务客户端选择选项。