using Microsoft.WindowsAzure.Storage; | |
using Microsoft.WindowsAzure.Storage.RetryPolicies; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace AzureStorageRetry | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var storageAccount = CloudStorageAccount.Parse("MyConnectionString"); | |
var blobClient1 = storageAccount.CreateCloudBlobClient(); | |
// Use ExponentialRetry strategy. Initial time is 10 seconds with a maximum of 5 retry attempts. | |
blobClient1.DefaultRequestOptions.RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(10), 5); | |
var blobClient2 = storageAccount.CreateCloudBlobClient(); | |
// Use LinearRetry strategy. Retry failed operations every 5 seconds a maximum of 10 times. | |
blobClient2.DefaultRequestOptions.RetryPolicy = new LinearRetry(TimeSpan.FromSeconds(5), 10); | |
var blobClient3 = storageAccount.CreateCloudBlobClient(); | |
// Use NoRetry strategy. Fail immediately on all errors. | |
blobClient3.DefaultRequestOptions.RetryPolicy = new NoRetry(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment