CreateStorageAccountFromConnectionString() public static method

Validate the connection string information in app.config and throws an exception if it looks like the user hasn't updated this to valid values.
public static CreateStorageAccountFromConnectionString ( string storageConnectionString ) : Microsoft.WindowsAzure.Storage.CloudStorageAccount
storageConnectionString string The storage connection string
return Microsoft.WindowsAzure.Storage.CloudStorageAccount
        /// <summary>
        /// Create a queue for the sample application to process messages in.
        /// </summary>
        /// <returns>A CloudQueue object</returns>
        public async Task <CloudQueue> CreateQueueAsync(string queueName)
        {
            // Retrieve storage account information from connection string.
            CloudStorageAccount storageAccount = Common.CreateStorageAccountFromConnectionString(Common.ConnStr);

            // Create a queue client for interacting with the queue service
            CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();

            Console.WriteLine("1. Create a queue for the demo");

            CloudQueue queue = queueClient.GetQueueReference(queueName);

            try
            {
                await queue.CreateIfNotExistsAsync();
            }
            catch
            {
                Console.WriteLine("If you are running with the default configuration please make sure you have started the storage emulator.  ess the Windows key and type Azure Storage to select and run it from the list of applications - then restart the sample.");
                Console.ReadLine();
                throw;
            }

            return(queue);
        }
        public async Task <CloudQueue> CreateQueueAsync(string queueName)
        {
            CloudStorageAccount storageAccount = Common.CreateStorageAccountFromConnectionString(CloudConfigurationManager.GetSetting("StorageConnectionString"));
            CloudQueueClient    queueClient    = storageAccount.CreateCloudQueueClient();

            Console.WriteLine("FOR KEDA--- Azure Storage Queue message sender.....");

            CloudQueue queue = queueClient.GetQueueReference(queueName);

            try
            {
                await queue.CreateIfNotExistsAsync();
            }
            catch
            {
                Console.WriteLine("If you are running with the default configuration please make sure you have started the storage emulator.  ess the Windows key and type Azure Storage to select and run it from the list of applications - then restart the sample.");
                Console.ReadLine();
                throw;
            }
            return(queue);
        }
        /// <summary>
        /// Test some of the queue storage operations.
        /// </summary>
        public async Task RunQueueStorageAdvancedOpsAsync()
        {
            try
            {
                //***** Setup *****//
                Console.WriteLine("Getting reference to the storage account.");

                // Retrieve storage account information from connection string
                // How to create a storage connection string - http://msdn.microsoft.com/en-us/library/azure/ee758697.aspx
                CloudStorageAccount storageAccount = Common.CreateStorageAccountFromConnectionString(CloudConfigurationManager.GetSetting("StorageConnectionString"));

                Console.WriteLine("Instantiating queue client.");
                Console.WriteLine(string.Empty);

                // Create a queue client for interacting with the queue service.
                CloudQueueClient cloudQueueClient = storageAccount.CreateCloudQueueClient();

                // List queues
                await ListQueuesSample(cloudQueueClient);

                // Service properties
                await ServicePropertiesSample(cloudQueueClient);

                // CORS Rules
                await CorsSample(cloudQueueClient);

                // Service Stats
                await ServiceStatsSample(cloudQueueClient);

                // Queue Metadata
                await QueueMetadataSample(cloudQueueClient);

                // Queue Acl
                await QueueAclSample(cloudQueueClient);
            }
            catch (Exception ex)
            {
                Console.WriteLine("    Exception thrown. Message = {0}{1}    Strack Trace = {2}", ex.Message, Environment.NewLine, ex.StackTrace);
            }
        }
        /// <summary>
        /// Test some of the queue storage operations.
        /// </summary>
        public async Task RunQueueStorageAdvancedOpsAsync()
        {
            try
            {
                //***** Setup *****//
                Console.WriteLine("Getting reference to the storage account.");

                // Retrieve storage account information from connection string
                // How to create a storage connection string - http://msdn.microsoft.com/en-us/library/azure/ee758697.aspx
                CloudStorageAccount storageAccount = Common.CreateStorageAccountFromConnectionString(CloudConfigurationManager.GetSetting("StorageConnectionString"));

                Console.WriteLine("Instantiating queue client.");
                Console.WriteLine(string.Empty);

                // Create a queue client for interacting with the queue service.
                CloudQueueClient cloudQueueClient = storageAccount.CreateCloudQueueClient();

                // Create 3 queues.

                // Create the queue name -- use a guid in the name so it's unique.
                string baseQueueName = "demotest-" + System.Guid.NewGuid().ToString();

                // Keep a list of the queues so you can compare this list
                //   against the list of queues that we retrieve.
                List <string> queueNames = new List <string>();

                for (int i = 0; i < 3; i++)
                {
                    // Set the name of the queue, then add it to the generic list.
                    string queueName = baseQueueName + "-0" + i;
                    queueNames.Add(queueName);

                    // Create the queue with this name.
                    Console.WriteLine("Creating queue with name {0}", queueName);
                    CloudQueue cloudQueue = cloudQueueClient.GetQueueReference(queueName);
                    try
                    {
                        await cloudQueue.CreateIfNotExistsAsync();

                        Console.WriteLine("    Queue created successfully.");
                    }
                    catch (StorageException exStorage)
                    {
                        Common.WriteException(exStorage);
                        Console.WriteLine("Please make sure your storage account is specified correctly in the app.config - then restart the sample.");
                        Console.WriteLine("Press any key to exit");
                        Console.ReadLine();
                        throw;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("    Exception thrown creating queue.");
                        Common.WriteException(ex);
                        throw;
                    }
                }

                Console.WriteLine(string.Empty);
                Console.WriteLine("List of queues in the storage account:");

                // List the queues for this storage account
                IEnumerable <CloudQueue> cloudQueueList = cloudQueueClient.ListQueues();
                try
                {
                    foreach (CloudQueue cloudQ in cloudQueueList)
                    {
                        Console.WriteLine("Cloud Queue name = {0}", cloudQ.Name);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("    Exception thrown listing queues.");
                    Common.WriteException(ex);
                    throw;
                }

                // Now clean up after yourself, using the list of queues that you created in case there were other queues in the account.
                foreach (string oneQueueName in queueNames)
                {
                    CloudQueue cloudQueue = cloudQueueClient.GetQueueReference(oneQueueName);
                    cloudQueue.DeleteIfExists();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("    Exception thrown. Message = {0}{1}    Strack Trace = {2}", ex.Message, Environment.NewLine, ex.StackTrace);
            }
        }