本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient.GetServiceStatsAsync方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobClient.GetServiceStatsAsync方法的具体用法?C# CloudBlobClient.GetServiceStatsAsync怎么用?C# CloudBlobClient.GetServiceStatsAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient
的用法示例。
在下文中一共展示了CloudBlobClient.GetServiceStatsAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetServiceStatsForSecondaryAsync
/// <summary>
/// Gets the Blob service stats for the secondary endpoint for an RA-GRS (read-access geo-redundant) storage account.
/// </summary>
/// <param name="blobClient">The Blob service client.</param>
/// <returns>A Task object.</returns>
private static async Task GetServiceStatsForSecondaryAsync(CloudBlobClient blobClient)
{
try
{
// Get the URI for the secondary endpoint for Blob storage.
Uri secondaryUri = blobClient.StorageUri.SecondaryUri;
// Create a new service client based on the secondary endpoint.
CloudBlobClient blobClientSecondary = new CloudBlobClient(secondaryUri, blobClient.Credentials);
// Get the current stats for the secondary.
// The call will fail if your storage account does not have RA-GRS enabled.
// Change the retry policy for this call so that if it fails, it fails quickly.
BlobRequestOptions requestOptions = new BlobRequestOptions() { RetryPolicy = new NoRetry() };
ServiceStats blobStats = await blobClientSecondary.GetServiceStatsAsync(requestOptions, null);
Console.WriteLine("Geo-replication status: {0}", blobStats.GeoReplication.Status);
Console.WriteLine("Last geo-replication sync time: {0}", blobStats.GeoReplication.LastSyncTime);
Console.WriteLine();
}
catch (StorageException e)
{
// In this case, we do not re-throw the exception, so that the sample will continue to run even if RA-GRS is not enabled
// for this storage account.
if (e.RequestInformation.HttpStatusCode == 403)
{
Console.WriteLine("This storage account does not appear to support RA-GRS.");
Console.WriteLine("More information: {0}", e.Message);
Console.WriteLine();
}
else
{
Console.WriteLine(e.Message);
Console.ReadLine();
throw;
}
}
}