本文整理匯總了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;
}
}
}