Azure / Azure/azure-powershell

https://learn.microsoft.com/en-us/powershell/module/az.recoveryservices/update-azrecoveryservicesasrprotectiondirection?view=azps-12.1.0&viewFallbackFrom=azps-6.3.0[Doc]:

Open
#25,530 4 comments 0 reactions 0 assignees View on GitHub
customer-reported Doc - Reference Recovery Services Site-Recovery Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### Type of issue

Code doesn't work

### Feedback

I've created a simple runbook in Azure Automation to kick off a failover in site recovery referencing a recovery plan. Failover works fine, the issue comes to when I need to "failback". This starts with a re-protect to re-replicate traffic from the backup region back to the source region. In the Azure GUI, this is performed via the "Re-Protect" button in the Recovery Plan. In PowerShell, this re-protect should be performed with the cmdlet:

Update-AzRecoveryServicesAsrProtectionDirection

Following this documentation:
https://docs.microsoft.com/en-us/powershell/module/az.recoveryservices/update-azrecoveryservicesasrprotectiondirection?view=azps-6.3.0

Steps to reproduce
The following code is being used to attempt to initiate a re-protection action, this is done post failover from primary region to backup region:

$vault = Get-AzRecoveryServicesVault -Name $RecoveryVaultName -ResourceGroupName $RecoveryVaultRG
Set-AzRecoveryServicesAsrVaultContext -Vault $vault

$RP = Get-AzRecoveryServicesAsrRecoveryPlan -Name $RecoveryPlanName

$job = Update-AzRecoveryServicesAsrProtectionDirection -RecoveryPlan $RP -Direction RecoveryToPrimary

### Page URL

https://learn.microsoft.com/en-us/powershell/module/az.recoveryservices/update-azrecoveryservicesasrprotectiondirection?view=azps-12.1.0&viewFallbackFrom=azps-6.3.0

### Content source URL

_No response_

### Author

_No response_

### Document Id

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.