/// <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); } }
/// <summary> /// ProcessRecord of the command. /// </summary> public override void ExecuteCmdlet() { try { RecoveryServicesOperationStatusResponse response = RecoveryServicesClient.DeleteVault(this.Vault.ResouceGroupName, this.Vault.Name); VaultOperationOutput output = new VaultOperationOutput() { Response = response.StatusCode == HttpStatusCode.OK ? Resources.VaultDeletionSuccessMessage : response.StatusCode.ToString() }; this.WriteObject(output, true); } catch (Exception exception) { this.HandleException(exception); } }
/// <summary> /// ProcessRecord of the command. /// </summary> protected override void ProcessRecord() { try { RecoveryServicesOperationStatusResponse response = RecoveryServicesClient.DeleteVault(this.Vault.ResouceGroupName, this.Vault.Name); VaultOperationOutput output = new VaultOperationOutput() { Response = response.StatusCode == HttpStatusCode.OK ? Resources.VaultDeletionSuccessMessage : response.StatusCode.ToString() }; this.WriteObject(output, true); } catch (Exception exception) { this.HandleException(exception); } }