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); }
// The Azure Functions runtime uses this storage account connection string for all functions // except for HTTP triggered functions. // The storage account must be a general-purpose one that supports blobs, queues, and tables. // See Storage account and Storage account requirements. // AzureWebJobsDashboard // Optional storage account connection string for storing logs and displaying them in the Monitor tab in the portal. // The storage account must be a general-purpose one that supports blobs, queues, and tables. // See Storage account and Storage account requirements. //Functions uses Storage for operations such as managing triggers and logging function executions. internal StorageAccountsValidation MakeServiceRequestsExpectSuccess(string connectionKey, string connectionString) { string storageSymptoms = String.Empty; int status = 0; string postfixStatement = "Please make sure this is a general-purpose storage account."; //if (connectionKey.Equals("AzureWebJobsStorage", StringComparison.OrdinalIgnoreCase)) //{ //} try { if (string.IsNullOrWhiteSpace(connectionString)) { // return Task.FromResult<StorageAccountsValidation> (new StorageAccountsValidation { }); return(new StorageAccountsValidation { }); } CloudStorageAccount account = CloudStorageAccount.Parse(connectionString); // Make blob service requests try { CloudBlobClient blobClient = account.CreateCloudBlobClient(); // blobClient.ListContainersSegmentedAsync(); // blobClient.ListContainers().Count(); blobClient.GetServiceProperties(); } catch (Exception ex) { storageSymptoms += "Blob endpoint is not reachable. Make sure the firewall on this storage account is not misconfigured."; throw ex; } try { // Make queue service requests CloudQueueClient queueClient = account.CreateCloudQueueClient(); queueClient.ListQueues().Count(); queueClient.GetServiceProperties(); } catch (Exception ex) { storageSymptoms += "Queue is not enabled. "; throw ex; } try { // Make table service requests CloudTableClient tableClient = account.CreateCloudTableClient(); tableClient.ListTables().Count(); tableClient.GetServiceProperties(); } catch (Exception ex) { storageSymptoms += "Table is not enabled."; throw ex; } try { // Not sure if this is only required for consumption // When using a Consumption plan function definitions are stored in File Storage. CloudFileClient fileClient = account.CreateCloudFileClient(); fileClient.ListShares().Count(); fileClient.GetServiceProperties(); } catch (Exception ex) { storageSymptoms += "File is not enabled."; throw ex; } storageSymptoms = "Storage connection string validation passed!"; } catch (Exception ex) { storageSymptoms += "\n"; storageSymptoms += postfixStatement; status = 1; } StorageAccountsValidation result = new StorageAccountsValidation { AppSettingsKey = connectionKey, Mandatory = false, AccountName = connectionString.Split(new string[] { "AccountName=", ";AccountKey=" }, StringSplitOptions.RemoveEmptyEntries)[1], Message = storageSymptoms, Status = status }; //return Task.FromResult(result); return(result); }