0

I am coding an MVC5 application, and am uploading BlockBlobs to Azure.

I have some Microsoft code that is now obsolete, and I wish to convert this obsolete code to code that will work in my application.

Here is the old code:

BlockBlob.PutBlock(blockId, chunkStream, null, null, new BlobRequestOptions() { RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(10)) });

I have code that does work, however this code does not use a RetryPolicy.

Here is the code with no RetryPolicy:

BlockBlob.PutBlock(blockId, chunkStream, null, null, null, null);

Can I please have some help to construct the BlobRequestOptions object correctly that uses a RetryPolicy?

Here is what I have so far:

BlobRequestOptions blobRequestOptions = new BlobRequestOptions();
blobRequestOptions.RetryPolicy.CreateInstance();
TimeSpan timeSpan = new TimeSpan();
TimeSpan.FromSeconds(10);
blobRequestOptions.RetryPolicy.ShouldRetry(3, 0, new Exception(), out timeSpan, new OperationContext());

I am not sure of the following:

  1. What status code to use.
  2. What to use for the LastException.
  3. The out value for the timespan.
  4. What to use for OperationContext.

Thanks in advance.

4

1 回答 1

2

我有一个类似的问题。Microsoft.WindowsAzure.StorageClient 已弃用,您现在需要使用 Microsoft.WindowsAzure.Storage 或更具体地说是 Microsoft.WindowsAzure.Storage.RetryPolicies。

对于重试,这应该有效

new BlobRequestOptions() { RetryPolicy = new LinearRetry(TimeSpan.FromSeconds(10), 3) }
于 2014-12-10T16:42:44.293 回答