Used to create a hosted service within a given subscription
Inheritance: Elastacloud.AzureManagement.Fluent.Commands.Services.ServiceCommand
コード例 #1
0
 public void CreateNewStorageAccount(string name, string location = "North Europe")
 {
     // issue the create storage account command
     var create = new CreateStorageAccountCommand(name, "Created with Fluent Management", location)
     {
         SubscriptionId = SubscriptionId,
         Certificate = ManagementCertificate
     };
     create.Execute();
 }
コード例 #2
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
                var create = new CreateStorageAccountCommand(Manager.StorageAccountName,
                                                             Manager.StorageAccountDescription,
                                                             Manager.StorageAccountLocation)
                                 {
                                     SubscriptionId = Manager.SubscriptionId,
                                     Certificate = Manager.ManagementCertificate
                                 };
                create.Execute();
                Manager.WriteComplete(EventPoint.StorageAccountCreated,
                                      "Storage account " + Manager.StorageAccountName + " created");
                // get the storage account keys
                var keys = new GetStorageAccountKeysCommand(Manager.StorageAccountName)
                               {
                                   SubscriptionId = Manager.SubscriptionId,
                                   Certificate = Manager.ManagementCertificate
                               };
                keys.Execute();
                Manager.WriteComplete(EventPoint.StorageKeyRequestSuccess, "Keys returned from storage request");
                // populate the primary and secondary keys
                Manager.StorageAccountPrimaryKey = keys.PrimaryStorageKey;
                Manager.StorageAccountSecondaryKey = keys.SecondaryStorageKey;
            }
            catch (Exception exception)
            {
                // rollback the operation if it failed
                Manager.WriteComplete(EventPoint.ExceptionOccurrence, exception.GetType() + ": " + exception.Message);
                return false;
            }
            return true;
        }
コード例 #3
0
        /// <summary>
        /// Creates a new storage account given a name and location
        /// </summary>
        public void CreateNewStorageAccount(string name, string location = LocationConstants.NorthEurope
            , StorageManagementOptions options = null)
        {
            if (options == null)
                options = StorageManagementOptions.GetDefaultOptions;

            // issue the create storage account command
            var create = new CreateStorageAccountCommand(name, "Created with Fluent Management", options, location)
                {
                    SubscriptionId = SubscriptionId,
                    Certificate = ManagementCertificate
                };
            create.Execute();
            var status = StorageStatus.Creating;
            while (status != StorageStatus.Created)
            {
                var command = new GetStorageAccountStatusCommand(name)
                {
                    SubscriptionId = SubscriptionId,
                    Certificate = ManagementCertificate
                };
                command.Execute();
                status = command.Status;
            }
        }