Update backup storage redundancy for Azure Cosmos DB periodic backup accounts

APPLIES TO: NoSQL MongoDB Cassandra Gremlin Table

By default, Azure Cosmos DB stores periodic mode backup data in geo-redundant blob storage that is replicated to a paired region. You can override the default backup storage redundancy. This article explains how to update the backup storage redundancy using Azure CLI and PowerShell. It also shows how to configure an Azure policy on your accounts to enforce the required storage redundancy.

Update using Azure portal

Use the following steps to update backup storage redundancy from the Azure portal:

  1. Sign into the Azure portal and navigate to your Azure Cosmos DB account.

  2. Open the Backup & Restore pane, update the backup storage redundancy and select Submit. It takes few minutes for the operation to complete:

    Update backup storage redundancy from the Azure portal

Update using CLI

Use the following steps to update the backup storage redundancy on an existing account using Azure CLI:

  1. Install the latest version if Azure CLI or a version higher than or equal to 2.30.0. If you have the "cosmosdb-preview" extension installed, make sure to remove it.

  2. Use the following command to get the backup redundancy options available in the regions where your account exists:

    az cosmosdb locations show --location <region_Name>
    
     {
      "id": "subscriptionId/<Subscription_ID>/providers/Microsoft.DocumentDB/locations/eastus/",
      "name": "East US",
      "properties": {
        "backupStorageRedundancies": [
          "Geo",
          "Zone",
          "Local"
        ],
        "isResidencyRestricted": false,
        "supportsAvailabilityZone": true
      },
      "type": "Microsoft.DocumentDB/locations"
     }
    

    The previous command shows a list of backup redundancies available in the specific region. Supported values are displayed in the backupStorageRedundancies property. For example some regions such as "East US" support three redundancy options "Geo", "Zone", and "Local" whereas some regions like "UAE North" support only "Geo" and "Local" redundancy options. Before updating, choose the backup storage redundancy option that is supported in all the regions where your account exists.

  3. Run the following command with the chosen backup redundancy option to update the backup redundancy on an existing account:

    az cosmosdb update -n <account_Name> -g <resource_Group> --backup-redundancy "Geo"
    
  4. Run the following command to create a new account with the chosen backup redundancy option:

    az cosmosdb create -n <account_Name> -g <resource_Group> --backup-redundancy "Geo" --locations regionName=westus
    

Update using PowerShell

  1. Install the latest version of Azure PowerShell or a version higher than or equal to 1.4.0

    Install-Module -Name Az.CosmosDB -RequiredVersion 1.4.0
    
  2. Use the following command to get the backup redundancy options available in the regions where your account exists:

    $location = Get-AzCosmosDBLocation -Location <region_Name>
    $location.Properties.BackupStorageRedundancies
    

    The previous command shows a list of backup redundancies available in the specific region. Supported values are displayed in the backupStorageRedundancies property. For example some regions such as "East US" support three redundancy options "Geo", "Zone", and "Local" whereas some regions like "UAE North" support only "Geo" and "Local" redundancy options. Before updating, choose the backup storage redundancy option that is supported in all the regions where your account exists.

  3. Run the following command with the chosen backup redundancy option to update the backup redundancy on an existing account:

    Update-AzCosmosDBAccount `
    -Name <account_Name> `
    -ResourceGroupName <resource_Group> `
    -BackupStorageRedundancy "Geo"
    
  4. Run the following command to create a new account with the chosen backup redundancy option:

    New-AzCosmosDBAccount `
     -Name <account_Name> `
     -ResourceGroupName <resource_Group> `
     -Location <region_Name> `
     -BackupPolicyType Periodic`
     -BackupStorageRedundancy "Geo"
    
    

Add a policy for the backup storage redundancy

Azure Policy helps you to enforce organizational standards and to assess compliance at-scale. The following sample shows how to add an Azure policy for the database accounts to have a backup redundancy of type "Zone".

"parameters": {},
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "Microsoft.DocumentDB/databaseAccounts/backupPolicy.periodicModeProperties.backupStorageRedundancy",
            "match": "Zone"
          }
        ]
      },
      "then": {
        "effect": "audit"
      }
    }

Next steps