Beispiel #1
0
        /// <summary>
        /// Used to create a storage account
        /// </summary>
        private bool CreateStorageAccount()
        {
            // Check to see whether the storage account details have been populated correctly
            if (Manager.StorageAccountDescription == null || Manager.StorageAccountLocation == null)
            {
                Manager.WriteComplete(EventPoint.ExceptionOccurrence, "Description or location not specified");
                return(false);
            }

            try
            {
                // issue the create storage account command
                _client.CreateNewStorageAccount(Manager.StorageAccountName, Manager.StorageAccountLocation);

                while (StorageStatus.Created != _client.GetStorageStatus(Manager.StorageAccountName))
                {
                    Thread.Sleep(5000);
                }

                Manager.WriteComplete(EventPoint.StorageAccountCreated, "Storage account " + Manager.StorageAccountName + " created");
                // get the storage account keys
                var keys = _client.GetStorageAccountKeys(Manager.StorageAccountName);

                Manager.WriteComplete(EventPoint.StorageKeyRequestSuccess, "Keys returned from storage request");
                // populate the primary and secondary keys
                Manager.StorageAccountPrimaryKey   = keys[0];
                Manager.StorageAccountSecondaryKey = keys[1];
            }
            catch (Exception exception)
            {
                // rollback the operation if it failed
                Manager.WriteComplete(EventPoint.ExceptionOccurrence, exception.GetType() + ": " + exception.Message);
                return(false);
            }
            return(true);
        }