Esempio n. 1
0
        public void Troubleshooting_File_storage_using_metrics()
        {
            // Parse your storage connection string from your application's configuration file.
            StorageCredentials  Credentials    = new StorageCredentials(this.Account, this.Key);
            CloudStorageAccount storageAccount = new CloudStorageAccount(Credentials, false);

            // Create the File service client.
            CloudFileClient fileClient = storageAccount.CreateCloudFileClient();

            // Set metrics properties for File service.
            // Note that the File service currently uses its own service properties type,
            // available in the Microsoft.WindowsAzure.Storage.File.Protocol namespace.
            fileClient.SetServiceProperties(new FileServiceProperties()
            {
                // Set hour metrics
                HourMetrics = new MetricsProperties()
                {
                    MetricsLevel  = MetricsLevel.ServiceAndApi,
                    RetentionDays = 14,
                    Version       = "1.0"
                },
                // Set minute metrics
                MinuteMetrics = new MetricsProperties()
                {
                    MetricsLevel  = MetricsLevel.ServiceAndApi,
                    RetentionDays = 7,
                    Version       = "1.0"
                }
            });

            // Read the metrics properties we just set.
            FileServiceProperties serviceProperties = fileClient.GetServiceProperties();

            Console.WriteLine("Hour metrics:");
            Console.WriteLine(serviceProperties.HourMetrics.MetricsLevel);
            Console.WriteLine(serviceProperties.HourMetrics.RetentionDays);
            Console.WriteLine(serviceProperties.HourMetrics.Version);
            Console.WriteLine();
            Console.WriteLine("Minute metrics:");
            Console.WriteLine(serviceProperties.MinuteMetrics.MetricsLevel);
            Console.WriteLine(serviceProperties.MinuteMetrics.RetentionDays);
            Console.WriteLine(serviceProperties.MinuteMetrics.Version);
        }