예제 #1
0
        /// <summary>
        /// ProcessRecord of the command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            if (ShouldProcess(Resources.VaultTarget, "new"))
            {
                try
                {
                    Vault vaultCreateArgs = new Vault();

                    if (Tag != null)
                    {
                        IDictionary <string, string> vaultTags = new Dictionary <string, string>();
                        foreach (string key in Tag.Keys)
                        {
                            vaultTags.Add(key, Tag[key].ToString());
                        }

                        vaultCreateArgs.Tags = vaultTags;
                    }
                    vaultCreateArgs.Location   = this.Location;
                    vaultCreateArgs.Properties = new VaultProperties();
                    vaultCreateArgs.Sku        = new Sku();
                    vaultCreateArgs.Sku.Name   = SkuName.Standard;

                    Vault response = RecoveryServicesClient.CreateVault(this.ResourceGroupName, this.Name, vaultCreateArgs);

                    this.WriteObject(new ARSVault(response));
                }
                catch (Exception exception)
                {
                    this.HandleException(exception);
                }
            }
        }
        /// <summary>
        /// ProcessRecord of the command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            try
            {
                this.WriteWarningWithTimestamp(
                    string.Format(
                        Properties.Resources.CmdletWillBeDeprecatedSoon,
                        this.MyInvocation.MyCommand.Name));

                string cloudServiceName = Utilities.GenerateCloudServiceName(this.Location);
                byte[] bytes            = System.Text.Encoding.UTF8.GetBytes(cloudServiceName);
                string base64Label      = Convert.ToBase64String(bytes);

                CloudServiceCreateArgs cloudServiceCreateArgs = new CloudServiceCreateArgs()
                {
                    GeoRegion   = this.Location,
                    Label       = base64Label,
                    Description = base64Label
                };

                RecoveryServicesClient.FindOrCreateCloudService(cloudServiceName, cloudServiceCreateArgs);

                VaultCreateArgs vaultCreateArgs = new VaultCreateArgs()
                {
                    Name = this.Name,
                    Plan = string.Empty,
                    ResourceProviderNamespace = Constants.ResourceNamespace,
                    Type          = Constants.ASRVaultType,
                    ETag          = Guid.NewGuid().ToString(),
                    SchemaVersion = Constants.RpSchemaVersion
                };

                RecoveryServicesOperationStatusResponse response = RecoveryServicesClient.CreateVault(cloudServiceName, this.Name, vaultCreateArgs);

                VaultOperationOutput output = new VaultOperationOutput()
                {
                    Response = response.StatusCode == HttpStatusCode.OK ? Resources.VaultCreationSuccessMessage : response.StatusCode.ToString()
                };

                this.WriteObject(output, true);
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
예제 #3
0
        /// <summary>
        /// ProcessRecord of the command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            try
            {
                VaultCreateArgs vaultCreateArgs = new VaultCreateArgs();
                vaultCreateArgs.Location            = this.Location;
                vaultCreateArgs.Properties          = new VaultProperties();
                vaultCreateArgs.Properties.Sku      = new VaultSku();
                vaultCreateArgs.Properties.Sku.Name = "standard";

                VaultCreateResponse response = RecoveryServicesClient.CreateVault(this.ResouceGroupName, this.Name, vaultCreateArgs);

                this.WriteObject(new ASRVault(response));
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
예제 #4
0
        /// <summary>
        /// ProcessRecord of the command.
        /// </summary>
        public override void ExecuteSiteRecoveryCmdlet()
        {
            base.ExecuteSiteRecoveryCmdlet();

            this.WriteWarningWithTimestamp(
                string.Format(
                    Properties.Resources.SiteRecoveryVaultTypeWillBeDeprecatedSoon));

            VaultCreateArgs vaultCreateArgs = new VaultCreateArgs();

            vaultCreateArgs.Location            = this.Location;
            vaultCreateArgs.Properties          = new VaultProperties();
            vaultCreateArgs.Properties.Sku      = new VaultSku();
            vaultCreateArgs.Properties.Sku.Name = "standard";

            VaultCreateResponse response = RecoveryServicesClient.CreateVault(this.ResourceGroupName, this.Name, vaultCreateArgs);

            this.WriteObject(new ASRVault(response));
        }
        /// <summary>
        /// ProcessRecord of the command.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            if (ShouldProcess(Resources.VaultTarget, "new"))
            {
                try
                {
                    Vault vaultCreateArgs = new Vault();
                    vaultCreateArgs.Location   = this.Location;
                    vaultCreateArgs.Properties = new VaultProperties();
                    vaultCreateArgs.Sku        = new Sku();
                    vaultCreateArgs.Sku.Name   = SkuName.Standard;

                    Vault response = RecoveryServicesClient.CreateVault(this.ResourceGroupName, this.Name, vaultCreateArgs);

                    this.WriteObject(new ARSVault(response));
                }
                catch (Exception exception)
                {
                    this.HandleException(exception);
                }
            }
        }
        /// <summary>
        /// ProcessRecord of the command.
        /// </summary>
        protected override void ProcessRecord()
        {
            try
            {
                this.WriteWarningWithTimestamp(
                    string.Format(
                        Properties.Resources.SiteRecoveryVaultTypeWillBeDeprecatedSoon));

                VaultCreateArgs vaultCreateArgs = new VaultCreateArgs();
                vaultCreateArgs.Location            = this.Location;
                vaultCreateArgs.Properties          = new VaultProperties();
                vaultCreateArgs.Properties.Sku      = new VaultSku();
                vaultCreateArgs.Properties.Sku.Name = "standard";

                VaultCreateResponse response = RecoveryServicesClient.CreateVault(this.ResouceGroupName, this.Name, vaultCreateArgs);

                this.WriteObject(new ASRVault(response));
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }