Skip to content

Commit db1207a

Browse files
author
Pedro Wood
committed
review changes
1 parent a043515 commit db1207a

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

BlobStorage/Advanced.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static async Task CallBlobAdvancedSamples()
8080
await CorsSample(blobClient);
8181

8282
// Page Blob Ranges
83-
await PageRangesSample(blobClient, container);
83+
await PageRangesSample(container);
8484
}
8585
catch (StorageException e)
8686
{
@@ -324,9 +324,7 @@ private static async Task GetServiceStatsForSecondary(CloudBlobClient blobClient
324324

325325
// Get the current stats for the secondary.
326326
// The call will fail if your storage account does not have RA-GRS enabled.
327-
// Change the retry policy for this call so that if it fails, it fails quickly.
328-
BlobRequestOptions requestOptions = new BlobRequestOptions() { RetryPolicy = new NoRetry() };
329-
ServiceStats blobStats = await blobClientSecondary.GetServiceStatsAsync(requestOptions, null);
327+
ServiceStats blobStats = await blobClientSecondary.GetServiceStatsAsync();
330328

331329
Console.WriteLine("Geo-replication status: {0}", blobStats.GeoReplication.Status);
332330
Console.WriteLine("Last geo-replication sync time: {0}", blobStats.GeoReplication.LastSyncTime);
@@ -1840,10 +1838,14 @@ private static async Task TestBlobSAS(string sasUri, string blobContent)
18401838
/// <param name="blobClient"></param>
18411839
private static async Task CorsSample(CloudBlobClient blobClient)
18421840
{
1843-
// Set CORS rules
1844-
Console.WriteLine("Set CORS rules");
1841+
// Get CORS rules
1842+
Console.WriteLine("Get CORS rules");
1843+
1844+
ServiceProperties serviceProperties = await blobClient.GetServicePropertiesAsync();
1845+
1846+
// Add CORS rule
1847+
Console.WriteLine("Add CORS rule");
18451848

1846-
CorsProperties cors = new CorsProperties();
18471849
CorsRule corsRule = new CorsRule
18481850
{
18491851
AllowedHeaders = new List<string> { "*" },
@@ -1853,20 +1855,19 @@ private static async Task CorsSample(CloudBlobClient blobClient)
18531855
MaxAgeInSeconds = 3600
18541856
};
18551857

1856-
cors.CorsRules.Add(corsRule);
1857-
await blobClient.SetServicePropertiesAsync(new ServiceProperties(null, null, null, cors));
1858+
serviceProperties.Cors.CorsRules.Add(corsRule);
1859+
await blobClient.SetServicePropertiesAsync(serviceProperties);
18581860
Console.WriteLine();
18591861
}
18601862

18611863
/// <summary>
18621864
/// Get a list of valid page ranges for a page blob
18631865
/// </summary>
1864-
/// <param name="blobClient"></param>
18651866
/// <param name="container"></param>
18661867
/// <returns>A Task object.</returns>
1867-
private static async Task PageRangesSample(CloudBlobClient blobClient, CloudBlobContainer container)
1868+
private static async Task PageRangesSample(CloudBlobContainer container)
18681869
{
1869-
BlobRequestOptions requestOptions = new BlobRequestOptions() { RetryPolicy = new NoRetry() };
1870+
BlobRequestOptions requestOptions = new BlobRequestOptions { RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(1), 3) };
18701871
await container.CreateIfNotExistsAsync(requestOptions, null);
18711872

18721873
Console.WriteLine("Create Page Blob");

0 commit comments

Comments
 (0)