Esempio n. 1
0
        public void SetLoggingVersion()
        {
            //Blob service
            CloudBlobClient blobClient = StorageAccount.CreateCloudBlobClient();

            GenericSetLoggingVersion(ServiceType.Blob, () => blobClient.GetServiceProperties());

            //Queue service
            CloudQueueClient queueClient = StorageAccount.CreateCloudQueueClient();

            GenericSetLoggingVersion(ServiceType.Queue, () => queueClient.GetServiceProperties());

            //Table service
            CloudTableClient tableClient = StorageAccount.CreateCloudTableClient();

            GenericSetLoggingVersion(ServiceType.Table, () => tableClient.GetServiceProperties());
        }
Esempio n. 2
0
        public void SetMetricsVersion()
        {
            //Blob service
            CloudBlobClient blobClient = StorageAccount.CreateCloudBlobClient();

            GenericSetMetricsVersion(ServiceType.Blob, () => blobClient.GetServiceProperties());

            //Queue service
            CloudQueueClient queueClient = StorageAccount.CreateCloudQueueClient();

            GenericSetMetricsVersion(ServiceType.Queue, () => queueClient.GetServiceProperties());

            //Table service
            CloudTableClient tableClient = StorageAccount.CreateCloudTableClient();

            GenericSetMetricsVersion(ServiceType.Table, () => tableClient.GetServiceProperties());

            //File service
            GenericSetMetricsVersion(ServiceType.File, () => Utility.GetServiceProperties(StorageAccount, ServiceType.File));
        }
        //https://msazure.visualstudio.com/One/_git/AzureStack-Services-Storage?path=%2Fsrc%2Fsdx%2Fbase%2Fwoss%2Ftest%2Ftests%2FWFE%2FHorizontalBVT%2FAccountKeyTests.cs&version=GBmaster&_a=contents
        /// <summary>
        /// Make a couple of requests to the blob, queue, and table services, expecting success.
        /// </summary>
        /// <param name="account">The account through which the services will be accessed.</param>
        internal void MakeServiceRequestsExpectSuccess(CloudStorageAccount account)
        {
            // Make blob service requests
            CloudBlobClient blobClient = account.CreateCloudBlobClient();

            //   blobClient.ListContainersSegmentedAsync();
            blobClient.ListContainers().Count();
            blobClient.GetServiceProperties();

            // Make queue service requests
            CloudQueueClient queueClient = account.CreateCloudQueueClient();

            queueClient.ListQueues().Count();
            queueClient.GetServiceProperties();

            // Make table service requests
            CloudTableClient tableClient = account.CreateCloudTableClient();

            tableClient.ListTables().Count();
            tableClient.GetServiceProperties();
        }
Esempio n. 4
0
        // 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);
        }