/// <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> /// Creates an E2A Protection Profile Object /// </summary> private void EnterpriseToAzureProtectionProfileObject() { if (string.Compare(this.ReplicationProvider, Constants.HyperVReplicaAzure, StringComparison.OrdinalIgnoreCase) != 0) { throw new InvalidOperationException( string.Format( Properties.Resources.IncorrectReplicationProvider, this.ReplicationProvider)); } PSRecoveryServicesClient.ValidateReplicationStartTime(this.ReplicationStartTime); ushort replicationFrequencyInSeconds = PSRecoveryServicesClient.ConvertReplicationFrequencyToUshort(this.ReplicationFrequencyInSeconds); HyperVReplicaAzureProtectionProfileInput hyperVReplicaAzureProtectionProfileInput = new HyperVReplicaAzureProtectionProfileInput() { ApplicationConsistentSnapshotFrequencyInHours = this.ApplicationConsistentSnapshotFrequencyInHours, ReplicationInterval = replicationFrequencyInSeconds, RecoveryPointHistoryDuration = this.RecoveryPoints, OnlineReplicationStartTime = this.ReplicationStartTime, Encryption = "Disable" }; var storageAccount = new CustomerStorageAccount(); storageAccount.StorageAccountName = this.RecoveryAzureStorageAccount; storageAccount.SubscriptionId = this.RecoveryAzureSubscription; hyperVReplicaAzureProtectionProfileInput.StorageAccounts = new System.Collections.Generic.List <CustomerStorageAccount>(); hyperVReplicaAzureProtectionProfileInput.StorageAccounts.Add(storageAccount); CreateProtectionProfileInput createProtectionProfileInput = new CreateProtectionProfileInput(); createProtectionProfileInput.Name = this.Name; createProtectionProfileInput.ReplicationProvider = this.ReplicationProvider; createProtectionProfileInput.ReplicationProviderSettings = hyperVReplicaAzureProtectionProfileInput; LongRunningOperationResponse response = RecoveryServicesClient.CreateProtectionProfile(createProtectionProfileInput); JobResponse jobResponse = RecoveryServicesClient .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); WriteObject(new ASRJob(jobResponse.Job)); }
/// <summary> /// Creates an E2A Protection Profile Object /// </summary> private void EnterpriseToAzureProtectionProfileObject() { if (string.Compare(this.ReplicationProvider, Constants.HyperVReplicaAzure, StringComparison.OrdinalIgnoreCase) != 0) { throw new InvalidOperationException( string.Format( Properties.Resources.IncorrectReplicationProvider, this.ReplicationProvider)); } PSRecoveryServicesClient.ValidateReplicationStartTime(this.ReplicationStartTime); ushort replicationFrequencyInSeconds = PSRecoveryServicesClient.ConvertReplicationFrequencyToUshort(this.ReplicationFrequencyInSeconds); HyperVReplicaAzureProtectionProfileInput hyperVReplicaAzureProtectionProfileInput = new HyperVReplicaAzureProtectionProfileInput() { ApplicationConsistentSnapshotFrequencyInHours = this.ApplicationConsistentSnapshotFrequencyInHours, ReplicationInterval = replicationFrequencyInSeconds, RecoveryPointHistoryDuration = this.RecoveryPoints, OnlineReplicationStartTime = this.ReplicationStartTime, Encryption = "Disable" }; var storageAccount = new CustomerStorageAccount(); storageAccount.StorageAccountName = this.RecoveryAzureStorageAccount; storageAccount.SubscriptionId = this.RecoveryAzureSubscription; hyperVReplicaAzureProtectionProfileInput.StorageAccounts = new System.Collections.Generic.List<CustomerStorageAccount>(); hyperVReplicaAzureProtectionProfileInput.StorageAccounts.Add(storageAccount); CreateProtectionProfileInput createProtectionProfileInput = new CreateProtectionProfileInput(); createProtectionProfileInput.Name = this.Name; createProtectionProfileInput.ReplicationProvider = this.ReplicationProvider; createProtectionProfileInput.ReplicationProviderSettings = hyperVReplicaAzureProtectionProfileInput; LongRunningOperationResponse response = RecoveryServicesClient.CreateProtectionProfile(createProtectionProfileInput); JobResponse jobResponse = RecoveryServicesClient .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); WriteObject(new ASRJob(jobResponse.Job)); }