/// <summary> /// Remove disks from replication protected item. /// </summary> /// <param name="fabricName">Fabric Name</param> /// <param name="protectionContainerName">Protection Container Name</param> /// <param name="replicationProtectedItemName">Replication Protected Item Name</param> /// <param name="input">Remove disks input.</param> /// <returns>Job response</returns> public PSSiteRecoveryLongRunningOperation RemoveDisks( string fabricName, string protectionContainerName, string replicationProtectedItemName, RemoveDisksInput input) { var op = this.GetSiteRecoveryClient() .ReplicationProtectedItems.BeginRemoveDisksWithHttpMessagesAsync( fabricName, protectionContainerName, replicationProtectedItemName, input, this.GetRequestHeaders(true)) .GetAwaiter() .GetResult(); var result = SiteRecoveryAutoMapperProfile.Mapper.Map <PSSiteRecoveryLongRunningOperation>(op); return(result); }
/// <summary> /// Helper method to fill in input details. /// </summary> private void FillRemoveDiskInputForAzureToAzureReplication(RemoveDisksInput input) { var providerSettings = new A2ARemoveDisksInput() { VmDisksUris = new List <string>(), VmManagedDisksIds = new List <string>() }; switch (this.ParameterSetName) { case ASRParameterSets.AzureToAzure: providerSettings.VmDisksUris = this.VhdUri; break; case ASRParameterSets.AzureToAzureManagedDisk: providerSettings.VmManagedDisksIds = this.DiskId; break; } input.Properties.ProviderSpecificDetails = providerSettings; }
/// <summary> /// ProcessRecord of the command. /// </summary> public override void ExecuteSiteRecoveryCmdlet() { base.ExecuteSiteRecoveryCmdlet(); // check for A2A protected item - if providerSpecificDetails is A2AReplicationDetails. var removeDisksProviderSpecificInput = new RemoveDisksProviderSpecificInput(); var inputProperties = new RemoveDisksInputProperties { ProviderSpecificDetails = removeDisksProviderSpecificInput }; var input = new RemoveDisksInput { Properties = inputProperties }; FillRemoveDiskInputForAzureToAzureReplication(input); if (this.ShouldProcess( this.InputObject.FriendlyName, "Removes the protected disk")) { PSSiteRecoveryLongRunningOperation response = this.RecoveryServicesClient.RemoveDisks( Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationFabrics), Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationProtectionContainers), this.InputObject.Name, input); this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); this.WriteObject(new ASRJob(this.jobResponse)); } }