Edit

Share via


Quickstart: Create a Recovery Services vault by using Bicep

This quickstart shows how to set up a Recovery Services vault by using Bicep. The Azure Site Recovery service helps you maintain your business continuity and disaster recovery (BCDR) strategy, so your business applications stay online during planned and unplanned outages. Site Recovery manages disaster recovery of on-premises machines and Azure virtual machines (VMs), including replication, failover, and recovery.

Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. It provides concise syntax, reliable type safety, and support for code reuse. Bicep offers the best authoring experience for your infrastructure-as-code solutions in Azure.

Prerequisites

If you don't have an active Azure subscription, create a free account.

Review the Bicep file

This quickstart uses a Bicep file from Azure Quickstart Templates.

@description('Name of the Vault')
param vaultName string

@description('Enable CRR (Works if vault has not registered any backup instance)')
param enableCRR bool = true

@description('Change Vault Storage Type (Works if vault has not registered any backup instance)')
@allowed([
  'LocallyRedundant'
  'GeoRedundant'
])
param vaultStorageType string = 'GeoRedundant'

@description('Location for all resources.')
param location string = resourceGroup().location

var skuName = 'RS0'
var skuTier = 'Standard'

resource recoveryServicesVault 'Microsoft.RecoveryServices/vaults@2022-02-01' = {
  name: vaultName
  location: location
  sku: {
    name: skuName
    tier: skuTier
  }
  properties: {}
}

resource vaultName_vaultstorageconfig 'Microsoft.RecoveryServices/vaults/backupstorageconfig@2022-02-01' = {
  parent: recoveryServicesVault
  name: 'vaultstorageconfig'
  properties: {
    storageModelType: vaultStorageType
    crossRegionRestoreFlag: enableCRR
  }
}

The Bicep file defines two Azure resources:

Deploy the Bicep file

  1. Save the Bicep file as main.bicep on your local computer.

  2. Deploy the Bicep file by using either Azure CLI or Azure PowerShell.

    az group create --name exampleRG --location eastus
    az deployment group create --resource-group exampleRG --template-file main.bicep --parameters vaultName=<vault-name>
    

    Note

    Replace <vault-name> with the name of the vault.

    When the deployment finishes, you see a message indicating the deployment succeeded.

Review deployed resources

Use Azure CLI or Azure PowerShell to confirm that the vault was created.

az backup vault show --name <vault-name> --resource-group exampleRG
az backup vault backup-properties show --name <vault-name> --resource-group exampleRG

Note

Replace <vault-name> with the name of the vault you created.

Clean up resources

If you plan to use the new resources, no action is needed. Otherwise, you can remove the resource group and vault that was created in this quickstart. To delete the resource group and its resources, use Azure CLI or Azure PowerShell.

az group delete --name exampleRG

Next steps

In this quickstart, you created a Recovery Services vault by using Bicep. To learn more about disaster recovery, see Set up disaster recovery.