I'm currently backing up Azure VMs via Azure CLI:

create resource group:

az group create -n backup-resource-group -l uksouth

create recovery services vault:

az backup vault create --resource-group backup-resource-group --name backup --location uksouth

loop VMs to create backup jobs:

az backup protection enable-for-vm --resource-group backup-resource-group --vault-name backup --vm $(az vm show -g servers-resource-group -n {{ loopedoutvm }} --query id | tr -d '"') --policy-name DefaultPolicy

This works fine, but only backs up VMs in the same Azure region. I'd like to adjust this to store the backups in a different region (in addition to the same region the VMs run in). If I run this again with a new resource group and vault created in a different region, Azure returns a message that recovery service vaults can only contain VMs from that location.

Which is strange, because in the Azure portal, it seems I can replicate VM backups to other regions (either via: some VM > disaster recovery > advanced, or via: some recovery services vault > replicate). But I don't know how to achieve this (or something similar) via Azure CLI in order to automate it. There doesn't seem to be anything in Microsoft's documentation for doing this with CLI.

If anyone could point me in the right direction it would be hugely appreciated.


As you mentioned, you can't attach a VM to a recovery vault in a different region. What you do is use a vault in the VM's region, then enable geo-redundancy on teh vault to replicate your backups to another region.

enter image description here

  • Thanks, this is really helpful actually - pointed me to docs.microsoft.com/en-us/cli/azure/backup/vault/…, which shows how to set via CLI - az backup vault backup-properties set --backup-storage-redundancy GeoRedundant. Though it actually seems to default to geo-redundant anyway, and I think the option I actually want is Cross Region Restore (below replication type option, but not shown in your screenshot). For that, there doesn't seem to be a CLI option unfortunately, or at least not yet been documented. – Sam Jun 30 '20 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.