private void EnterpriseToEnterpriseDissociation() { if (string.Compare( this.ProtectionProfile.ReplicationProvider, Constants.HyperVReplica, StringComparison.OrdinalIgnoreCase) != 0) { throw new InvalidOperationException( string.Format( Properties.Resources.IncorrectReplicationProvider, this.ProtectionProfile.ReplicationProvider)); } DisassociateProtectionProfileInput disassociateProtectionProfileInput = new DisassociateProtectionProfileInput(); disassociateProtectionProfileInput.PrimaryProtectionContainerId = this.PrimaryProtectionContainer.Name; disassociateProtectionProfileInput.RecoveryProtectionContainerId = this.RecoveryProtectionContainer.Name; disassociateProtectionProfileInput.Name = this.ProtectionProfile.Name; disassociateProtectionProfileInput.ReplicationProviderSettings = new ProtectionProfileProviderSpecificInput(); this.response = RecoveryServicesClient.DissociateAzureSiteRecoveryProtectionProfile( this.ProtectionProfile.Name, disassociateProtectionProfileInput); JobResponse jobResponse = RecoveryServicesClient .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); WriteObject(new ASRJob(jobResponse.Job)); }
/// <summary> /// ProcessRecord of the command. /// </summary> public override void ExecuteCmdlet() { try { string recoveryContainerId = string.Empty; recoveryContainerId = this.RecoveryProtectionContainer.ID; DisassociateProtectionProfileInput disassociateProtectionProfileInput = new DisassociateProtectionProfileInput(); disassociateProtectionProfileInput.PrimaryProtectionContainerId = this.PrimaryProtectionContainer.Name; disassociateProtectionProfileInput.RecoveryProtectionContainerId = this.RecoveryProtectionContainer.Name; disassociateProtectionProfileInput.Name = this.ProtectionProfile.Name; disassociateProtectionProfileInput.ReplicationProviderSettings = string.Empty; this.response = RecoveryServicesClient.DissociateAzureSiteRecoveryProtectionProfile( this.ProtectionProfile.Name, disassociateProtectionProfileInput); JobResponse jobResponse = RecoveryServicesClient .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); WriteObject(new ASRJob(jobResponse.Job)); } catch (Exception exception) { this.HandleException(exception); } }
/// <summary> /// Dissociates Azure Site Recovery Protection Profile. /// </summary> /// <param name="protectionProfileId">Protection Profile ID</param> /// <param name="DisassociateProtectionProfileInput">Protection Profile disassociation Input</param> /// <returns>Long running operation response</returns> public LongRunningOperationResponse DissociateAzureSiteRecoveryProtectionProfile( string protectionProfileId, DisassociateProtectionProfileInput disassociateProtectionProfileInput) { return(this.GetSiteRecoveryClient().ProtectionProfile.BeginDissociating( protectionProfileId, disassociateProtectionProfileInput, this.GetRequestHeaders())); }
/// <summary> /// Creates a profile /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.SiteRecovery.IProtectionProfileOperations. /// </param> /// <param name='name'> /// Required. Input to dissociate profile /// </param> /// <param name='input'> /// Required. Input to create profile /// </param> /// <param name='customRequestHeaders'> /// Optional. Request header parameters. /// </param> /// <returns> /// A standard service response for long running operations. /// </returns> public static Task <LongRunningOperationResponse> DissociateAsync(this IProtectionProfileOperations operations, string name, DisassociateProtectionProfileInput input, CustomRequestHeaders customRequestHeaders) { return(operations.DissociateAsync(name, input, customRequestHeaders, CancellationToken.None)); }
/// <summary> /// Creates a profile /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.SiteRecovery.IProtectionProfileOperations. /// </param> /// <param name='name'> /// Required. Input to dissociate profile /// </param> /// <param name='input'> /// Required. Input to create profile /// </param> /// <param name='customRequestHeaders'> /// Optional. Request header parameters. /// </param> /// <returns> /// A standard service response for long running operations. /// </returns> public static LongRunningOperationResponse Dissociate(this IProtectionProfileOperations operations, string name, DisassociateProtectionProfileInput input, CustomRequestHeaders customRequestHeaders) { return(Task.Factory.StartNew((object s) => { return ((IProtectionProfileOperations)s).DissociateAsync(name, input, customRequestHeaders); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }