/// <summary> /// Updates Azure Site Recovery Protection Profile given the ID. /// </summary> /// <param name="updateProtectionProfileInput">Protection Profile Input</param> /// <param name="protectionProfileId">Protection Profile ID</param> /// <returns>Job response</returns> public JobResponse UpdateAzureSiteRecoveryProtectionProfile( UpdateProtectionProfileInput updateProtectionProfileInput, string protectionProfileId) { return(this.GetSiteRecoveryClient().ProtectionProfile.Update( updateProtectionProfileInput, protectionProfileId, this.GetRequestHeaders())); }
public void Update() { using (UndoContext context = UndoContext.Current) { context.Start(); var client = GetSiteRecoveryClient(CustomHttpHandler); var requestHeaders = RequestHeaders; requestHeaders.AgentAuthenticationHeader = GenerateAgentAuthenticationHeader(requestHeaders.ClientRequestId); JobQueryParameter jqp = new JobQueryParameter(); var responseRP = client.ProtectionProfile.List(RequestHeaders); string serializedHyperVReplicaAzureProfileManagementInput = null; foreach (var profile in responseRP.ProtectionProfiles) { if (profile.ReplicationProvider == "HyperVReplicaAzure") { string subsId = null; var obj = DataContractUtils <HyperVReplicaAzureProtectionProfileDetails> .Deserialize( profile.ReplicationProviderSetting); var settings = new HyperVReplicaAzureProtectionProfileInput(); settings.AppConsistencyFreq = obj.AppConsistencyFreq; settings.IsEncryptionEnabled = obj.IsEncryptionEnabled; settings.OnlineIrStartTime = obj.OnlineIrStartTime; settings.RecoveryPointHistoryDuration = obj.RecoveryPointHistoryDuration; settings.ReplicationInterval = obj.ReplicationInterval; settings.StorageAccounts = new List <CustomerStorageAccount>(); var storageAccount = new CustomerStorageAccount(); storageAccount.StorageAccountName = obj.ActiveStorageAccount.StorageAccountName; subsId = storageAccount.SubscriptionId; storageAccount.SubscriptionId = "MySubscriptionId"; settings.StorageAccounts.Add(storageAccount); serializedHyperVReplicaAzureProfileManagementInput = DataContractUtils <HyperVReplicaAzureProtectionProfileInput> .Serialize(settings); // update the profile object. var input = new UpdateProtectionProfileInput(); input.ReplicationProviderSettings = serializedHyperVReplicaAzureProfileManagementInput; var responseUpdate = client.ProtectionProfile.Update(input, profile.ID, RequestHeaders); var responseGet = client.ProtectionProfile.Get(profile.ID, RequestHeaders); // check for subsid. Assert.NotNull(responseGet.ProtectionProfile); // revert the temp changes. storageAccount.SubscriptionId = subsId; serializedHyperVReplicaAzureProfileManagementInput = DataContractUtils <HyperVReplicaAzureProtectionProfileInput> .Serialize(settings); input.ReplicationProviderSettings = serializedHyperVReplicaAzureProfileManagementInput; responseUpdate = client.ProtectionProfile.Update( input, profile.ID, requestHeaders); return; } } } }
/// <summary> /// Update protection profile. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionProfileOperations. /// </param> /// <param name='input'> /// Required. input. /// </param> /// <param name='protectionProfileId'> /// Required. Profile id. /// </param> /// <param name='customRequestHeaders'> /// Optional. Request header parameters. /// </param> /// <returns> /// The response model for the Job details object. /// </returns> public static Task <JobResponse> UpdateAsync(this IProtectionProfileOperations operations, UpdateProtectionProfileInput input, string protectionProfileId, CustomRequestHeaders customRequestHeaders) { return(operations.UpdateAsync(input, protectionProfileId, customRequestHeaders, CancellationToken.None)); }
/// <summary> /// Update protection profile. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionProfileOperations. /// </param> /// <param name='input'> /// Required. input. /// </param> /// <param name='protectionProfileId'> /// Required. Profile id. /// </param> /// <param name='customRequestHeaders'> /// Optional. Request header parameters. /// </param> /// <returns> /// The response model for the Job details object. /// </returns> public static JobResponse Update(this IProtectionProfileOperations operations, UpdateProtectionProfileInput input, string protectionProfileId, CustomRequestHeaders customRequestHeaders) { return(Task.Factory.StartNew((object s) => { return ((IProtectionProfileOperations)s).UpdateAsync(input, protectionProfileId, customRequestHeaders); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }