I'm having a problem restoring a gen 1 Azure VM to a new (gen 1) VM. This new VM will exist in a different resource group (in a different Azure location), and that resource group contains the virtual network for the new VM. As you can see in the code below (written in PowerShell), I'm getting the most recent recovery point from the recovery services vault in question, and then using that for the restore operation.
# Get the most recent recovery point name
[string]$rpName = az backup recoverypoint list --resource-group $vm.resourceGroup `
--vault-name $vm.vaultName `
--backup-management-type 'AzureIaasVM' `
--container-name $vm.vmName `
--item-name $vm.vmName `
--query '[0].name' `
--output 'tsv'
Write-Output "Restoring $($vm.vmName) to $($vm.targetVmName)"
az backup restore restore-disks --resource-group $vm.resourceGroup `
--vault-name $vm.vaultName `
--container-name $vm.vmName `
--item-name $vm.vmName `
--restore-mode 'AlternateLocation' `
--storage-account $storageAccountName `
--storage-account-resource-group $storageAccountRg `
--target-resource-group $vm.targetVnetResourceGroup `
--rp-name $rpName `
--target-vm-name $vm.targetVmName `
--target-vnet-name $vm.targetVnetName `
--target-vnet-resource-group $vm.targetVnetResourceGroup `
--target-subnet-name $vm.targetSubnetName
This will kick off a restore that I can monitor in the Backup Center. After about 20 minutes, the restore status will change to Completed with warnings. If I drill into the backup job, the error code I see is CloudInternalError with the following warning message: Microsoft Azure Backup encountered an internal error.
The job itself consists of 2 sub-tasks:
- Transfer data from vault.
- Create the restored virtual machine
The first step completes, but the second is where the error happens. The storage account being used for the restore is a Standard_LRS, StorageV2 account.
Where am I going wrong here?
I managed to figure out the issue with the restore. So the issue here is that the storage account and virtual network were both in a region that wasn't the failover / secondary region for the one that the original VM resides. So, in this case, since the VM and Recovery Services Vault lived in
East US 2, the infrastructure for the new VM either has also live inEast US 2or the paired region, which isCentral US.So, if I recreate my infrastructure in the
Central USregion, and add the--use-secondary-regionflag to theaz backup restore restore-diskscall, then the restore both registers correctly as a Cross Region restore in the Backup Center, and it completes successfully. Note that Cross Region restore must be enabled in the Recovery Services Vault for this to work.