Site Recovery - Powershell "re-protect" via Azure Automation - not working (Azure to Azure)

437 Views Asked by At

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" which start with a re-protect which needs to happen in order to re-replicate traffic from the target back to the source.

From how I understand it, this is done via the cmdlet:

Update-AzRecoveryServicesAsrProtectionDirection

And outlined here for an Azure to Azure deployment: https://learn.microsoft.com/en-us/powershell/module/az.recoveryservices/update-azrecoveryservicesasrprotectiondirection?view=azps-6.3.0

I get an error when running the runbook:

Unsupported replication provider A2A for reprotect

Seems like it is complaining that this process doesn't work for A2A (Azure to Azure) replication. But the link above shows that it should.

Here is my code to build the request:

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

$RP = Get-AzRecoveryServicesAsrRecoveryPlan -Name $RecoveryPlanName

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

Thoughts? I haven't tried to update the direction with an individual workload yet, I need the plan to work if possible.

Thanks!

1

There are 1 best solutions below

0
On

I had the same issue before,

In my script, that line seems like this in the failback script

Update-AzRecoveryServicesAsrProtectionDirection -AzureToAzure -LogStorageAccountId $PrimaryStagingStorageAccount -ProtectionContainerMapping $reverseContainerMapping -RecoveryResourceGroupId $currentVmResourceGroupId -ReplicationProtectedItem $rpi

One of the things I made sure is that lines 50-59 get the output you are looking for, run it line by line to make sure before running the script.

In the variables section on top, make sure the storage account in the failback it will be your primary storage account and in the failover script you are selecting your recovery storage account.

Remember that when you fail over, For reverse replication the roles of the original region and the recovery region switch. Meaning the original region now becomes a new recovery region and viceversa.

The other thing I did was that I created the replication through a powershell script, I didnt do it from the portal to avoid Azure creating a default one for me.

You can review it here and I hope that works for you: https://raw.githubusercontent.com/oortizmcp/Automating-DR/main/scripts/Failback-Reprotect-RP_V2.ps1