An Azure native disaster recovery service. Previously known as Microsoft Azure Hyper-V Recovery Manager.
That error typically means the parameters passed to New-AzRecoveryServicesAsrProtectionContainerMapping do not match the Azure-to-Azure (A2A) replication provider requirements. The cmdlet validates that the protection containers, fabrics, and replication policy are all compatible with A2A replication. If any of those objects come from a different provider type, the operation fails with the message that the A2A provider is invalid for the current parameters.
A frequent cause is using a replication policy that was created for a different provider such as Hyper-V or VMware, or retrieving containers from fabrics that are not of type Azure. Another common issue is running the mapping command before setting the Recovery Services vault context, which causes objects to be resolved incorrectly.
Ensure the vault context is set first.
$vault = Get-AzRecoveryServicesVault -Name "MyVault"
Set-AzRecoveryServicesAsrVaultContext -Vault $vault
Retrieve the Azure fabrics and containers.
$fabrics = Get-AzRecoveryServicesAsrFabric | Where-Object {$_.FabricType -eq "Azure"}
$primaryFabric = $fabrics | Where-Object {$_.Location -eq "eastus"}
$recoveryFabric = $fabrics | Where-Object {$_.Location -eq "westus"}
$primaryContainer = Get-AzRecoveryServicesAsrProtectionContainer -Fabric $primaryFabric
$recoveryContainer = Get-AzRecoveryServicesAsrProtectionContainer -Fabric $recoveryFabric
Confirm the replication policy uses the A2A provider.
$policy = Get-AzRecoveryServicesAsrReplicationPolicy | Where-Object {$_.ReplicationProvider -eq "A2A"}
Then create the mapping.
New-AzRecoveryServicesAsrProtectionContainerMapping `
-Name "MyMapping" `
-PrimaryProtectionContainer $primaryContainer `
-RecoveryProtectionContainer $recoveryContainer `
-Policy $policy
If the error still occurs, inspect the objects to confirm the provider types.
$policy.ReplicationProvider
$primaryContainer.FabricFriendlyName
$recoveryContainer.FabricFriendlyName
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin