Reputation: 8357
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:
Thanks in advance.
Upvotes: 0
Views: 1221
Reputation: 523
I had a similar issue. Microsoft.WindowsAzure.StorageClient is deprecated, you now need to use Microsoft.WindowsAzure.Storage or more specifically the Microsoft.WindowsAzure.Storage.RetryPolicies.
For that retry, this should work
new BlobRequestOptions() { RetryPolicy = new LinearRetry(TimeSpan.FromSeconds(10), 3) }
Upvotes: 2