BlobStorage.Advanced.ConfigureBlobAnalyticsAsync C# (CSharp) Method

ConfigureBlobAnalyticsAsync() private static method

Configures logging and metrics for Blob storage, as well as the default service version. Note that if you have already enabled analytics for your storage account, running this sample will change those settings. For that reason, it's best to run with a test storage account if possible. The sample saves your settings and resets them after it has completed running.
private static ConfigureBlobAnalyticsAsync ( Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient blobClient ) : System.Threading.Tasks.Task
blobClient Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient The Blob service client.
return System.Threading.Tasks.Task
        private static async Task ConfigureBlobAnalyticsAsync(CloudBlobClient blobClient)
        {
            try
            {
                // Get current service property settings.
                ServiceProperties serviceProperties = await blobClient.GetServicePropertiesAsync();

                // Enable analytics logging and set retention policy to 14 days. 
                serviceProperties.Logging.LoggingOperations = LoggingOperations.All;
                serviceProperties.Logging.RetentionDays = 14;
                serviceProperties.Logging.Version = "1.0";

                // Configure service properties for hourly and minute metrics. 
                // Set retention policy to 7 days.
                serviceProperties.HourMetrics.MetricsLevel = MetricsLevel.ServiceAndApi;
                serviceProperties.HourMetrics.RetentionDays = 7;
                serviceProperties.HourMetrics.Version = "1.0";

                serviceProperties.MinuteMetrics.MetricsLevel = MetricsLevel.ServiceAndApi;
                serviceProperties.MinuteMetrics.RetentionDays = 7;
                serviceProperties.MinuteMetrics.Version = "1.0";

                // Set the default service version to be used for anonymous requests.
                serviceProperties.DefaultServiceVersion = "2015-04-05";

                // Set the service properties.
                await blobClient.SetServicePropertiesAsync(serviceProperties);            
            }
            catch (StorageException e)
            {
                Console.WriteLine(e.Message);
                Console.ReadLine();
                throw;
            }
        }