/// <summary> /// Associates protection profile with enterprise based protection containers /// </summary> private void EnterpriseToEnterpriseAssociation() { if (string.Compare( this.ProtectionProfile.ReplicationProvider, Constants.HyperVReplica, StringComparison.OrdinalIgnoreCase) != 0) { throw new InvalidOperationException( string.Format( Properties.Resources.IncorrectReplicationProvider, this.ProtectionProfile.ReplicationProvider)); } ProtectionProfileAssociationInput protectionProfileAssociationInput = new ProtectionProfileAssociationInput( this.PrimaryProtectionContainer.Name, this.RecoveryProtectionContainer.Name); LongRunningOperationResponse response = RecoveryServicesClient.AssociateAzureSiteRecoveryProtectionProfile( this.ProtectionProfile.Name, protectionProfileAssociationInput); JobResponse jobResponse = RecoveryServicesClient .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); this.WriteObject(new ASRJob(jobResponse.Job)); }
/// <summary> /// Deletes and Dissociates Azure Site Recovery Protection Profile. /// </summary> /// <param name="protectionProfileId">Protection Profile ID</param> /// <param name="protectionProfileAssociationInput">Protection Profile Association Input</param> /// <returns>Job response</returns> public JobResponse StartDeleteAndDissociateAzureSiteRecoveryProtectionProfileJob( string protectionProfileId, ProtectionProfileAssociationInput protectionProfileAssociationInput) { return(this.GetSiteRecoveryClient().ProtectionProfile.DissociateAndDelete( protectionProfileId, protectionProfileAssociationInput, this.GetRequestHeaders())); }
/// <summary> /// Associates Azure Site Recovery Protection Profile. /// </summary> /// <param name="ProtectionProfileAssociationInput">Protection Profile association input</param> /// <returns>Long running operation response</returns> public LongRunningOperationResponse AssociateAzureSiteRecoveryProtectionProfile( string profileName, ProtectionProfileAssociationInput protectionProfileAssociationInput) { return(this.GetSiteRecoveryClient().ProtectionProfile.BeginAssociating( profileName, protectionProfileAssociationInput, this.GetRequestHeaders())); }
/// <summary> /// Associates protection profile with one enterprise based and an Azure protection container /// </summary> private void EnterpriseToAzureAssociation() { if (string.Compare( this.ProtectionProfile.ReplicationProvider, Constants.HyperVReplicaAzure, StringComparison.OrdinalIgnoreCase) != 0) { throw new InvalidOperationException( string.Format( Properties.Resources.IncorrectReplicationProvider, this.ProtectionProfile.ReplicationProvider)); } HyperVReplicaAzureProtectionProfileInput hyperVReplicaAzureProtectionProfileInput = new HyperVReplicaAzureProtectionProfileInput() { ApplicationConsistentSnapshotFrequencyInHours = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ApplicationConsistentSnapshotFrequencyInHours, ReplicationInterval = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ReplicationFrequencyInSeconds, OnlineReplicationStartTime = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ReplicationStartTime, RecoveryPointHistoryDuration = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.RecoveryPoints, EncryptionEnabled = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.EncryptStoredData }; var storageAccount = new CustomerStorageAccount(); storageAccount.StorageAccountName = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.RecoveryAzureStorageAccountName; storageAccount.SubscriptionId = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.RecoveryAzureSubscription; hyperVReplicaAzureProtectionProfileInput.StorageAccounts = new System.Collections.Generic.List <CustomerStorageAccount>(); hyperVReplicaAzureProtectionProfileInput.StorageAccounts.Add(storageAccount); CreateProtectionProfileInput createProtectionProfileInput = new CreateProtectionProfileInput( string.IsNullOrEmpty(this.ProtectionProfile.Name) ? this.PrimaryProtectionContainer.Name : this.ProtectionProfile.Name, this.ProtectionProfile.ReplicationProvider, DataContractUtils <HyperVReplicaAzureProtectionProfileInput> .Serialize(hyperVReplicaAzureProtectionProfileInput)); ProtectionProfileAssociationInput protectionProfileAssociationInput = new ProtectionProfileAssociationInput( this.PrimaryProtectionContainer.ID, Constants.AzureContainer); CreateAndAssociateProtectionProfileInput createAndAssociateProtectionProfileInput = new CreateAndAssociateProtectionProfileInput( createProtectionProfileInput, protectionProfileAssociationInput); this.jobResponse = RecoveryServicesClient.StartCreateAndAssociateAzureSiteRecoveryProtectionProfileJob( createAndAssociateProtectionProfileInput); this.WriteJob(this.jobResponse.Job); }
/// <summary> /// Associates protection profile with enterprise based protection containers /// </summary> private void EnterpriseToEnterpriseAssociation() { if (string.Compare( this.ProtectionProfile.ReplicationProvider, Constants.HyperVReplica, StringComparison.OrdinalIgnoreCase) != 0) { throw new InvalidOperationException( string.Format( Properties.Resources.IncorrectReplicationProvider, this.ProtectionProfile.ReplicationProvider)); } HyperVReplicaProtectionProfileInput hyperVReplicaProtectionProfileInput = new HyperVReplicaProtectionProfileInput() { ApplicationConsistentSnapshotFrequencyInHours = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ApplicationConsistentSnapshotFrequencyInHours, ReplicationFrequencyInSeconds = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationFrequencyInSeconds, OnlineReplicationStartTime = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationStartTime, CompressionEnabled = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.CompressionEnabled, OnlineReplicationMethod = (string.Compare(this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationMethod, Constants.OnlineReplicationMethod, StringComparison.OrdinalIgnoreCase) == 0) ? true : false, RecoveryPoints = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.RecoveryPoints, ReplicationPort = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationPort, AllowReplicaDeletion = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.AllowReplicaDeletion, AllowedAuthenticationType = (ushort)((string.Compare(this.ProtectionProfile.HyperVReplicaProviderSettingsObject.Authentication, Constants.AuthenticationTypeKerberos, StringComparison.OrdinalIgnoreCase) == 0) ? 1 : 2), }; CreateProtectionProfileInput createProtectionProfileInput = new CreateProtectionProfileInput( //// Name of the protection profile as the name of the protection container if not given string.IsNullOrEmpty(this.ProtectionProfile.Name) ? this.PrimaryProtectionContainer.Name : this.ProtectionProfile.Name, this.ProtectionProfile.ReplicationProvider, DataContractUtils <HyperVReplicaProtectionProfileInput> .Serialize(hyperVReplicaProtectionProfileInput)); ProtectionProfileAssociationInput protectionProfileAssociationInput = new ProtectionProfileAssociationInput( this.PrimaryProtectionContainer.ID, this.RecoveryProtectionContainer.ID); CreateAndAssociateProtectionProfileInput createAndAssociateProtectionProfileInput = new CreateAndAssociateProtectionProfileInput( createProtectionProfileInput, protectionProfileAssociationInput); this.jobResponse = RecoveryServicesClient.StartCreateAndAssociateAzureSiteRecoveryProtectionProfileJob( createAndAssociateProtectionProfileInput); this.WriteJob(this.jobResponse.Job); }
/// <summary> /// ProcessRecord of the command. /// </summary> public override void ExecuteCmdlet() { try { this.WriteWarningWithTimestamp( string.Format( Properties.Resources.CmdletWillBeDeprecatedSoon, this.MyInvocation.MyCommand.Name)); string recoveryContainerId = string.Empty; switch (this.ParameterSetName) { case ASRParameterSets.EnterpriseToAzure: if (this.ProtectionProfile.ReplicationProvider != Constants.HyperVReplicaAzure) { throw new Exception("Please provide recovery container object."); } else { recoveryContainerId = Constants.AzureContainer; } break; case ASRParameterSets.EnterpriseToEnterprise: recoveryContainerId = this.RecoveryProtectionContainer.ID; break; } ProtectionProfileAssociationInput protectionProfileAssociationInput = new ProtectionProfileAssociationInput( this.PrimaryProtectionContainer.ID, recoveryContainerId); this.jobResponse = RecoveryServicesClient.StartDeleteAndDissociateAzureSiteRecoveryProtectionProfileJob( this.ProtectionProfile.ID, protectionProfileAssociationInput); this.WriteJob(this.jobResponse.Job); } catch (Exception exception) { this.HandleException(exception); } }
/// <summary> /// Enable Protection for the given protection entity. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionProfileOperations. /// </param> /// <param name='protectionProfileId'> /// Required. Protection Profile ID. /// </param> /// <param name='input'> /// Required. input. /// </param> /// <param name='customRequestHeaders'> /// Optional. Request header parameters. /// </param> /// <returns> /// The response model for the Job details object. /// </returns> public static JobResponse DissociateAndDelete(this IProtectionProfileOperations operations, string protectionProfileId, ProtectionProfileAssociationInput input, CustomRequestHeaders customRequestHeaders) { return(Task.Factory.StartNew((object s) => { return ((IProtectionProfileOperations)s).DissociateAndDeleteAsync(protectionProfileId, input, customRequestHeaders); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Enable Protection for the given protection entity. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionProfileOperations. /// </param> /// <param name='protectionProfileId'> /// Required. Protection Profile ID. /// </param> /// <param name='input'> /// Required. input. /// </param> /// <param name='customRequestHeaders'> /// Optional. Request header parameters. /// </param> /// <returns> /// The response model for the Job details object. /// </returns> public static Task <JobResponse> DissociateAndDeleteAsync(this IProtectionProfileOperations operations, string protectionProfileId, ProtectionProfileAssociationInput input, CustomRequestHeaders customRequestHeaders) { return(operations.DissociateAndDeleteAsync(protectionProfileId, 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 associate profile /// </param> /// <param name='input'> /// Required. Input to associate profile /// </param> /// <param name='customRequestHeaders'> /// Optional. Request header parameters. /// </param> /// <returns> /// A standard service response for long running operations. /// </returns> public static Task <LongRunningOperationResponse> AssociateAsync(this IProtectionProfileOperations operations, string name, ProtectionProfileAssociationInput input, CustomRequestHeaders customRequestHeaders) { return(operations.AssociateAsync(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 associate profile /// </param> /// <param name='input'> /// Required. Input to associate profile /// </param> /// <param name='customRequestHeaders'> /// Optional. Request header parameters. /// </param> /// <returns> /// A standard service response for long running operations. /// </returns> public static LongRunningOperationResponse BeginAssociating(this IProtectionProfileOperations operations, string name, ProtectionProfileAssociationInput input, CustomRequestHeaders customRequestHeaders) { return(Task.Factory.StartNew((object s) => { return ((IProtectionProfileOperations)s).BeginAssociatingAsync(name, input, customRequestHeaders); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }