当前位置: 首页>>代码示例>>C#>>正文


C# CloudBlobClient.GetServiceStatsAsync方法代码示例

本文整理汇总了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;
                }
            }
        }
开发者ID:tamram,项目名称:storage-blob-dotnet-getting-started,代码行数:43,代码来源:Advanced.cs


注:本文中的Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient.GetServiceStatsAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。