New-AzureRmSiteRecoveryPolicy Internal Error
Cmdlet(s)
PowerShell Version
5.1.15063.296
Module Version
4.1.0
OS Version
10.0.15063.296
Description
I'm executing the following commands:
$SelectedRecoveryVault = Get-AzureRmRecoveryServicesVault -ResourceGroupName myresourcegroup
Set-AzureRmSiteRecoveryVaultSettings -ARSVault $SelectedRecoveryVault -ErrorAction Stop
$StorageAccountID = Get-AzureRmStorageAccount -Name mystorageaccount -ResourceGroupName myresourcegroup | Select -ExpandProperty Id
New-AzureRmSiteRecoveryPolicy -Name TestPSPOL10 -ReplicationProvider HyperVReplicaAzure -ReplicationFrequencyInSeconds 300 -RecoveryPoints 5 -ApplicationConsistentSnapshotFrequencyInHours 3 -RecoveryAzureStorageAccountId $StorageAccountID
I am not getting any errors in PowerShell itself, but when I take a look at the Site Recovery jobs in Azure (Or in PowerShell) the job has failed:
ERROR ID 499 ERROR MESSAGE An internal error occurred. POSSIBLE CAUSES The operation failed due to an internal error. RECOMMENDATION Retry the last action. If the issue persists, contact Support.
If I execute the above command not utilizing the -RecoveryAzureStorageAccountId parameter it works without issue.
Script/Steps for Reproduction
Execute the above commands against a recovery vault.
After some additional troubleshooting when I ran into another issue it appears that I had a bunch of conflicting versions of Azure PowerShell which caused this issue to occur.
However, I am still a bit confused. I am able to run the command both with and without
-RecoveryAzureStorageAccountId
What exactly is the point of that if it is not required? I also do not see Storage Account when you add a Replication Policy within the portal. Is this something that's been deprecated and the switch just hasn't been removed?
I just had the same issue, different error but removing RecoveryAzureStorageAccountId from the list of parameters and the command runs fine.
I am using AzureRM.SiteRecovery v 4.2.1 side-by-side with 2.1.0.
$SiteRecoveryPolicy = New-AzureRmSiteRecoveryPolicy -Name $PolicyName -ReplicationFrequencyInSeconds $ReplicationFreq -RecoveryPoints $RecoveryPoints -ReplicationProvider HyperVReplicaAzure -ApplicationConsistentSnapshotFrequencyInHours 1
# -RecoveryAzureStorageAccountId $StorAcctName
This conflicting version issue should be resolved by tthe consolidation of RecoveryServices* modules. Assigning to @dragonfly91
Please use the command provided at https://docs.microsoft.com/en-us/powershell/module/azurerm.siterecovery/new-azurermsiterecoverypolicy?view=azurermps-5.7.0
$SelectedRecoveryVault = Get-AzRecoveryServicesVault -ResourceGroupName myresourcegroup Set-ASRVaultContext -Vault $SelectedRecoveryVault -ErrorAction Stop
$StorageAccountID = Get-AzStorageAccount -Name mystorageaccount -ResourceGroupName myresourcegroup | Select -ExpandProperty Id
https://docs.microsoft.com/en-us/powershell/module/AzureRM.RecoveryServices.SiteRecovery/New-AzureRmRecoveryServicesAsrPolicy?view=azurermps-6.13.0
$currentJob = New-AzRecoveryServicesAsrPolicy -Name $ProtectionProfileName -ReplicationProvider HyperVReplicaAzure -ReplicationFrequencyInSeconds 30 -RecoveryPoints 1 -ApplicationConsistentSnapshotFrequencyInHours 0 -RecoveryAzureStorageAccountId $StorageAccountID