예제 #1
0
        /// <summary>
        /// Queries by friendly name.
        /// </summary>
        private void GetByFriendlyName()
        {
            bool found = false;

            ReplicationProtectedItemListResponse replicationProtectedItemListResponse = RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(
                Utilities.GetValueFromArmId(this.ProtectionContainer.ID, ARMResourceTypeConstants.ReplicationFabrics),
                this.ProtectionContainer.Name);
            ReplicationProtectedItem replicationProtectedItem =
                replicationProtectedItemListResponse.ReplicationProtectedItems.SingleOrDefault(t =>
                                                                                               string.Compare(t.Properties.FriendlyName, this.FriendlyName, StringComparison.OrdinalIgnoreCase) == 0);

            if (replicationProtectedItem != null)
            {
                ReplicationProtectedItemResponse replicationProtectedItemResponse = RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(
                    Utilities.GetValueFromArmId(this.ProtectionContainer.ID, ARMResourceTypeConstants.ReplicationFabrics),
                    this.ProtectionContainer.Name,
                    replicationProtectedItem.Name);
                WriteReplicationProtectedItem(replicationProtectedItemResponse.ReplicationProtectedItem);

                found = true;
            }

            if (!found)
            {
                throw new InvalidOperationException(
                          string.Format(
                              Properties.Resources.ProtectionEntityNotFound,
                              this.FriendlyName,
                              this.ProtectionContainer.FriendlyName));
            }
        }
        /// <summary>
        /// Start PE Commit.
        /// </summary>
        private void SetPECommit()
        {
            // fetch the latest PE object
            ProtectableItemResponse protectableItemResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryProtectableItem(this.fabricName,
                                                                           this.ProtectionEntity.ProtectionContainerId, this.ProtectionEntity.Name);

            ReplicationProtectedItemResponse replicationProtectedItemResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(this.fabricName,
                                                                                    this.ProtectionEntity.ProtectionContainerId, Utilities.GetValueFromArmId(protectableItemResponse.ProtectableItem.Properties.ReplicationProtectedItemId, ARMResourceTypeConstants.ReplicationProtectedItems));

            PolicyResponse policyResponse = RecoveryServicesClient.GetAzureSiteRecoveryPolicy(Utilities.GetValueFromArmId(replicationProtectedItemResponse.ReplicationProtectedItem.Properties.PolicyID, ARMResourceTypeConstants.ReplicationPolicies));

            this.ProtectionEntity = new ASRProtectionEntity(protectableItemResponse.ProtectableItem, replicationProtectedItemResponse.ReplicationProtectedItem);

            LongRunningOperationResponse response = RecoveryServicesClient.StartAzureSiteRecoveryCommitFailover(
                this.fabricName,
                this.protectionContainerName,
                Utilities.GetValueFromArmId(replicationProtectedItemResponse.ReplicationProtectedItem.Id, ARMResourceTypeConstants.ReplicationProtectedItems));

            JobResponse jobResponse =
                RecoveryServicesClient
                .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));

            WriteObject(new ASRJob(jobResponse.Job));
        }
예제 #3
0
        /// <summary>
        /// Queries by Protectable Item
        /// </summary>
        private void GetByProtectableItem()
        {
            bool found = false;

            ProtectableItemResponse protectableItemResponse = RecoveryServicesClient.GetAzureSiteRecoveryProtectableItem(
                Utilities.GetValueFromArmId(this.ProtectableItem.ID, ARMResourceTypeConstants.ReplicationFabrics),
                Utilities.GetValueFromArmId(this.ProtectableItem.ID, ARMResourceTypeConstants.ReplicationProtectionContainers),
                this.ProtectableItem.Name);

            if (protectableItemResponse.ProtectableItem != null)
            {
                ReplicationProtectedItemResponse replicationProtectedItemResponse = RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(
                    Utilities.GetValueFromArmId(this.ProtectableItem.ID, ARMResourceTypeConstants.ReplicationFabrics),
                    Utilities.GetValueFromArmId(this.ProtectableItem.ID, ARMResourceTypeConstants.ReplicationProtectionContainers),
                    Utilities.GetValueFromArmId(protectableItemResponse.ProtectableItem.Properties.ReplicationProtectedItemId, ARMResourceTypeConstants.ReplicationProtectedItems));

                WriteReplicationProtectedItem(replicationProtectedItemResponse.ReplicationProtectedItem);

                found = true;
            }

            if (!found)
            {
                throw new InvalidOperationException(
                          string.Format(
                              Properties.Resources.ProtectionEntityNotFound,
                              this.FriendlyName,
                              this.ProtectionContainer.FriendlyName));
            }
        }
예제 #4
0
        /// <summary>
        /// Queries by Name.
        /// </summary>
        private void GetByName()
        {
            try
            {
                var replicationProtectedItemResponse = RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(
                    Utilities.GetValueFromArmId(this.ProtectionContainer.ID, ARMResourceTypeConstants.ReplicationFabrics),
                    this.ProtectionContainer.Name,
                    this.Name);

                if (replicationProtectedItemResponse.ReplicationProtectedItem != null)
                {
                    this.WriteReplicationProtectedItem(replicationProtectedItemResponse.ReplicationProtectedItem);
                }
            }
            catch (CloudException ex)
            {
                if (string.Compare(ex.Error.Code, "NotFound", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    throw new InvalidOperationException(
                              string.Format(
                                  Properties.Resources.ReplicationProtectedItemNotFound,
                                  this.Name,
                                  this.ProtectionContainer.FriendlyName));
                }
                else
                {
                    throw;
                }
            }
        }
        /// <summary>
        /// Write Protection Entities
        /// </summary>
        /// <param name="protectableItems">List of protectable items</param>
        private void WriteProtectionEntities(IList <ProtectableItem> protectableItems)
        {
            List <ASRProtectionEntity> asrProtectionEntityList = new List <ASRProtectionEntity>();

            foreach (ProtectableItem protectableItem in protectableItems)
            {
                ReplicationProtectedItemResponse replicationProtectedItemResponse = null;
                if (!String.IsNullOrEmpty(protectableItem.Properties.ReplicationProtectedItemId))
                {
                    replicationProtectedItemResponse = RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(
                        Utilities.GetValueFromArmId(this.ProtectionContainer.ID, ARMResourceTypeConstants.ReplicationFabrics),
                        this.ProtectionContainer.Name,
                        Utilities.GetValueFromArmId(protectableItem.Properties.ReplicationProtectedItemId, ARMResourceTypeConstants.ReplicationProtectedItems));
                }

                if (replicationProtectedItemResponse != null && replicationProtectedItemResponse.ReplicationProtectedItem != null)
                {
                    PolicyResponse policyResponse = RecoveryServicesClient.GetAzureSiteRecoveryPolicy(Utilities.GetValueFromArmId(replicationProtectedItemResponse.ReplicationProtectedItem.Properties.PolicyID, ARMResourceTypeConstants.ReplicationPolicies));
                    asrProtectionEntityList.Add(new ASRProtectionEntity(protectableItem, replicationProtectedItemResponse.ReplicationProtectedItem, policyResponse.Policy));
                }
                else
                {
                    asrProtectionEntityList.Add(new ASRProtectionEntity(protectableItem));
                }
            }

            this.WriteObject(asrProtectionEntityList, true);
        }
예제 #6
0
        /// <summary>
        /// Starts PE Unplanned failover.
        /// </summary>
        private void StartPEUnplannedFailover()
        {
            var unplannedFailoverInputProperties = new UnplannedFailoverInputProperties()
            {
                FailoverDirection       = this.Direction,
                SourceSiteOperations    = this.PerformSourceSideActions ? "Required" : "NotRequired", //Required|NotRequired
                ProviderSpecificDetails = new ProviderSpecificFailoverInput()
            };

            var input = new UnplannedFailoverInput()
            {
                Properties = unplannedFailoverInputProperties
            };

            // fetch the latest PE object
            ProtectableItemResponse protectableItemResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryProtectableItem(this.fabricName,
                                                                           this.ProtectionEntity.ProtectionContainerId, this.ProtectionEntity.Name);

            ReplicationProtectedItemResponse replicationProtectedItemResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(this.fabricName,
                                                                                    this.ProtectionEntity.ProtectionContainerId, Utilities.GetValueFromArmId(protectableItemResponse.ProtectableItem.Properties.ReplicationProtectedItemId, ARMResourceTypeConstants.ReplicationProtectedItems));

            PolicyResponse policyResponse = RecoveryServicesClient.GetAzureSiteRecoveryPolicy(Utilities.GetValueFromArmId(replicationProtectedItemResponse.ReplicationProtectedItem.Properties.PolicyID, ARMResourceTypeConstants.ReplicationPolicies));

            this.ProtectionEntity = new ASRProtectionEntity(protectableItemResponse.ProtectableItem, replicationProtectedItemResponse.ReplicationProtectedItem);

            if (0 == string.Compare(
                    this.ProtectionEntity.ReplicationProvider,
                    Constants.HyperVReplicaAzure,
                    StringComparison.OrdinalIgnoreCase))
            {
                if (this.Direction == Constants.PrimaryToRecovery)
                {
                    var failoverInput = new HyperVReplicaAzureFailoverProviderInput()
                    {
                        PrimaryKekCertificatePfx   = primaryKekCertpfx,
                        SecondaryKekCertificatePfx = secondaryKekCertpfx,
                        VaultLocation = this.GetCurrentVaultLocation()
                    };
                    input.Properties.ProviderSpecificDetails = failoverInput;
                }
            }

            LongRunningOperationResponse response =
                RecoveryServicesClient.StartAzureSiteRecoveryUnplannedFailover(
                    this.fabricName,
                    this.protectionContainerName,
                    Utilities.GetValueFromArmId(replicationProtectedItemResponse.ReplicationProtectedItem.Id, ARMResourceTypeConstants.ReplicationProtectedItems),
                    input);

            JobResponse jobResponse =
                RecoveryServicesClient
                .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));

            WriteObject(new ASRJob(jobResponse.Job));
        }
        /// <summary>
        /// Creates Replication Plan Legacy.
        /// </summary>
        private void CreateRecoveryPlanLegacy()
        {
            CreateRecoveryPlanInputProperties createRecoveryPlanInputProperties = new CreateRecoveryPlanInputProperties()
            {
                FailoverDeploymentModel = failoverDeploymentModel,
                Groups           = new List <RecoveryPlanGroup>(),
                PrimaryFabricId  = this.primaryserver,
                RecoveryFabricId = this.recoveryserver
            };

            RecoveryPlanGroup recoveryPlanGroup = new RecoveryPlanGroup()
            {
                GroupType = Constants.Boot,
                ReplicationProtectedItems = new List <RecoveryPlanProtectedItem>(),
                StartGroupActions         = new List <RecoveryPlanAction>(),
                EndGroupActions           = new List <RecoveryPlanAction>()
            };

            foreach (ASRProtectionEntity pe in ProtectionEntityList)
            {
                string fabricName = Utilities.GetValueFromArmId(pe.ID, ARMResourceTypeConstants.ReplicationFabrics);
                // fetch the latest PE object
                ProtectableItemResponse protectableItemResponse =
                    RecoveryServicesClient.GetAzureSiteRecoveryProtectableItem(fabricName,
                                                                               pe.ProtectionContainerId, pe.Name);

                ReplicationProtectedItemResponse replicationProtectedItemResponse =
                    RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(fabricName,
                                                                                        pe.ProtectionContainerId, Utilities.GetValueFromArmId(protectableItemResponse.ProtectableItem.Properties.ReplicationProtectedItemId, ARMResourceTypeConstants.ReplicationProtectedItems));

                string VmId = null;

                if (replicationProtectedItemResponse.ReplicationProtectedItem.Properties.ProviderSpecificDetails.GetType() == typeof(HyperVReplicaAzureReplicationDetails))
                {
                    VmId = ((HyperVReplicaAzureReplicationDetails)replicationProtectedItemResponse.ReplicationProtectedItem.Properties.ProviderSpecificDetails).VmId;
                }
                else if (replicationProtectedItemResponse.ReplicationProtectedItem.Properties.ProviderSpecificDetails.GetType() == typeof(HyperVReplica2012ReplicationDetails))
                {
                    VmId = ((HyperVReplica2012ReplicationDetails)replicationProtectedItemResponse.ReplicationProtectedItem.Properties.ProviderSpecificDetails).VmId;
                }

                RecoveryPlanProtectedItem recoveryPlanProtectedItem = new RecoveryPlanProtectedItem();
                recoveryPlanProtectedItem.Id = replicationProtectedItemResponse.ReplicationProtectedItem.Id;
                recoveryPlanProtectedItem.VirtualMachineId = VmId;
                recoveryPlanGroup.ReplicationProtectedItems.Add(recoveryPlanProtectedItem);
            }

            createRecoveryPlanInputProperties.Groups.Add(recoveryPlanGroup);

            CreateRecoveryPlanInput createRecoveryPlanInput = new CreateRecoveryPlanInput()
            {
                Properties = createRecoveryPlanInputProperties
            };

            CreateRecoveryPlan(this.Name, createRecoveryPlanInput);
        }
        /// <summary>
        /// Write Protection Entity
        /// </summary>
        /// <param name="protectableItem"></param>
        private void WriteProtectionEntity(ProtectableItem protectableItem)
        {
            ReplicationProtectedItemResponse replicationProtectedItemResponse = null;

            if (!String.IsNullOrEmpty(protectableItem.Properties.ReplicationProtectedItemId))
            {
                replicationProtectedItemResponse = RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(
                    Utilities.GetValueFromArmId(this.ProtectionContainer.ID, ARMResourceTypeConstants.ReplicationFabrics),
                    this.ProtectionContainer.Name,
                    Utilities.GetValueFromArmId(protectableItem.Properties.ReplicationProtectedItemId, ARMResourceTypeConstants.ReplicationProtectedItems));
            }

            if (replicationProtectedItemResponse != null && replicationProtectedItemResponse.ReplicationProtectedItem != null)
            {
                PolicyResponse policyResponse = RecoveryServicesClient.GetAzureSiteRecoveryPolicy(Utilities.GetValueFromArmId(replicationProtectedItemResponse.ReplicationProtectedItem.Properties.PolicyID, ARMResourceTypeConstants.ReplicationPolicies));
                this.WriteObject(new ASRVirtualMachine(protectableItem, replicationProtectedItemResponse.ReplicationProtectedItem, policyResponse.Policy));
            }
            else
            {
                this.WriteObject(new ASRVirtualMachine(protectableItem));
            }
        }
        /// <summary>
        ///     Switches protection from one container to another or one replication provider to another.
        /// </summary>
        private void A2ARPIReprotect()
        {
            var switchProtectionInputProperties = new SwitchProtectionInputProperties()
            {
                ReplicationProtectedItemName = this.ReplicationProtectedItem.Name,
                ProviderSpecificDetails      = new SwitchProtectionProviderSpecificInput()
            };
            var fabricFriendlyName =
                this.ReplicationProtectedItem.PrimaryFabricFriendlyName;
            SwitchProtectionInput input = new SwitchProtectionInput()
            {
                Properties = switchProtectionInputProperties
            };

            if (0 == string.Compare(
                    this.ReplicationProtectedItem.ReplicationProvider,
                    Constants.A2A,
                    StringComparison.OrdinalIgnoreCase))
            {
                var a2aSwitchInput = new A2ASwitchProtectionInput()
                {
                    PolicyId            = this.ProtectionContainerMapping.PolicyId,
                    RecoveryContainerId =
                        this.ProtectionContainerMapping.TargetProtectionContainerId,
                    VmDisks                          = new List <A2AVmDiskInputDetails>(),
                    VmManagedDisks                   = new List <A2AVmManagedDiskInputDetails>(),
                    RecoveryResourceGroupId          = this.RecoveryResourceGroupId,
                    RecoveryCloudServiceId           = this.RecoveryCloudServiceId,
                    RecoveryAvailabilitySetId        = this.RecoveryAvailabilitySetId,
                    RecoveryBootDiagStorageAccountId = this.RecoveryBootDiagStorageAccountId,
                };

                // Fetch the latest Protected item objects
                var replicationProtectedItemResponse =
                    RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(
                        this.fabricName,
                        this.protectionContainerName,
                        this.ReplicationProtectedItem.Name);

                if (fabricFriendlyName != this.ProtectionContainerMapping.TargetFabricFriendlyName)
                {
                    throw new ArgumentException(
                              string.Format(Resources.InvalidSwitchParamRPIAndProtectionContainerMapping,
                                            fabricFriendlyName,
                                            this.ProtectionContainerMapping.TargetFabricFriendlyName));
                }

                // unmanagedDisk case
                if (((A2AReplicationDetails)replicationProtectedItemResponse.Properties.ProviderSpecificDetails).ProtectedDisks != null &&
                    ((A2AReplicationDetails)replicationProtectedItemResponse.Properties.ProviderSpecificDetails).ProtectedDisks.Count > 0)
                {
                    populateUnManagedDiskInputDetails(fabricFriendlyName, a2aSwitchInput, replicationProtectedItemResponse);
                }
                else if (this.AzureToAzureDiskReplicationConfiguration == null &&
                         ((A2AReplicationDetails)replicationProtectedItemResponse.Properties.ProviderSpecificDetails).ProtectedManagedDisks != null)
                {
                    populateManagedDiskInputDetails(a2aSwitchInput, replicationProtectedItemResponse);
                }

                input.Properties.ProviderSpecificDetails = a2aSwitchInput;
            }

            var response =
                RecoveryServicesClient.StartSwitchProtection(
                    this.fabricName,
                    this.protectionContainerName,
                    input);

            var jobResponse =
                RecoveryServicesClient
                .GetAzureSiteRecoveryJobDetails(
                    PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));

            WriteObject(new ASRJob(jobResponse));
        }
예제 #10
0
        /// <summary>
        /// PE Reprotect.
        /// </summary>
        private void SetPEReprotect()
        {
            ReverseReplicationInputProperties plannedFailoverInputProperties = new ReverseReplicationInputProperties()
            {
                FailoverDirection       = this.Direction,
                ProviderSpecificDetails = new ReverseReplicationProviderSpecificInput()
            };

            ReverseReplicationInput input = new ReverseReplicationInput()
            {
                Properties = plannedFailoverInputProperties
            };

            // fetch the latest PE object
            ProtectableItemResponse protectableItemResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryProtectableItem(this.fabricName,
                                                                           this.ProtectionEntity.ProtectionContainerId, this.ProtectionEntity.Name);

            ReplicationProtectedItemResponse replicationProtectedItemResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(this.fabricName,
                                                                                    this.ProtectionEntity.ProtectionContainerId, Utilities.GetValueFromArmId(protectableItemResponse.ProtectableItem.Properties.ReplicationProtectedItemId, ARMResourceTypeConstants.ReplicationProtectedItems));

            PolicyResponse policyResponse = RecoveryServicesClient.GetAzureSiteRecoveryPolicy(Utilities.GetValueFromArmId(replicationProtectedItemResponse.ReplicationProtectedItem.Properties.PolicyID, ARMResourceTypeConstants.ReplicationPolicies));

            this.ProtectionEntity = new ASRProtectionEntity(protectableItemResponse.ProtectableItem, replicationProtectedItemResponse.ReplicationProtectedItem);

            if (0 == string.Compare(
                    this.ProtectionEntity.ReplicationProvider,
                    Constants.HyperVReplicaAzure,
                    StringComparison.OrdinalIgnoreCase))
            {
                if (this.Direction == Constants.PrimaryToRecovery)
                {
                    HyperVReplicaAzureReprotectInput reprotectInput = new HyperVReplicaAzureReprotectInput()
                    {
                        HvHostVmId = this.ProtectionEntity.FabricObjectId,
                        VmName     = this.ProtectionEntity.FriendlyName,
                        OSType     = ((string.Compare(this.ProtectionEntity.OS, "Windows") == 0) || (string.Compare(this.ProtectionEntity.OS, "Linux") == 0)) ? this.ProtectionEntity.OS : "Windows",
                        VHDId      = this.ProtectionEntity.OSDiskId
                    };

                    HyperVReplicaAzureReplicationDetails providerSpecificDetails =
                        (HyperVReplicaAzureReplicationDetails)replicationProtectedItemResponse.ReplicationProtectedItem.Properties.ProviderSpecificDetails;

                    reprotectInput.StorageAccountId = providerSpecificDetails.RecoveryAzureStorageAccount;

                    input.Properties.ProviderSpecificDetails = reprotectInput;
                }
            }

            LongRunningOperationResponse response =
                RecoveryServicesClient.StartAzureSiteRecoveryReprotection(
                    this.fabricName,
                    this.protectionContainerName,
                    Utilities.GetValueFromArmId(replicationProtectedItemResponse.ReplicationProtectedItem.Id, ARMResourceTypeConstants.ReplicationProtectedItems),
                    input);

            JobResponse jobResponse =
                RecoveryServicesClient
                .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));

            WriteObject(new ASRJob(jobResponse.Job));
        }
예제 #11
0
        /// <summary>
        /// ProcessRecord of the command.
        /// </summary>
        public override void ExecuteSiteRecoveryCmdlet()
        {
            base.ExecuteSiteRecoveryCmdlet();

            ASRRecoveryPlanGroup tempGroup;

            switch (this.ParameterSetName)
            {
            case ASRParameterSets.AppendGroup:
                RecoveryPlanGroup recoveryPlanGroup = new RecoveryPlanGroup()
                {
                    GroupType = Constants.Boot,
                    ReplicationProtectedItems = new List <RecoveryPlanProtectedItem>(),
                    StartGroupActions         = new List <RecoveryPlanAction>(),
                    EndGroupActions           = new List <RecoveryPlanAction>()
                };

                this.RecoveryPlan.Groups.Add(new ASRRecoveryPlanGroup("Group " + (RecoveryPlan.Groups.Count - 1).ToString(), recoveryPlanGroup));
                break;

            case ASRParameterSets.RemoveGroup:
                tempGroup = this.RecoveryPlan.Groups.FirstOrDefault(g => String.Compare(g.Name, RemoveGroup.Name, StringComparison.OrdinalIgnoreCase) == 0);

                if (tempGroup != null)
                {
                    this.RecoveryPlan.Groups.Remove(tempGroup);
                    this.RecoveryPlan = this.RecoveryPlan.RefreshASRRecoveryPlanGroupNames();
                }
                else
                {
                    throw new PSArgumentException(string.Format(Properties.Resources.GroupNotFoundInRecoveryPlan, this.RemoveGroup.Name, this.RecoveryPlan.FriendlyName));
                }

                break;

            case ASRParameterSets.AddProtectedEntities:
                foreach (ASRProtectionEntity pe in AddProtectedEntities)
                {
                    string fabricName = Utilities.GetValueFromArmId(pe.ID, ARMResourceTypeConstants.ReplicationFabrics);
                    // fetch the latest PE object
                    ProtectableItemResponse protectableItemResponse =
                        RecoveryServicesClient.GetAzureSiteRecoveryProtectableItem(fabricName,
                                                                                   pe.ProtectionContainerId, pe.Name);

                    ReplicationProtectedItemResponse replicationProtectedItemResponse =
                        RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(fabricName,
                                                                                            pe.ProtectionContainerId, Utilities.GetValueFromArmId(protectableItemResponse.ProtectableItem.Properties.ReplicationProtectedItemId,
                                                                                                                                                  ARMResourceTypeConstants.ReplicationProtectedItems));

                    tempGroup = this.RecoveryPlan.Groups.FirstOrDefault(g => String.Compare(g.Name, Group.Name, StringComparison.OrdinalIgnoreCase) == 0);

                    if (tempGroup != null)
                    {
                        foreach (ASRRecoveryPlanGroup gp in this.RecoveryPlan.Groups)
                        {
                            if (gp.ReplicationProtectedItems == null)
                            {
                                continue;
                            }

                            if (gp.ReplicationProtectedItems.Any(pi => String.Compare(pi.Id, replicationProtectedItemResponse.ReplicationProtectedItem.Id, StringComparison.OrdinalIgnoreCase) == 0))
                            {
                                throw new PSArgumentException(string.Format(Properties.Resources.VMAlreadyPartOfGroup, pe.FriendlyName, gp.Name, this.RecoveryPlan.FriendlyName));
                            }
                        }

                        this.RecoveryPlan.Groups[RecoveryPlan.Groups.IndexOf(tempGroup)].ReplicationProtectedItems.Add(replicationProtectedItemResponse.ReplicationProtectedItem);
                    }
                    else
                    {
                        throw new PSArgumentException(string.Format(Properties.Resources.GroupNotFoundInRecoveryPlan, this.Group.Name, this.RecoveryPlan.FriendlyName));
                    }
                }
                break;

            case ASRParameterSets.RemoveProtectedEntities:
                foreach (ASRProtectionEntity pe in RemoveProtectedEntities)
                {
                    string fabricName = Utilities.GetValueFromArmId(pe.ID, ARMResourceTypeConstants.ReplicationFabrics);
                    // fetch the latest PE object
                    ProtectableItemResponse protectableItemResponse =
                        RecoveryServicesClient.GetAzureSiteRecoveryProtectableItem(fabricName,
                                                                                   pe.ProtectionContainerId, pe.Name);

                    tempGroup = this.RecoveryPlan.Groups.FirstOrDefault(g => String.Compare(g.Name, Group.Name, StringComparison.OrdinalIgnoreCase) == 0);

                    if (tempGroup != null)
                    {
                        var ReplicationProtectedItem =
                            this.RecoveryPlan.Groups[RecoveryPlan.Groups.IndexOf(tempGroup)].
                            ReplicationProtectedItems.
                            FirstOrDefault(pi => String.Compare(pi.Id,
                                                                protectableItemResponse.ProtectableItem.Properties.ReplicationProtectedItemId,
                                                                StringComparison.OrdinalIgnoreCase) == 0);

                        if (ReplicationProtectedItem != null)
                        {
                            this.RecoveryPlan.Groups[RecoveryPlan.Groups.IndexOf(tempGroup)].ReplicationProtectedItems.Remove(ReplicationProtectedItem);
                        }
                        else
                        {
                            throw new PSArgumentException(string.Format(Properties.Resources.VMNotFoundInGroup, pe.FriendlyName, this.Group.Name, this.RecoveryPlan.FriendlyName));
                        }
                    }
                    else
                    {
                        throw new PSArgumentException(string.Format(Properties.Resources.GroupNotFoundInRecoveryPlan, this.Group.Name, this.RecoveryPlan.FriendlyName));
                    }
                }
                break;
            }
            ;

            this.WriteObject(this.RecoveryPlan);
        }
예제 #12
0
        /// <summary>
        /// ProcessRecord of the command.
        /// </summary>
        public override void ExecuteSiteRecoveryCmdlet()
        {
            base.ExecuteSiteRecoveryCmdlet();

            ProtectableItemResponse protectableItemResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryProtectableItem(Utilities.GetValueFromArmId(this.VirtualMachine.ID, ARMResourceTypeConstants.ReplicationFabrics),
                                                                           this.VirtualMachine.ProtectionContainerId, this.VirtualMachine.Name);

            if (protectableItemResponse.ProtectableItem.Properties.ReplicationProtectedItemId == null)
            {
                this.WriteWarning(Properties.Resources.ProtectionIsNotEnabledForVM.ToString());
                return;
            }

            ReplicationProtectedItemResponse replicationProtectedItemResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(Utilities.GetValueFromArmId(this.VirtualMachine.ID, ARMResourceTypeConstants.ReplicationFabrics),
                                                                                    this.VirtualMachine.ProtectionContainerId, Utilities.GetValueFromArmId(protectableItemResponse.ProtectableItem.Properties.ReplicationProtectedItemId, ARMResourceTypeConstants.ReplicationProtectedItems));

            // Check for Replication Provider type HyperVReplicaAzure
            if (0 != string.Compare(
                    replicationProtectedItemResponse.ReplicationProtectedItem.Properties.ProviderSpecificDetails.InstanceType,
                    Constants.HyperVReplicaAzure,
                    StringComparison.OrdinalIgnoreCase))
            {
                this.WriteWarning(Properties.Resources.UnsupportedReplicationProvidedForUpdateVmProperties.ToString());
                return;
            }

            // Check for at least one option
            if (string.IsNullOrEmpty(this.Name) &&
                string.IsNullOrEmpty(this.Size) &&
                string.IsNullOrEmpty(this.PrimaryNic) &&
                string.IsNullOrEmpty(this.RecoveryNetworkId))
            {
                this.WriteWarning(Properties.Resources.ArgumentsMissingForUpdateVmProperties.ToString());
                return;
            }

            // Both primary & recovery inputs should be present
            if (string.IsNullOrEmpty(this.PrimaryNic) ^
                string.IsNullOrEmpty(this.RecoveryNetworkId))
            {
                this.WriteWarning(Properties.Resources.NetworkArgumentsMissingForUpdateVmProperties.ToString());
                return;
            }

            List <VMNicInputDetails> vMNicInputDetailsList = new List <VMNicInputDetails>();
            VMNicDetails             vMNicDetailsToBeUpdated;

            if (!string.IsNullOrEmpty(this.PrimaryNic))
            {
                HyperVReplicaAzureReplicationDetails providerSpecificDetails =
                    (HyperVReplicaAzureReplicationDetails)replicationProtectedItemResponse.ReplicationProtectedItem.Properties.ProviderSpecificDetails;

                if (providerSpecificDetails.VMNics != null)
                {
                    vMNicDetailsToBeUpdated = providerSpecificDetails.VMNics.SingleOrDefault(n => string.Compare(n.NicId, this.PrimaryNic, StringComparison.OrdinalIgnoreCase) == 0);
                    if (vMNicDetailsToBeUpdated != null)
                    {
                        VMNicInputDetails vMNicInputDetails = new VMNicInputDetails();

                        vMNicInputDetails.NicId = this.PrimaryNic;
                        vMNicInputDetails.RecoveryVMSubnetName      = this.RecoveryNicSubnetName;
                        vMNicInputDetails.ReplicaNicStaticIPAddress = this.RecoveryNicStaticIPAddress;
                        vMNicInputDetails.SelectionType             = string.IsNullOrEmpty(this.NicSelectionType) ? Constants.SelectedByUser : this.NicSelectionType;
                        vMNicInputDetailsList.Add(vMNicInputDetails);

                        IEnumerable <VMNicDetails> vMNicDetailsListRemaining = providerSpecificDetails.VMNics.Where(n => string.Compare(n.NicId, this.PrimaryNic, StringComparison.OrdinalIgnoreCase) != 0);
                        foreach (VMNicDetails nDetails in vMNicDetailsListRemaining)
                        {
                            vMNicInputDetails = new VMNicInputDetails();

                            vMNicInputDetails.NicId = nDetails.NicId;
                            vMNicInputDetails.RecoveryVMSubnetName      = nDetails.RecoveryVMSubnetName;
                            vMNicInputDetails.ReplicaNicStaticIPAddress = nDetails.ReplicaNicStaticIPAddress;
                            vMNicInputDetails.SelectionType             = nDetails.SelectionType;
                            vMNicInputDetailsList.Add(vMNicInputDetails);
                        }
                    }
                    else
                    {
                        throw new PSInvalidOperationException(Properties.Resources.NicNotFoundInVMForUpdateVmProperties);
                    }
                }
            }

            UpdateReplicationProtectedItemInputProperties updateReplicationProtectedItemInputProperties = new UpdateReplicationProtectedItemInputProperties()
            {
                RecoveryAzureVMName            = this.Name,
                RecoveryAzureVMSize            = this.Size,
                SelectedRecoveryAzureNetworkId = this.RecoveryNetworkId,
                VmNics = vMNicInputDetailsList
            };

            UpdateReplicationProtectedItemInput input = new UpdateReplicationProtectedItemInput()
            {
                Properties = updateReplicationProtectedItemInputProperties
            };

            LongRunningOperationResponse response = RecoveryServicesClient.UpdateVmProperties(
                Utilities.GetValueFromArmId(this.VirtualMachine.ID, ARMResourceTypeConstants.ReplicationFabrics),
                Utilities.GetValueFromArmId(this.VirtualMachine.ID, ARMResourceTypeConstants.ReplicationProtectionContainers),
                replicationProtectedItemResponse.ReplicationProtectedItem.Name,
                input);

            JobResponse jobResponse =
                RecoveryServicesClient
                .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));

            WriteObject(new ASRJob(jobResponse.Job));
        }
예제 #13
0
        /// <summary>
        /// Queries all Protected Items under given Protection Container.
        /// </summary>
        private void GetAll()
        {
            ReplicationProtectedItemListResponse replicationProtectedItemListResponse = RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(
                Utilities.GetValueFromArmId(this.ProtectionContainer.ID, ARMResourceTypeConstants.ReplicationFabrics),
                this.ProtectionContainer.Name);

            WriteReplicationProtectedItems(replicationProtectedItemListResponse.ReplicationProtectedItems);
        }
예제 #14
0
        /// <summary>
        /// Starts PE Test failover.
        /// </summary>
        private void StartPETestFailover()
        {
            var testFailoverInputProperties = new TestFailoverInputProperties()
            {
                FailoverDirection       = this.Direction,
                NetworkId               = this.networkId,
                NetworkType             = this.networkType,
                ProviderSpecificDetails = new ProviderSpecificFailoverInput()
            };

            var input = new TestFailoverInput()
            {
                Properties = testFailoverInputProperties
            };

            // fetch the latest PE object
            ProtectableItemResponse protectableItemResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryProtectableItem(this.fabricName,
                                                                           this.ProtectionEntity.ProtectionContainerId, this.ProtectionEntity.Name);

            ReplicationProtectedItemResponse replicationProtectedItemResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(this.fabricName,
                                                                                    this.ProtectionEntity.ProtectionContainerId, Utilities.GetValueFromArmId(protectableItemResponse.ProtectableItem.Properties.ReplicationProtectedItemId, ARMResourceTypeConstants.ReplicationProtectedItems));

            PolicyResponse policyResponse = RecoveryServicesClient.GetAzureSiteRecoveryPolicy(Utilities.GetValueFromArmId(replicationProtectedItemResponse.ReplicationProtectedItem.Properties.PolicyID, ARMResourceTypeConstants.ReplicationPolicies));

            this.ProtectionEntity = new ASRProtectionEntity(protectableItemResponse.ProtectableItem, replicationProtectedItemResponse.ReplicationProtectedItem);

            if (0 == string.Compare(
                    this.ProtectionEntity.ReplicationProvider,
                    Constants.HyperVReplicaAzure,
                    StringComparison.OrdinalIgnoreCase))
            {
                if (this.Direction == Constants.PrimaryToRecovery)
                {
                    var failoverInput = new HyperVReplicaAzureFailoverProviderInput()
                    {
                        PrimaryKekCertificatePfx   = primaryKekCertpfx,
                        SecondaryKekCertificatePfx = secondaryKekCertpfx,
                        VaultLocation = this.GetCurrentVaultLocation()
                    };

                    input.Properties.ProviderSpecificDetails = failoverInput;
                }
                else
                {
                    new ArgumentException(Properties.Resources.UnsupportedDirectionForTFO);// Throw Unsupported Direction Exception
                }
            }

            LongRunningOperationResponse response =
                RecoveryServicesClient.StartAzureSiteRecoveryTestFailover(
                    this.fabricName,
                    this.protectionContainerName,
                    Utilities.GetValueFromArmId(replicationProtectedItemResponse.ReplicationProtectedItem.Id, ARMResourceTypeConstants.ReplicationProtectedItems),
                    input);

            JobResponse jobResponse =
                RecoveryServicesClient
                .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));

            WriteObject(new ASRJob(jobResponse.Job));
        }
        /// <summary>
        ///     Switches protection from one container to another or one replication provider to another.
        /// </summary>
        private void A2ARPIReprotect()
        {
            var switchProtectionInputProperties = new SwitchProtectionInputProperties()
            {
                ReplicationProtectedItemName = this.ReplicationProtectedItem.Name,
                ProviderSpecificDetails      = new SwitchProtectionProviderSpecificInput()
            };
            var fabricFriendlyName =
                this.ReplicationProtectedItem.PrimaryFabricFriendlyName;
            SwitchProtectionInput input = new SwitchProtectionInput()
            {
                Properties = switchProtectionInputProperties
            };

            if (0 == string.Compare(
                    this.ReplicationProtectedItem.ReplicationProvider,
                    Constants.A2A,
                    StringComparison.OrdinalIgnoreCase))
            {
                var a2aSwitchInput = new A2ASwitchProtectionInput()
                {
                    PolicyId            = this.ProtectionContainerMapping.PolicyId,
                    RecoveryContainerId =
                        this.ProtectionContainerMapping.TargetProtectionContainerId,
                    VmDisks = new List <A2AVmDiskInputDetails>(),
                    RecoveryResourceGroupId   = this.RecoveryResourceGroupId,
                    RecoveryCloudServiceId    = this.RecoveryCloudServiceId,
                    RecoveryAvailabilitySetId = this.RecoveryAvailabilitySetId
                };

                // Fetch the latest Protected item objects
                var replicationProtectedItemResponse =
                    RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(
                        this.fabricName,
                        this.protectionContainerName,
                        this.ReplicationProtectedItem.Name);

                if (fabricFriendlyName != this.ProtectionContainerMapping.TargetFabricFriendlyName)
                {
                    throw new ArgumentException(
                              string.Format(Resources.InvalidSwitchParamRPIAndProtectionContainerMapping,
                                            fabricFriendlyName,
                                            this.ProtectionContainerMapping.TargetFabricFriendlyName));
                }

                // At a time only Disk or managedDisk details will be present.
                // Will check with retieved protectedItem weather correct disk mapping is passed and then create the relevant object
                // and pass as input to service.
                if (this.AzureToAzureDiskReplicationConfiguration == null || this.AzureToAzureDiskReplicationConfiguration.Length == 0)
                {
                    if (fabricFriendlyName !=
                        this.ProtectionContainerMapping.TargetFabricFriendlyName &&
                        RecoveryAzureStorageAccountId == null)
                    {
                        throw new ArgumentException(Resources.InvalidRecoveryAzureStorageAccountId);
                    }

                    foreach (var disk in ((A2AReplicationDetails)replicationProtectedItemResponse
                                          .Properties.ProviderSpecificDetails)
                             .ProtectedDisks)
                    {
                        a2aSwitchInput.VmDisks.Add(new A2AVmDiskInputDetails
                        {
                            DiskUri = disk.RecoveryDiskUri,
                            RecoveryAzureStorageAccountId =
                                fabricFriendlyName ==
                                this.ProtectionContainerMapping.TargetFabricFriendlyName &&
                                this.RecoveryAzureStorageAccountId == null ?
                                disk.PrimaryDiskAzureStorageAccountId :
                                this.RecoveryAzureStorageAccountId,
                            PrimaryStagingAzureStorageAccountId =
                                this.LogStorageAccountId,
                        });
                    }
                }
                else
                {
                    foreach (ASRAzuretoAzureDiskReplicationConfig disk in this.AzureToAzureDiskReplicationConfiguration)
                    {
                        if (string.IsNullOrEmpty(disk.LogStorageAccountId))
                        {
                            throw new PSArgumentException(
                                      string.Format(
                                          Properties.Resources.InvalidPrimaryStagingAzureStorageAccountIdDiskInput,
                                          disk.VhdUri));
                        }

                        if (string.IsNullOrEmpty(disk.RecoveryAzureStorageAccountId))
                        {
                            throw new PSArgumentException(
                                      string.Format(
                                          Properties.Resources.InvalidRecoveryAzureStorageAccountIdDiskInput,
                                          disk.VhdUri));
                        }

                        a2aSwitchInput.VmDisks.Add(new A2AVmDiskInputDetails
                        {
                            DiskUri = disk.VhdUri,
                            RecoveryAzureStorageAccountId       = disk.RecoveryAzureStorageAccountId,
                            PrimaryStagingAzureStorageAccountId =
                                disk.LogStorageAccountId
                        });
                    }
                }

                input.Properties.ProviderSpecificDetails = a2aSwitchInput;
            }

            var response =
                RecoveryServicesClient.StartSwitchProtection(
                    this.fabricName,
                    this.protectionContainerName,
                    input);

            var jobResponse =
                RecoveryServicesClient
                .GetAzureSiteRecoveryJobDetails(
                    PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));

            WriteObject(new ASRJob(jobResponse));
        }
예제 #16
0
        /// <summary>
        /// Starts PE Planned failover.
        /// </summary>
        private void StartPEPlannedFailover()
        {
            var plannedFailoverInputProperties = new PlannedFailoverInputProperties()
            {
                FailoverDirection       = this.Direction,
                ProviderSpecificDetails = new ProviderSpecificFailoverInput()
            };

            var input = new PlannedFailoverInput()
            {
                Properties = plannedFailoverInputProperties
            };

            // fetch the latest PE object
            ProtectableItemResponse protectableItemResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryProtectableItem(this.fabricName,
                                                                           this.ProtectionEntity.ProtectionContainerId, this.ProtectionEntity.Name);

            ReplicationProtectedItemResponse replicationProtectedItemResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(this.fabricName,
                                                                                    this.ProtectionEntity.ProtectionContainerId, Utilities.GetValueFromArmId(protectableItemResponse.ProtectableItem.Properties.ReplicationProtectedItemId, ARMResourceTypeConstants.ReplicationProtectedItems));

            PolicyResponse policyResponse = RecoveryServicesClient.GetAzureSiteRecoveryPolicy(Utilities.GetValueFromArmId(replicationProtectedItemResponse.ReplicationProtectedItem.Properties.PolicyID, ARMResourceTypeConstants.ReplicationPolicies));

            this.ProtectionEntity = new ASRProtectionEntity(protectableItemResponse.ProtectableItem, replicationProtectedItemResponse.ReplicationProtectedItem);


            if (0 == string.Compare(
                    this.ProtectionEntity.ReplicationProvider,
                    Constants.HyperVReplicaAzure,
                    StringComparison.OrdinalIgnoreCase))
            {
                if (this.Direction == Constants.PrimaryToRecovery)
                {
                    var failoverInput = new HyperVReplicaAzureFailoverProviderInput()
                    {
                        PrimaryKekCertificatePfx   = primaryKekCertpfx,
                        SecondaryKekCertificatePfx = secondaryKekCertpfx,
                        VaultLocation = this.GetCurrentVaultLocation()
                    };
                    input.Properties.ProviderSpecificDetails = failoverInput;
                }
                else
                {
                    var failbackInput = new HyperVReplicaAzureFailbackProviderInput()
                    {
                        DataSyncOption           = this.Optimize == Constants.ForDownTime ? Constants.ForDownTime : Constants.ForSynchronization,
                        RecoveryVmCreationOption = String.Compare(this.CreateVmIfNotFound, Constants.Yes, StringComparison.OrdinalIgnoreCase) == 0 ? Constants.CreateVmIfNotFound : Constants.NoAction
                    };

                    if (String.Compare(this.CreateVmIfNotFound, Constants.Yes, StringComparison.OrdinalIgnoreCase) == 0 &&
                        string.Compare(RecoveryServicesClient.GetAzureSiteRecoveryFabric(this.fabricName).Fabric.Properties.CustomDetails.InstanceType, Constants.HyperVSite) == 0)
                    {
                        if (this.Server == null || string.Compare(this.Server.FabricType, Constants.HyperVSite) != 0)
                        {
                            throw new InvalidOperationException(
                                      Properties.Resources.ImproperServerObjectPassedForHyperVFailback);
                        }
                        else
                        {
                            failbackInput.ProviderIdForAlternateRecovery = this.Server.ID;
                        }
                    }

                    input.Properties.ProviderSpecificDetails = failbackInput;
                }
            }

            LongRunningOperationResponse response =
                RecoveryServicesClient.StartAzureSiteRecoveryPlannedFailover(
                    this.fabricName,
                    this.protectionContainerName,
                    Utilities.GetValueFromArmId(replicationProtectedItemResponse.ReplicationProtectedItem.Id, ARMResourceTypeConstants.ReplicationProtectedItems),
                    input);

            JobResponse jobResponse =
                RecoveryServicesClient
                .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));

            WriteObject(new ASRJob(jobResponse.Job));
        }
예제 #17
0
        /// <summary>
        /// Starts PE Planned failover.
        /// </summary>
        private void StartPEPlannedFailover()
        {
            PlannedFailoverInputProperties plannedFailoverInputProperties = new PlannedFailoverInputProperties()
            {
                FailoverDirection       = this.Direction,
                ProviderSpecificDetails = new ProviderSpecificFailoverInput()
            };

            PlannedFailoverInput input = new PlannedFailoverInput()
            {
                Properties = plannedFailoverInputProperties
            };

            // fetch the latest PE object
            ProtectableItemResponse protectableItemResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryProtectableItem(this.fabricName,
                                                                           this.ProtectionEntity.ProtectionContainerId, this.ProtectionEntity.Name);

            ReplicationProtectedItemResponse replicationProtectedItemResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryReplicationProtectedItem(this.fabricName,
                                                                                    this.ProtectionEntity.ProtectionContainerId, Utilities.GetValueFromArmId(protectableItemResponse.ProtectableItem.Properties.ReplicationProtectedItemId, ARMResourceTypeConstants.ReplicationProtectedItems));

            PolicyResponse policyResponse = RecoveryServicesClient.GetAzureSiteRecoveryPolicy(Utilities.GetValueFromArmId(replicationProtectedItemResponse.ReplicationProtectedItem.Properties.PolicyID, ARMResourceTypeConstants.ReplicationPolicies));

            this.ProtectionEntity = new ASRProtectionEntity(protectableItemResponse.ProtectableItem, replicationProtectedItemResponse.ReplicationProtectedItem);


            if (0 == string.Compare(
                    this.ProtectionEntity.ReplicationProvider,
                    Constants.HyperVReplicaAzure,
                    StringComparison.OrdinalIgnoreCase))
            {
                if (this.Direction == Constants.PrimaryToRecovery)
                {
                    HyperVReplicaAzureFailoverProviderInput failoverInput = new HyperVReplicaAzureFailoverProviderInput()
                    {
                        PrimaryKekCertificatePfx   = null,
                        SecondaryKekCertificatePfx = null,
                        VaultLocation = this.GetCurrentValutLocation()
                    };
                    input.Properties.ProviderSpecificDetails = failoverInput;
                }
                else
                {
                    HyperVReplicaAzureFailbackProviderInput failbackInput = new HyperVReplicaAzureFailbackProviderInput()
                    {
                        DataSyncOption = this.Optimize == Constants.ForDowntime ? Constants.ForDowntime : Constants.ForSynchronization,
                        //ProviderIdForAlternateRecovery = "",
                        RecoveryVmCreationOption = "CreateVmIfNotFound" //CreateVmIfNotFound | NoAction
                    };
                    input.Properties.ProviderSpecificDetails = failbackInput;
                }
            }

            LongRunningOperationResponse response =
                RecoveryServicesClient.StartAzureSiteRecoveryPlannedFailover(
                    this.fabricName,
                    this.protectionContainerName,
                    Utilities.GetValueFromArmId(replicationProtectedItemResponse.ReplicationProtectedItem.Id, ARMResourceTypeConstants.ReplicationProtectedItems),
                    input);

            JobResponse jobResponse =
                RecoveryServicesClient
                .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));

            WriteObject(new ASRJob(jobResponse.Job));
        }