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;
                    }
                }
            }
        }
        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;
                    }
                }
            }
        }
        public void CreateAndAssociateE2A(string provider)
        {
            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.AssociationDetail[0].AssociationStatus == "Paired")
                    {
                        // Instead of creating new set of values. Picking the values from already paired cloud.
                        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;
                        storageAccount.SubscriptionId     = obj.ActiveStorageAccount.SubscriptionId;
                        settings.StorageAccounts.Add(storageAccount);

                        serializedHyperVReplicaAzureProfileManagementInput =
                            DataContractUtils <HyperVReplicaAzureProtectionProfileInput> .Serialize(settings);
                    }
                }

                var responsePC = client.ProtectionContainer.List(RequestHeaders);

                foreach (var pc in responsePC.ProtectionContainers)
                {
                    if (string.IsNullOrWhiteSpace(pc.Role))
                    {
                        var input = new CreateAndAssociateProtectionProfileInput();

                        input.ProtectionProfileInput      = new CreateProtectionProfileInput();
                        input.ProtectionProfileInput.Name = "PP1";
                        input.ProtectionProfileInput.ReplicationProvider         = "HyperVReplicaAzure";
                        input.ProtectionProfileInput.ReplicationProviderSettings =
                            serializedHyperVReplicaAzureProfileManagementInput;

                        input.AssociationInput = new ProtectionProfileAssociationInput();
                        input.AssociationInput.PrimaryProtectionContainerId  = pc.ID;
                        input.AssociationInput.RecoveryProtectionContainerId = AzureProtectionContainerId;

                        client.ProtectionProfile.CreateAndAssociate(input, requestHeaders);
                    }
                }

                //Assert.NotNull(response.);
                //Assert.NotNull(response.RecoveryPlan.ID);
                //Assert.NotNull(response.RecoveryPlan.Name);
                //Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }
        public void CreateAndAssociateE2A(string provider)
        {
            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.AssociationDetail[0].AssociationStatus == "Paired")
                    {
                        // Instead of creating new set of values. Picking the values from already paired cloud.
                        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;
                        storageAccount.SubscriptionId = obj.ActiveStorageAccount.SubscriptionId;
                        settings.StorageAccounts.Add(storageAccount);

                        serializedHyperVReplicaAzureProfileManagementInput =
                            DataContractUtils<HyperVReplicaAzureProtectionProfileInput>.Serialize(settings);
                    }
                }

                var responsePC = client.ProtectionContainer.List(RequestHeaders);

                foreach (var pc in responsePC.ProtectionContainers)
                {
                    if (string.IsNullOrWhiteSpace(pc.Role))
                    {
                        var input = new CreateAndAssociateProtectionProfileInput();

                        input.ProtectionProfileInput = new CreateProtectionProfileInput();
                        input.ProtectionProfileInput.Name = "PP1";
                        input.ProtectionProfileInput.ReplicationProvider = "HyperVReplicaAzure";
                        input.ProtectionProfileInput.ReplicationProviderSettings =
                            serializedHyperVReplicaAzureProfileManagementInput;

                        input.AssociationInput = new ProtectionProfileAssociationInput();
                        input.AssociationInput.PrimaryProtectionContainerId = pc.ID;
                        input.AssociationInput.RecoveryProtectionContainerId = AzureProtectionContainerId;

                        client.ProtectionProfile.CreateAndAssociate(input, requestHeaders);
                    }
                }

                //Assert.NotNull(response.);
                //Assert.NotNull(response.RecoveryPlan.ID);
                //Assert.NotNull(response.RecoveryPlan.Name);
                //Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }