/// <summary> /// ProcessRecord of the command. /// </summary> public override void ExecuteSiteRecoveryCmdlet() { base.ExecuteSiteRecoveryCmdlet(); if (this.ShouldProcess( this.InputObject.FriendlyName, VerbsCommon.Set)) { var replicationProtectedItemResponse = this.RecoveryServicesClient .GetAzureSiteRecoveryReplicationProtectedItem( Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationFabrics), Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationProtectionContainers), this.InputObject.Name); var provider = replicationProtectedItemResponse.Properties.ProviderSpecificDetails; // Check for Replication Provider type HyperVReplicaAzure/InMageAzureV2 if (!(provider is HyperVReplicaAzureReplicationDetails) && !(provider is InMageAzureV2ReplicationDetails) && !(provider is A2AReplicationDetails)) { this.WriteWarning( Resources.UnsupportedReplicationProvidedForUpdateVmProperties); 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.UseManagedDisk == null && string.IsNullOrEmpty(this.RecoveryAvailabilitySet) && string.IsNullOrEmpty(this.RecoveryCloudServiceId) && string.IsNullOrEmpty(this.RecoveryResourceGroupId) && string.IsNullOrEmpty(this.LicenseType)) { this.WriteWarning(Resources.ArgumentsMissingForUpdateVmProperties); return; } // Both primary & recovery inputs should be present if (string.IsNullOrEmpty(this.PrimaryNic) ^ string.IsNullOrEmpty(this.RecoveryNetworkId)) { this.WriteWarning(Resources.NetworkArgumentsMissingForUpdateVmProperties); return; } var vmName = this.Name; var vmSize = this.Size; var vmRecoveryNetworkId = this.RecoveryNetworkId; var licenseType = this.LicenseType; var recoveryResourceGroupId = this.RecoveryResourceGroupId; var recoveryCloudServiceId = this.RecoveryCloudServiceId; var useManagedDisk = this.UseManagedDisk; var availabilitySetId = this.RecoveryAvailabilitySet; var vMNicInputDetailsList = new List <VMNicInputDetails>(); var providerSpecificInput = new UpdateReplicationProtectedItemProviderInput(); if (provider is HyperVReplicaAzureReplicationDetails) { var providerSpecificDetails = (HyperVReplicaAzureReplicationDetails)replicationProtectedItemResponse .Properties.ProviderSpecificDetails; if (string.IsNullOrEmpty(this.Name)) { vmName = providerSpecificDetails.RecoveryAzureVMName; } if (string.IsNullOrEmpty(this.Size)) { vmSize = providerSpecificDetails.RecoveryAzureVMSize; } if (string.IsNullOrEmpty(this.RecoveryNetworkId)) { vmRecoveryNetworkId = providerSpecificDetails .SelectedRecoveryAzureNetworkId; } if (string.IsNullOrEmpty(this.LicenseType)) { licenseType = providerSpecificDetails.LicenseType; } if (string.IsNullOrEmpty(this.RecoveryAvailabilitySet)) { availabilitySetId = providerSpecificDetails.RecoveryAvailabilitySetId; } if (string.IsNullOrEmpty(this.UseManagedDisk)) { useManagedDisk = providerSpecificDetails.UseManagedDisks; } if (string.IsNullOrEmpty(this.RecoveryResourceGroupId)) { recoveryResourceGroupId = providerSpecificDetails.RecoveryAzureResourceGroupId; } var deploymentType = Utilities.GetValueFromArmId( providerSpecificDetails.RecoveryAzureStorageAccount, ARMResourceTypeConstants.Providers); if (deploymentType.ToLower() .Contains(Constants.Classic.ToLower())) { providerSpecificInput = new HyperVReplicaAzureUpdateReplicationProtectedItemInput { RecoveryAzureV1ResourceGroupId = recoveryResourceGroupId, RecoveryAzureV2ResourceGroupId = null }; } else { providerSpecificInput = new HyperVReplicaAzureUpdateReplicationProtectedItemInput { RecoveryAzureV1ResourceGroupId = null, RecoveryAzureV2ResourceGroupId = recoveryResourceGroupId, UseManagedDisks = useManagedDisk }; } vMNicInputDetailsList = getNicListToUpdate(providerSpecificDetails.VmNics); } else if (provider is InMageAzureV2ReplicationDetails) { var providerSpecificDetails = (InMageAzureV2ReplicationDetails)replicationProtectedItemResponse.Properties .ProviderSpecificDetails; if (string.IsNullOrEmpty(this.Name)) { vmName = providerSpecificDetails.RecoveryAzureVMName; } if (string.IsNullOrEmpty(this.Size)) { vmSize = providerSpecificDetails.RecoveryAzureVMSize; } if (string.IsNullOrEmpty(this.RecoveryNetworkId)) { vmRecoveryNetworkId = providerSpecificDetails .SelectedRecoveryAzureNetworkId; } if (string.IsNullOrEmpty(this.LicenseType)) { licenseType = providerSpecificDetails.LicenseType; } if (string.IsNullOrEmpty(this.RecoveryAvailabilitySet)) { availabilitySetId = providerSpecificDetails.RecoveryAvailabilitySetId; } if (string.IsNullOrEmpty(this.UseManagedDisk)) { useManagedDisk = providerSpecificDetails.UseManagedDisks; } if (string.IsNullOrEmpty(this.RecoveryResourceGroupId)) { recoveryResourceGroupId = providerSpecificDetails.RecoveryAzureResourceGroupId; } var deploymentType = Utilities.GetValueFromArmId( providerSpecificDetails.RecoveryAzureStorageAccount, ARMResourceTypeConstants.Providers); if (deploymentType.ToLower() .Contains(Constants.Classic.ToLower())) { providerSpecificInput = new InMageAzureV2UpdateReplicationProtectedItemInput { RecoveryAzureV1ResourceGroupId = recoveryResourceGroupId, RecoveryAzureV2ResourceGroupId = null }; } else { providerSpecificInput = new InMageAzureV2UpdateReplicationProtectedItemInput { RecoveryAzureV1ResourceGroupId = null, RecoveryAzureV2ResourceGroupId = recoveryResourceGroupId, UseManagedDisks = useManagedDisk }; } vMNicInputDetailsList = getNicListToUpdate(providerSpecificDetails.VmNics); } else if (provider is A2AReplicationDetails) { A2AReplicationDetails providerSpecificDetails = (A2AReplicationDetails)replicationProtectedItemResponse.Properties.ProviderSpecificDetails; if (!this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.RecoveryResourceGroupId))) { recoveryResourceGroupId = providerSpecificDetails.RecoveryAzureResourceGroupId; } if (!this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.RecoveryCloudServiceId))) { recoveryCloudServiceId = providerSpecificDetails.RecoveryCloudService; } providerSpecificInput = new A2AUpdateReplicationProtectedItemInput() { RecoveryCloudServiceId = this.RecoveryCloudServiceId, RecoveryResourceGroupId = this.RecoveryResourceGroupId }; if (string.IsNullOrEmpty(this.RecoveryNetworkId)) { vmRecoveryNetworkId = providerSpecificDetails.SelectedRecoveryAzureNetworkId; } vMNicInputDetailsList = getNicListToUpdate(providerSpecificDetails.VmNics); } var updateReplicationProtectedItemInputProperties = new UpdateReplicationProtectedItemInputProperties { RecoveryAzureVMName = vmName, RecoveryAzureVMSize = vmSize, SelectedRecoveryAzureNetworkId = vmRecoveryNetworkId, VmNics = vMNicInputDetailsList, LicenseType = licenseType == Management.RecoveryServices.SiteRecovery.Models.LicenseType .NoLicenseType.ToString() ? Management.RecoveryServices.SiteRecovery.Models.LicenseType .NoLicenseType : Management.RecoveryServices.SiteRecovery.Models.LicenseType .WindowsServer, RecoveryAvailabilitySetId = availabilitySetId, ProviderSpecificDetails = providerSpecificInput }; var input = new UpdateReplicationProtectedItemInput { Properties = updateReplicationProtectedItemInputProperties }; var response = this.RecoveryServicesClient.UpdateVmProperties( Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationFabrics), Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationProtectionContainers), this.InputObject.Name, input); var jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); this.WriteObject(new ASRJob(jobResponse)); } }
/// <summary> /// ProcessRecord of the command. /// </summary> public override void ExecuteSiteRecoveryCmdlet() { base.ExecuteSiteRecoveryCmdlet(); if (this.ShouldProcess( this.InputObject.FriendlyName, VerbsCommon.Set)) { var replicationProtectedItemResponse = this.RecoveryServicesClient .GetAzureSiteRecoveryReplicationProtectedItem( Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationFabrics), Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationProtectionContainers), this.InputObject.Name); var provider = replicationProtectedItemResponse.Properties.ProviderSpecificDetails; // Check for Replication Provider type HyperVReplicaAzure/InMageAzureV2/A2A if (!(provider is HyperVReplicaAzureReplicationDetails) && !(provider is InMageAzureV2ReplicationDetails) && !(provider is A2AReplicationDetails)) { this.WriteWarning( Resources.UnsupportedReplicationProvidedForUpdateVmProperties); return; } // Check for at least one option if (string.IsNullOrEmpty(this.Name) && string.IsNullOrEmpty(this.Size) && string.IsNullOrEmpty(this.UpdateNic) && string.IsNullOrEmpty(this.RecoveryNetworkId) && string.IsNullOrEmpty(this.PrimaryNic) && this.UseManagedDisk == null && this.IsParameterBound(c => c.RecoveryAvailabilitySet) && string.IsNullOrEmpty(this.RecoveryCloudServiceId) && string.IsNullOrEmpty(this.RecoveryResourceGroupId) && string.IsNullOrEmpty(this.LicenseType) && string.IsNullOrEmpty(this.RecoveryBootDiagStorageAccountId) && this.AzureToAzureUpdateReplicationConfiguration == null) { this.WriteWarning(Resources.ArgumentsMissingForUpdateVmProperties); return; } // Both primary & recovery inputs should be present if (string.IsNullOrEmpty(this.UpdateNic) ^ string.IsNullOrEmpty(this.RecoveryNetworkId)) { this.WriteWarning(Resources.NetworkArgumentsMissingForUpdateVmProperties); return; } // NSG, LB and PIP only for A2A provider. if ((!string.IsNullOrEmpty(RecoveryNetworkSecurityGroupId) || !string.IsNullOrEmpty(RecoveryPublicIPAddressId) || RecoveryLBBackendAddressPoolId != null && RecoveryLBBackendAddressPoolId.Length > 0) && !(provider is A2AReplicationDetails)) { this.WriteWarning(Resources.NetworkingResourcesInDRNotSupportedForClassicVms); return; } var vmName = this.Name; var vmSize = this.Size; var vmRecoveryNetworkId = this.RecoveryNetworkId; var licenseType = this.LicenseType; var recoveryResourceGroupId = this.RecoveryResourceGroupId; var recoveryCloudServiceId = this.RecoveryCloudServiceId; var useManagedDisk = this.UseManagedDisk; var availabilitySetId = this.RecoveryAvailabilitySet; var primaryNic = this.PrimaryNic; var vMNicInputDetailsList = new List <VMNicInputDetails>(); var providerSpecificInput = new UpdateReplicationProtectedItemProviderInput(); if (provider is HyperVReplicaAzureReplicationDetails) { var providerSpecificDetails = (HyperVReplicaAzureReplicationDetails)replicationProtectedItemResponse .Properties.ProviderSpecificDetails; if (string.IsNullOrEmpty(this.Name)) { vmName = providerSpecificDetails.RecoveryAzureVmName; } if (string.IsNullOrEmpty(this.Size)) { vmSize = providerSpecificDetails.RecoveryAzureVMSize; } if (string.IsNullOrEmpty(this.RecoveryNetworkId)) { vmRecoveryNetworkId = providerSpecificDetails .SelectedRecoveryAzureNetworkId; } if (string.IsNullOrEmpty(this.LicenseType)) { licenseType = providerSpecificDetails.LicenseType; } availabilitySetId = this.IsParameterBound(c => c.RecoveryAvailabilitySet) ? this.RecoveryAvailabilitySet : providerSpecificDetails.RecoveryAvailabilitySetId; if (string.IsNullOrEmpty(this.UseManagedDisk)) { useManagedDisk = providerSpecificDetails.UseManagedDisks; } if (string.IsNullOrEmpty(this.RecoveryResourceGroupId)) { recoveryResourceGroupId = providerSpecificDetails.RecoveryAzureResourceGroupId; } if (!this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.PrimaryNic))) { primaryNic = providerSpecificDetails.SelectedSourceNicId; } var deploymentType = Utilities.GetValueFromArmId( providerSpecificDetails.RecoveryAzureStorageAccount, ARMResourceTypeConstants.Providers); if (deploymentType.ToLower() .Contains(Constants.Classic.ToLower())) { providerSpecificInput = new HyperVReplicaAzureUpdateReplicationProtectedItemInput { RecoveryAzureV1ResourceGroupId = recoveryResourceGroupId, RecoveryAzureV2ResourceGroupId = null }; } else { providerSpecificInput = new HyperVReplicaAzureUpdateReplicationProtectedItemInput { RecoveryAzureV1ResourceGroupId = null, RecoveryAzureV2ResourceGroupId = recoveryResourceGroupId, UseManagedDisks = useManagedDisk }; } vMNicInputDetailsList = getNicListToUpdate(providerSpecificDetails.VmNics); } else if (provider is InMageAzureV2ReplicationDetails) { var providerSpecificDetails = (InMageAzureV2ReplicationDetails)replicationProtectedItemResponse.Properties.ProviderSpecificDetails; if (string.IsNullOrEmpty(this.Name)) { vmName = providerSpecificDetails.RecoveryAzureVMName; } if (string.IsNullOrEmpty(this.Size)) { vmSize = providerSpecificDetails.RecoveryAzureVMSize; } if (string.IsNullOrEmpty(this.RecoveryNetworkId)) { vmRecoveryNetworkId = providerSpecificDetails.SelectedRecoveryAzureNetworkId; } if (string.IsNullOrEmpty(this.LicenseType)) { licenseType = providerSpecificDetails.LicenseType; } availabilitySetId = this.IsParameterBound(c => c.RecoveryAvailabilitySet) ? this.RecoveryAvailabilitySet : providerSpecificDetails.RecoveryAvailabilitySetId; if (string.IsNullOrEmpty(this.UseManagedDisk)) { useManagedDisk = providerSpecificDetails.UseManagedDisks; } if (string.IsNullOrEmpty(this.RecoveryResourceGroupId)) { recoveryResourceGroupId = providerSpecificDetails.RecoveryAzureResourceGroupId; } if (!this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.PrimaryNic))) { primaryNic = providerSpecificDetails.SelectedSourceNicId; } var deploymentType = Utilities.GetValueFromArmId( providerSpecificDetails.TargetVmId, ARMResourceTypeConstants.Providers); if (deploymentType.ToLower() .Contains(Constants.ClassicCompute.ToLower())) { providerSpecificInput = new InMageAzureV2UpdateReplicationProtectedItemInput { RecoveryAzureV1ResourceGroupId = recoveryResourceGroupId, RecoveryAzureV2ResourceGroupId = null }; } else { providerSpecificInput = new InMageAzureV2UpdateReplicationProtectedItemInput { RecoveryAzureV1ResourceGroupId = null, RecoveryAzureV2ResourceGroupId = recoveryResourceGroupId, UseManagedDisks = useManagedDisk }; } vMNicInputDetailsList = getNicListToUpdate(providerSpecificDetails.VmNics); } else if (provider is A2AReplicationDetails) { A2AReplicationDetails providerSpecificDetails = (A2AReplicationDetails)replicationProtectedItemResponse.Properties.ProviderSpecificDetails; if (!this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.RecoveryResourceGroupId))) { recoveryResourceGroupId = providerSpecificDetails.RecoveryAzureResourceGroupId; } availabilitySetId = this.IsParameterBound(c => c.RecoveryAvailabilitySet) ? this.RecoveryAvailabilitySet : providerSpecificDetails.RecoveryAvailabilitySet; if (!this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.RecoveryNetworkId))) { vmRecoveryNetworkId = providerSpecificDetails.SelectedRecoveryAzureNetworkId; } if (!this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.RecoveryCloudServiceId))) { recoveryCloudServiceId = providerSpecificDetails.RecoveryCloudService; } if (!this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.RecoveryBootDiagStorageAccountId))) { this.RecoveryBootDiagStorageAccountId = providerSpecificDetails.RecoveryBootDiagStorageAccountId; } List <A2AVmManagedDiskUpdateDetails> managedDiskUpdateDetails = null; // ManagedDisk case if (this.AzureToAzureUpdateReplicationConfiguration == null && providerSpecificDetails.ProtectedManagedDisks != null) { managedDiskUpdateDetails = new List <A2AVmManagedDiskUpdateDetails>(); foreach (var managedDisk in providerSpecificDetails.ProtectedManagedDisks) { managedDiskUpdateDetails.Add( new A2AVmManagedDiskUpdateDetails( managedDisk.DiskId, managedDisk.RecoveryTargetDiskAccountType, managedDisk.RecoveryReplicaDiskAccountType)); } } else if (this.AzureToAzureUpdateReplicationConfiguration != null && this.AzureToAzureUpdateReplicationConfiguration[0].IsManagedDisk) { managedDiskUpdateDetails = new List <A2AVmManagedDiskUpdateDetails>(); foreach (var managedDisk in this.AzureToAzureUpdateReplicationConfiguration) { managedDiskUpdateDetails.Add( new A2AVmManagedDiskUpdateDetails( managedDisk.DiskId, managedDisk.RecoveryTargetDiskAccountType, managedDisk.RecoveryReplicaDiskAccountType)); } } providerSpecificInput = new A2AUpdateReplicationProtectedItemInput() { RecoveryCloudServiceId = this.RecoveryCloudServiceId, RecoveryResourceGroupId = this.RecoveryResourceGroupId, RecoveryBootDiagStorageAccountId = this.RecoveryBootDiagStorageAccountId, ManagedDiskUpdateDetails = managedDiskUpdateDetails, DiskEncryptionInfo = this.A2AEncryptionDetails(provider) }; vMNicInputDetailsList = getNicListToUpdate(providerSpecificDetails.VmNics); } var updateReplicationProtectedItemInputProperties = new UpdateReplicationProtectedItemInputProperties { RecoveryAzureVMName = vmName, RecoveryAzureVMSize = vmSize, SelectedRecoveryAzureNetworkId = vmRecoveryNetworkId, SelectedSourceNicId = primaryNic, VmNics = vMNicInputDetailsList, LicenseType = licenseType == Management.RecoveryServices.SiteRecovery.Models.LicenseType .NoLicenseType.ToString() ? Management.RecoveryServices.SiteRecovery.Models.LicenseType .NoLicenseType : Management.RecoveryServices.SiteRecovery.Models.LicenseType .WindowsServer, RecoveryAvailabilitySetId = availabilitySetId, ProviderSpecificDetails = providerSpecificInput }; if (provider is HyperVReplicaAzureReplicationDetails || provider is InMageAzureV2ReplicationDetails) { updateReplicationProtectedItemInputProperties.SelectedSourceNicId = primaryNic; } var input = new UpdateReplicationProtectedItemInput { Properties = updateReplicationProtectedItemInputProperties }; var response = this.RecoveryServicesClient.UpdateVmProperties( Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationFabrics), Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationProtectionContainers), this.InputObject.Name, input); var jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); this.WriteObject(new ASRJob(jobResponse)); } }
/// <summary> /// ProcessRecord of the command. /// </summary> public override void ExecuteSiteRecoveryCmdlet() { base.ExecuteSiteRecoveryCmdlet(); if (this.ShouldProcess( this.InputObject.FriendlyName, VerbsCommon.Set)) { var replicationProtectedItemResponse = this.RecoveryServicesClient .GetAzureSiteRecoveryReplicationProtectedItem( Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationFabrics), Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationProtectionContainers), this.InputObject.Name); var provider = replicationProtectedItemResponse.Properties.ProviderSpecificDetails; // Check for Replication Provider type HyperVReplicaAzure/InMageAzureV2/A2A if (!(provider is HyperVReplicaAzureReplicationDetails) && !(provider is InMageAzureV2ReplicationDetails) && !(provider is A2AReplicationDetails)) { this.WriteWarning( Resources.UnsupportedReplicationProvidedForUpdateVmProperties); return; } // Check for at least one option if (string.IsNullOrEmpty(this.Name) && string.IsNullOrEmpty(this.Size) && string.IsNullOrEmpty(this.UpdateNic) && string.IsNullOrEmpty(this.RecoveryNetworkId) && string.IsNullOrEmpty(this.PrimaryNic) && this.UseManagedDisk == null && this.IsParameterBound(c => c.RecoveryAvailabilitySet) && this.IsParameterBound(c => c.RecoveryAvailabilityZone) && this.IsParameterBound(c => c.RecoveryProximityPlacementGroupId) && string.IsNullOrEmpty(this.RecoveryCloudServiceId) && string.IsNullOrEmpty(this.RecoveryResourceGroupId) && string.IsNullOrEmpty(this.LicenseType) && string.IsNullOrEmpty(this.RecoveryBootDiagStorageAccountId) && this.AzureToAzureUpdateReplicationConfiguration == null) { this.WriteWarning(Resources.ArgumentsMissingForUpdateVmProperties); return; } // Both primary & recovery inputs should be present if (this.ASRVMNicConfiguration == null && (string.IsNullOrEmpty(this.UpdateNic) ^ string.IsNullOrEmpty(this.RecoveryNetworkId))) { this.WriteWarning(Resources.NetworkArgumentsMissingForUpdateVmProperties); return; } // NSG, LB and PIP only for A2A provider. if ((!string.IsNullOrEmpty(RecoveryNetworkSecurityGroupId) || !string.IsNullOrEmpty(RecoveryPublicIPAddressId) || RecoveryLBBackendAddressPoolId != null && RecoveryLBBackendAddressPoolId.Length > 0) && !(provider is A2AReplicationDetails)) { this.WriteWarning( Resources.UnsupportedReplicationProvidedForNetworkingResources); return; } if (this.ASRVMNicConfiguration != null && !(provider is A2AReplicationDetails)) { this.WriteWarning(Resources.UnsupportedReplicationProvidedForASRVMNicConfig); return; } if (this.ASRVMNicConfiguration != null && !string.IsNullOrEmpty(this.UpdateNic)) { this.WriteWarning(Resources.ASRVMNicsAndUpdateNicNotAllowed); return; } var vmName = this.Name; var vmSize = this.Size; var vmRecoveryNetworkId = this.RecoveryNetworkId; var licenseType = this.LicenseType; var recoveryResourceGroupId = this.RecoveryResourceGroupId; var recoveryCloudServiceId = this.RecoveryCloudServiceId; var useManagedDisk = this.UseManagedDisk; var availabilitySetId = this.RecoveryAvailabilitySet; var proximityPlacementGroupId = this.RecoveryProximityPlacementGroupId; var availabilityZone = this.RecoveryAvailabilityZone; var primaryNic = this.PrimaryNic; var diskIdToDiskEncryptionMap = this.DiskIdToDiskEncryptionSetMap; var tfoNetworkId = string.Empty; var vMNicInputDetailsList = new List <VMNicInputDetails>(); var providerSpecificInput = new UpdateReplicationProtectedItemProviderInput(); if (provider is HyperVReplicaAzureReplicationDetails) { var providerSpecificDetails = (HyperVReplicaAzureReplicationDetails)replicationProtectedItemResponse .Properties.ProviderSpecificDetails; if (string.IsNullOrEmpty(this.Name)) { vmName = providerSpecificDetails.RecoveryAzureVmName; } if (string.IsNullOrEmpty(this.Size)) { vmSize = providerSpecificDetails.RecoveryAzureVMSize; } if (string.IsNullOrEmpty(this.RecoveryNetworkId)) { vmRecoveryNetworkId = providerSpecificDetails .SelectedRecoveryAzureNetworkId; } if (string.IsNullOrEmpty(this.LicenseType)) { licenseType = providerSpecificDetails.LicenseType; } availabilitySetId = this.IsParameterBound(c => c.RecoveryAvailabilitySet) ? this.RecoveryAvailabilitySet : providerSpecificDetails.RecoveryAvailabilitySetId; availabilityZone = this.IsParameterBound(c => c.RecoveryAvailabilityZone) ? this.RecoveryAvailabilityZone : providerSpecificDetails.TargetAvailabilityZone; proximityPlacementGroupId = this.IsParameterBound(c => c.RecoveryProximityPlacementGroupId) ? this.RecoveryProximityPlacementGroupId : providerSpecificDetails.TargetProximityPlacementGroupId; if (string.IsNullOrEmpty(this.UseManagedDisk)) { useManagedDisk = providerSpecificDetails.UseManagedDisks; } if (string.IsNullOrEmpty(this.RecoveryResourceGroupId)) { recoveryResourceGroupId = providerSpecificDetails.RecoveryAzureResourceGroupId; } if (!this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.PrimaryNic))) { primaryNic = providerSpecificDetails.SelectedSourceNicId; } if (this.DiskIdToDiskEncryptionSetMap == null || this.DiskIdToDiskEncryptionSetMap.Count == 0) { diskIdToDiskEncryptionMap = providerSpecificDetails.AzureVmDiskDetails. ToDictionary(x => x.DiskId, x => x.DiskEncryptionSetId); } var deploymentType = Utilities.GetValueFromArmId( providerSpecificDetails.RecoveryAzureStorageAccount, ARMResourceTypeConstants.Providers); if (deploymentType.ToLower() .Contains(Constants.Classic.ToLower())) { providerSpecificInput = new HyperVReplicaAzureUpdateReplicationProtectedItemInput { RecoveryAzureV1ResourceGroupId = recoveryResourceGroupId, RecoveryAzureV2ResourceGroupId = null }; } else { providerSpecificInput = new HyperVReplicaAzureUpdateReplicationProtectedItemInput { RecoveryAzureV1ResourceGroupId = null, RecoveryAzureV2ResourceGroupId = recoveryResourceGroupId, UseManagedDisks = useManagedDisk, DiskIdToDiskEncryptionMap = this.DiskIdToDiskEncryptionSetMap, TargetAvailabilityZone = availabilityZone, TargetProximityPlacementGroupId = proximityPlacementGroupId }; } vMNicInputDetailsList = getNicListToUpdate(providerSpecificDetails.VmNics); } else if (provider is InMageAzureV2ReplicationDetails) { var providerSpecificDetails = (InMageAzureV2ReplicationDetails)replicationProtectedItemResponse.Properties.ProviderSpecificDetails; if (string.IsNullOrEmpty(this.Name)) { vmName = providerSpecificDetails.RecoveryAzureVMName; } if (string.IsNullOrEmpty(this.Size)) { vmSize = providerSpecificDetails.RecoveryAzureVMSize; } if (string.IsNullOrEmpty(this.RecoveryNetworkId)) { vmRecoveryNetworkId = providerSpecificDetails.SelectedRecoveryAzureNetworkId; } if (string.IsNullOrEmpty(this.LicenseType)) { licenseType = providerSpecificDetails.LicenseType; } availabilitySetId = this.IsParameterBound(c => c.RecoveryAvailabilitySet) ? this.RecoveryAvailabilitySet : providerSpecificDetails.RecoveryAvailabilitySetId; availabilityZone = this.IsParameterBound(c => c.RecoveryAvailabilityZone) ? this.RecoveryAvailabilityZone : providerSpecificDetails.TargetAvailabilityZone; proximityPlacementGroupId = this.IsParameterBound(c => c.RecoveryProximityPlacementGroupId) ? this.RecoveryProximityPlacementGroupId : providerSpecificDetails.TargetProximityPlacementGroupId; if (string.IsNullOrEmpty(this.UseManagedDisk)) { useManagedDisk = providerSpecificDetails.UseManagedDisks; } if (string.IsNullOrEmpty(this.RecoveryResourceGroupId)) { recoveryResourceGroupId = providerSpecificDetails.RecoveryAzureResourceGroupId; } if (!this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.PrimaryNic))) { primaryNic = providerSpecificDetails.SelectedSourceNicId; } var deploymentType = Utilities.GetValueFromArmId( providerSpecificDetails.TargetVmId, ARMResourceTypeConstants.Providers); if (deploymentType.ToLower() .Contains(Constants.ClassicCompute.ToLower())) { providerSpecificInput = new InMageAzureV2UpdateReplicationProtectedItemInput { RecoveryAzureV1ResourceGroupId = recoveryResourceGroupId, RecoveryAzureV2ResourceGroupId = null }; } else { providerSpecificInput = new InMageAzureV2UpdateReplicationProtectedItemInput { RecoveryAzureV1ResourceGroupId = null, RecoveryAzureV2ResourceGroupId = recoveryResourceGroupId, UseManagedDisks = useManagedDisk, TargetAvailabilityZone = availabilityZone, TargetProximityPlacementGroupId = proximityPlacementGroupId }; } vMNicInputDetailsList = getNicListToUpdate(providerSpecificDetails.VmNics); } else if (provider is A2AReplicationDetails) { A2AReplicationDetails providerSpecificDetails = (A2AReplicationDetails)replicationProtectedItemResponse.Properties.ProviderSpecificDetails; if (!this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.RecoveryResourceGroupId))) { recoveryResourceGroupId = providerSpecificDetails.RecoveryAzureResourceGroupId; } availabilitySetId = this.IsParameterBound(c => c.RecoveryAvailabilitySet) ? this.RecoveryAvailabilitySet : providerSpecificDetails.RecoveryAvailabilitySet; if (!this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.RecoveryNetworkId))) { vmRecoveryNetworkId = providerSpecificDetails.SelectedRecoveryAzureNetworkId; } proximityPlacementGroupId = this.IsParameterBound(c => c.RecoveryProximityPlacementGroupId) ? this.RecoveryProximityPlacementGroupId : providerSpecificDetails.RecoveryProximityPlacementGroupId; if (!this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.RecoveryCloudServiceId))) { recoveryCloudServiceId = providerSpecificDetails.RecoveryCloudService; } if (!this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.RecoveryBootDiagStorageAccountId))) { this.RecoveryBootDiagStorageAccountId = providerSpecificDetails.RecoveryBootDiagStorageAccountId; } if (!this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.TfoAzureVMName))) { this.TfoAzureVMName = providerSpecificDetails.TfoAzureVMName; } if (!this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.Name))) { vmName = providerSpecificDetails.RecoveryAzureVMName; } List <A2AVmManagedDiskUpdateDetails> managedDiskUpdateDetails = null; // ManagedDisk case if (this.AzureToAzureUpdateReplicationConfiguration == null && providerSpecificDetails.ProtectedManagedDisks != null) { managedDiskUpdateDetails = new List <A2AVmManagedDiskUpdateDetails>(); foreach (var managedDisk in providerSpecificDetails.ProtectedManagedDisks) { managedDiskUpdateDetails.Add( new A2AVmManagedDiskUpdateDetails( managedDisk.DiskId, managedDisk.RecoveryTargetDiskAccountType, managedDisk.RecoveryReplicaDiskAccountType, failoverDiskName: managedDisk.FailoverDiskName, tfoDiskName: managedDisk.TfoDiskName)); } } else if (this.AzureToAzureUpdateReplicationConfiguration != null && this.AzureToAzureUpdateReplicationConfiguration[0].IsManagedDisk) { managedDiskUpdateDetails = new List <A2AVmManagedDiskUpdateDetails>(); foreach (var managedDisk in this.AzureToAzureUpdateReplicationConfiguration) { managedDiskUpdateDetails.Add( new A2AVmManagedDiskUpdateDetails( managedDisk.DiskId, managedDisk.RecoveryTargetDiskAccountType, managedDisk.RecoveryReplicaDiskAccountType, failoverDiskName: managedDisk.FailoverDiskName, tfoDiskName: managedDisk.TfoDiskName, diskEncryptionInfo: Utilities.A2AEncryptionDetails( managedDisk.DiskEncryptionSecretUrl, managedDisk.DiskEncryptionVaultId, managedDisk.KeyEncryptionKeyUrl, managedDisk.KeyEncryptionVaultId))); } } providerSpecificInput = new A2AUpdateReplicationProtectedItemInput() { RecoveryCloudServiceId = this.RecoveryCloudServiceId, RecoveryResourceGroupId = this.RecoveryResourceGroupId, RecoveryProximityPlacementGroupId = this.RecoveryProximityPlacementGroupId, RecoveryBootDiagStorageAccountId = this.RecoveryBootDiagStorageAccountId, ManagedDiskUpdateDetails = managedDiskUpdateDetails, TfoAzureVMName = this.TfoAzureVMName, DiskEncryptionInfo = Utilities.A2AEncryptionDetails( this.DiskEncryptionSecretUrl, this.DiskEncryptionVaultId, this.KeyEncryptionKeyUrl, this.KeyEncryptionVaultId) }; if (this.ASRVMNicConfiguration != null && this.ASRVMNicConfiguration.Count() > 0) { var recoveryNetworkIds = new HashSet <string>(); var tfoNetworkIds = new HashSet <string>(); this.ASRVMNicConfiguration.ForEach( nic => { if (!string.IsNullOrEmpty(nic.RecoveryVMNetworkId)) { recoveryNetworkIds.Add(nic.RecoveryVMNetworkId); } }); this.ASRVMNicConfiguration.ForEach( nic => { if (!string.IsNullOrEmpty(nic.TfoVMNetworkId)) { tfoNetworkIds.Add(nic.TfoVMNetworkId); } }); if (recoveryNetworkIds.Count() > 1) { this.WriteWarning(Resources.RecoveryNetworkIdConflictInASRVMNics); return; } if (tfoNetworkIds.Count() > 1) { this.WriteWarning(Resources.TfoNetworkIdConflictInASRVMNics); return; } if (!string.IsNullOrEmpty(this.RecoveryNetworkId) && !string.IsNullOrEmpty(recoveryNetworkIds.FirstOrDefault()) && !this.RecoveryNetworkId.Equals( recoveryNetworkIds.First(), StringComparison.OrdinalIgnoreCase)) { this.WriteWarning(Resources.RecoveryNetworkInformationMismatch); return; } if (!string.IsNullOrEmpty(recoveryNetworkIds.FirstOrDefault())) { vmRecoveryNetworkId = recoveryNetworkIds.First(); } tfoNetworkId = tfoNetworkIds.FirstOrDefault(); } if (string.IsNullOrEmpty(tfoNetworkId)) { tfoNetworkId = providerSpecificDetails.SelectedTfoAzureNetworkId; } vMNicInputDetailsList = getNicListToUpdate(providerSpecificDetails.VmNics); } var updateReplicationProtectedItemInputProperties = new UpdateReplicationProtectedItemInputProperties { RecoveryAzureVMName = vmName, RecoveryAzureVMSize = vmSize, SelectedRecoveryAzureNetworkId = vmRecoveryNetworkId, SelectedTfoAzureNetworkId = tfoNetworkId, SelectedSourceNicId = primaryNic, VmNics = vMNicInputDetailsList, LicenseType = licenseType == Management.RecoveryServices.SiteRecovery.Models.LicenseType .NoLicenseType.ToString() ? Management.RecoveryServices.SiteRecovery.Models.LicenseType .NoLicenseType : Management.RecoveryServices.SiteRecovery.Models.LicenseType .WindowsServer, RecoveryAvailabilitySetId = availabilitySetId, ProviderSpecificDetails = providerSpecificInput }; if (provider is HyperVReplicaAzureReplicationDetails || provider is InMageAzureV2ReplicationDetails) { updateReplicationProtectedItemInputProperties.SelectedSourceNicId = primaryNic; } var input = new UpdateReplicationProtectedItemInput { Properties = updateReplicationProtectedItemInputProperties }; var response = this.RecoveryServicesClient.UpdateVmProperties( Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationFabrics), Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationProtectionContainers), this.InputObject.Name, input); var jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); this.WriteObject(new ASRJob(jobResponse)); } }
/// <summary> /// ProcessRecord of the command. /// </summary> public override void ExecuteSiteRecoveryCmdlet() { base.ExecuteSiteRecoveryCmdlet(); if (this.ShouldProcess( this.InputObject.FriendlyName, VerbsCommon.Set)) { var replicationProtectedItemResponse = this.RecoveryServicesClient .GetAzureSiteRecoveryReplicationProtectedItem( Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationFabrics), Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationProtectionContainers), this.InputObject.Name); var provider = replicationProtectedItemResponse.Properties.ProviderSpecificDetails; // Check for Replication Provider type HyperVReplicaAzure/InMageAzureV2 if (!(provider is HyperVReplicaAzureReplicationDetails) && !(provider is InMageAzureV2ReplicationDetails)) { this.WriteWarning( Resources.UnsupportedReplicationProvidedForUpdateVmProperties); return; } // Check for at least one option if (string.IsNullOrEmpty(this.Name) && string.IsNullOrEmpty(this.Size) && string.IsNullOrEmpty(this.PrimaryNic) && string.IsNullOrEmpty(this.RecoveryNetworkId) && string.IsNullOrEmpty(this.RecoveryResourceGroupId) && string.IsNullOrEmpty(this.LicenseType)) { this.WriteWarning(Resources.ArgumentsMissingForUpdateVmProperties); return; } // Both primary & recovery inputs should be present if (string.IsNullOrEmpty(this.PrimaryNic) ^ string.IsNullOrEmpty(this.RecoveryNetworkId)) { this.WriteWarning(Resources.NetworkArgumentsMissingForUpdateVmProperties); return; } var vmName = this.Name; var vmSize = this.Size; var vmRecoveryNetworkId = this.RecoveryNetworkId; var licenseType = this.LicenseType; var recoveryResourceGroupId = this.RecoveryResourceGroupId; var vMNicInputDetailsList = new List <VMNicInputDetails>(); VMNicDetails vMNicDetailsToBeUpdated; var providerSpecificInput = new UpdateReplicationProtectedItemProviderInput(); if (provider is HyperVReplicaAzureReplicationDetails) { var providerSpecificDetails = (HyperVReplicaAzureReplicationDetails)replicationProtectedItemResponse .Properties.ProviderSpecificDetails; if (string.IsNullOrEmpty(this.RecoveryResourceGroupId)) { recoveryResourceGroupId = providerSpecificDetails.RecoveryAzureResourceGroupId; } var deploymentType = Utilities.GetValueFromArmId( providerSpecificDetails.RecoveryAzureStorageAccount, ARMResourceTypeConstants.Providers); if (deploymentType.ToLower() .Contains(Constants.Classic.ToLower())) { providerSpecificInput = new HyperVReplicaAzureUpdateReplicationProtectedItemInput { RecoveryAzureV1ResourceGroupId = recoveryResourceGroupId, RecoveryAzureV2ResourceGroupId = null }; } else { providerSpecificInput = new HyperVReplicaAzureUpdateReplicationProtectedItemInput { RecoveryAzureV1ResourceGroupId = null, RecoveryAzureV2ResourceGroupId = recoveryResourceGroupId }; } if (string.IsNullOrEmpty(this.Name)) { vmName = providerSpecificDetails.RecoveryAzureVMName; } if (string.IsNullOrEmpty(this.Size)) { vmSize = providerSpecificDetails.RecoveryAzureVMSize; } if (string.IsNullOrEmpty(this.RecoveryNetworkId)) { vmRecoveryNetworkId = providerSpecificDetails .SelectedRecoveryAzureNetworkId; } if (string.IsNullOrEmpty(this.LicenseType)) { //licenseType = providerSpecificDetails.LicenseType; } if (!string.IsNullOrEmpty(this.PrimaryNic)) { if (providerSpecificDetails.VmNics != null) { vMNicDetailsToBeUpdated = providerSpecificDetails.VmNics.SingleOrDefault( n => string.Compare( n.NicId, this.PrimaryNic, StringComparison.OrdinalIgnoreCase) == 0); if (vMNicDetailsToBeUpdated != null) { var 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); var vMNicDetailsListRemaining = providerSpecificDetails.VmNics.Where( n => string.Compare( n.NicId, this.PrimaryNic, StringComparison.OrdinalIgnoreCase) != 0); foreach (var 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( Resources.NicNotFoundInVMForUpdateVmProperties); } } } else { VMNicInputDetails vMNicInputDetails; foreach (var nDetails in providerSpecificDetails.VmNics) { vMNicInputDetails = new VMNicInputDetails(); vMNicInputDetails.NicId = nDetails.NicId; vMNicInputDetails.RecoveryVMSubnetName = nDetails.RecoveryVMSubnetName; vMNicInputDetails.ReplicaNicStaticIPAddress = nDetails.ReplicaNicStaticIPAddress; vMNicInputDetails.SelectionType = nDetails.SelectionType; vMNicInputDetailsList.Add(vMNicInputDetails); } } } else if (provider is InMageAzureV2ReplicationDetails) { var providerSpecificDetails = (InMageAzureV2ReplicationDetails)replicationProtectedItemResponse.Properties .ProviderSpecificDetails; if (string.IsNullOrEmpty(this.RecoveryResourceGroupId)) { recoveryResourceGroupId = providerSpecificDetails.RecoveryAzureResourceGroupId; } var deploymentType = Utilities.GetValueFromArmId( providerSpecificDetails.RecoveryAzureStorageAccount, ARMResourceTypeConstants.Providers); if (deploymentType.ToLower() .Contains(Constants.Classic.ToLower())) { providerSpecificInput = new InMageAzureV2UpdateReplicationProtectedItemInput { RecoveryAzureV1ResourceGroupId = recoveryResourceGroupId, RecoveryAzureV2ResourceGroupId = null }; } else { providerSpecificInput = new InMageAzureV2UpdateReplicationProtectedItemInput { RecoveryAzureV1ResourceGroupId = null, RecoveryAzureV2ResourceGroupId = recoveryResourceGroupId }; } if (string.IsNullOrEmpty(this.Name)) { vmName = providerSpecificDetails.RecoveryAzureVMName; } if (string.IsNullOrEmpty(this.Size)) { vmSize = providerSpecificDetails.RecoveryAzureVMSize; } if (string.IsNullOrEmpty(this.RecoveryNetworkId)) { vmRecoveryNetworkId = providerSpecificDetails .SelectedRecoveryAzureNetworkId; } if (string.IsNullOrEmpty(this.LicenseType)) { //licenseType = providerSpecificDetails.LicenseType; } if (!string.IsNullOrEmpty(this.PrimaryNic)) { if (providerSpecificDetails.VmNics != null) { vMNicDetailsToBeUpdated = providerSpecificDetails.VmNics.SingleOrDefault( n => string.Compare( n.NicId, this.PrimaryNic, StringComparison.OrdinalIgnoreCase) == 0); if (vMNicDetailsToBeUpdated != null) { var 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); var vMNicDetailsListRemaining = providerSpecificDetails.VmNics.Where( n => string.Compare( n.NicId, this.PrimaryNic, StringComparison.OrdinalIgnoreCase) != 0); foreach (var 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( Resources.NicNotFoundInVMForUpdateVmProperties); } } } else { VMNicInputDetails vMNicInputDetails; foreach (var nDetails in providerSpecificDetails.VmNics) { vMNicInputDetails = new VMNicInputDetails(); vMNicInputDetails.NicId = nDetails.NicId; vMNicInputDetails.RecoveryVMSubnetName = nDetails.RecoveryVMSubnetName; vMNicInputDetails.ReplicaNicStaticIPAddress = nDetails.ReplicaNicStaticIPAddress; vMNicInputDetails.SelectionType = nDetails.SelectionType; vMNicInputDetailsList.Add(vMNicInputDetails); } } } var updateReplicationProtectedItemInputProperties = new UpdateReplicationProtectedItemInputProperties { RecoveryAzureVMName = vmName, RecoveryAzureVMSize = vmSize, SelectedRecoveryAzureNetworkId = vmRecoveryNetworkId, VmNics = vMNicInputDetailsList, LicenseType = licenseType == Management.RecoveryServices.SiteRecovery.Models.LicenseType .NoLicenseType.ToString() ? Management.RecoveryServices.SiteRecovery.Models.LicenseType .NoLicenseType : Management.RecoveryServices.SiteRecovery.Models.LicenseType .WindowsServer, ProviderSpecificDetails = providerSpecificInput }; var input = new UpdateReplicationProtectedItemInput { Properties = updateReplicationProtectedItemInputProperties }; var response = this.RecoveryServicesClient.UpdateVmProperties( Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationFabrics), Utilities.GetValueFromArmId( this.InputObject.ID, ARMResourceTypeConstants.ReplicationProtectionContainers), this.InputObject.Name, input); var jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); this.WriteObject(new ASRJob(jobResponse)); } }