Gallery › Backup › Azure built-in policies
[Preview]: Configure vaulted backup with auto-protection for blobs on storage accounts without a given tag to a backup vault
Converted Policy AuditIfNotExists DeployIfNotExists Disabled Mode Indexed Version 1.0.0-preview Preview
Enforce vaulted backup with auto-protection for blobs on all storage accounts that do not contain a given tag to a central backup vault. Auto-protection backs up all blob containers in the storage account, including containers created in the future. Doing this can help you manage vaulted backup of blobs contained across multiple storage accounts at scale. For more details, refer to https://aka.ms/AB-BlobBackupAzPolicies
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
{
"properties": {
"displayName": "[Preview]: Configure vaulted backup with auto-protection for blobs on storage accounts without a given tag to a backup vault",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Enforce vaulted backup with auto-protection for blobs on all storage accounts that do not contain a given tag to a central backup vault. Auto-protection backs up all blob containers in the storage account, including containers created in the future. Doing this can help you manage vaulted backup of blobs contained across multiple storage accounts at scale. For more details, refer to https://aka.ms/AB-BlobBackupAzPolicies",
"metadata": {
"version": "1.0.0-preview",
"preview": true,
"category": "Backup"
},
"version": "1.0.0-preview",
"parameters": {
"vaultLocation": {
"type": "String",
"metadata": {
"displayName": "Location (Specify the location of the storage accounts that you want to protect)",
"description": "Specify the location of the storage accounts that you want to protect. Blobs in the storage accounts should be backed up to a vault in the same location. For example - CanadaCentral",
"strongType": "location"
}
},
"backupPolicyId": {
"type": "String",
"metadata": {
"displayName": "Backup Policy (of type Azure Blobs (Azure Storage) from a vault in the location chosen above)",
"description": "Specify the ID of the backup policy to be used for configuring vaulted backup for blobs. The selected Azure Backup policy should be of type Azure Blobs (Azure Storage) and should support vaulted backup. This policy needs to be in a vault that is present in the location chosen above. For example - /subscriptions/<SubscriptionId>/resourceGroups/<resourceGroupName>/providers/Microsoft.DataProtection/vaults/<VaultName>/backupPolicies/<BackupPolicyName>. Also, make sure that this Backup vault's managed identity has the Storage Account Backup Contributor role assigned on the storage accounts for which backup is to be configured."
}
},
"exclusionTagName": {
"type": "String",
"metadata": {
"displayName": "Exclusion Tag Name",
"description": "Name of the tag to use for excluding storage accounts in the scope of this policy. This should be used along with the Exclusion Tag Value parameter. Learn more at https://aka.ms/AB-BlobBackupAzPolicies"
}
},
"exclusionTagValues": {
"type": "Array",
"metadata": {
"displayName": "Exclusion Tag Values",
"description": "Value of the tag to use for excluding storage accounts in the scope of this policy (in case of multiple values, use a comma-separated list). This should be used along with the Exclusion Tag Name parameter. Learn more at https://aka.ms/AB-BlobBackupAzPolicies."
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"DeployIfNotExists",
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Storage/storageAccounts"
},
{
"field": "kind",
"equals": "StorageV2"
},
{
"field": "Microsoft.Storage/storageAccounts/sku.name",
"contains": "Standard"
},
{
"field": "Microsoft.Storage/storageAccounts/isHnsEnabled",
"notEquals": "true"
},
{
"field": "Microsoft.Storage/storageAccounts/isNfsV3Enabled",
"notEquals": "true"
},
{
"field": "location",
"equals": "[parameters('vaultLocation')]"
},
{
"anyOf": [
{
"not": {
"field": "[concat('tags[', parameters('exclusionTagName'), ']')]",
"in": "[parameters('exclusionTagValues')]"
}
},
{
"value": "[empty(parameters('exclusionTagValues'))]",
"equals": "true"
},
{
"value": "[empty(parameters('exclusionTagName'))]",
"equals": "true"
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.DataProtection/backupInstances",
"evaluationDelay": "AfterProvisioning",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/5e467623-bb1f-42f4-a55d-6e525e11384b"
],
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"backupPolicyId": {
"type": "string",
"metadata": {
"description": "Backup Policy Id"
}
},
"storageAccountResourceId": {
"type": "string",
"metadata": {
"description": "ResourceId of the Storage Account"
}
},
"location": {
"type": "string",
"metadata": {
"description": "Location for all resources"
}
}
},
"variables": {
"storageAccountName": "[first(skip(split(parameters('storageAccountResourceId'), '/'), 8))]",
"dataSourceType": "Microsoft.Storage/storageAccounts/blobServices",
"resourceType": "Microsoft.Storage/storageAccounts",
"backupPolicyName": "[first(skip(split(parameters('backupPolicyId'), '/'), 10))]",
"vaultName": "[first(skip(split(parameters('backupPolicyId'), '/'), 8))]",
"vaultResourceGroup": "[first(skip(split(parameters('backupPolicyId'), '/'), 4))]",
"vaultSubscriptionId": "[first(skip(split(parameters('backupPolicyId'), '/'), 2))]"
},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2021-04-01",
"resourceGroup": "[variables('vaultResourceGroup')]",
"subscriptionId": "[variables('vaultSubscriptionId')]",
"name": "[concat('DeployProtection-',uniqueString(variables('storageAccountName')))]",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"resources": [
{
"type": "Microsoft.DataProtection/backupvaults/backupInstances",
"apiVersion": "2026-03-01",
"name": "[concat(variables('vaultName'), '/', variables('storageAccountName'))]",
"properties": {
"objectType": "BackupInstance",
"friendlyName": "[variables('storageAccountName')]",
"dataSourceInfo": {
"objectType": "Datasource",
"resourceID": "[parameters('storageAccountResourceId')]",
"resourceName": "[variables('storageAccountName')]",
"resourceType": "[variables('resourceType')]",
"resourceUri": "[parameters('storageAccountResourceId')]",
"resourceLocation": "[parameters('location')]",
"datasourceType": "[variables('dataSourceType')]"
},
"dataSourceSetInfo": {
"objectType": "DatasourceSet",
"resourceID": "[parameters('storageAccountResourceId')]",
"resourceName": "[variables('storageAccountName')]",
"resourceType": "[variables('resourceType')]",
"resourceUri": "[parameters('storageAccountResourceId')]",
"resourceLocation": "[parameters('location')]",
"datasourceType": "[variables('dataSourceType')]"
},
"policyInfo": {
"policyId": "[parameters('backupPolicyId')]",
"name": "[variables('backupPolicyName')]",
"policyParameters": {
"backupDatasourceParametersList": [
{
"objectType": "BlobBackupDatasourceParametersForAutoProtection",
"autoProtectionSettings": {
"objectType": "BlobBackupRuleBasedAutoProtectionSettings",
"enabled": true,
"rules": []
}
}
]
}
}
}
}
]
}
}
}
]
},
"parameters": {
"storageAccountResourceId": {
"value": "[field('id')]"
},
"backupPolicyId": {
"value": "[parameters('backupPolicyId')]"
},
"location": {
"value": "[field('location')]"
}
}
}
}
}
}
},
"versions": [
"1.0.0-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/e876c60c-da8a-46eb-a85e-54d791446f6b",
"name": "e876c60c-da8a-46eb-a85e-54d791446f6b"
}# Converted from BlobVaultedBackupAutoProtectForStorageAccountsWithoutTag_DINE.json by ConvertTo-Bylaw.
Policy 'e876c60c-da8a-46eb-a85e-54d791446f6b' {
Properties @{
DisplayName = '[Preview]: Configure vaulted backup with auto-protection for blobs on storage accounts without a given tag to a backup vault'
Description = 'Enforce vaulted backup with auto-protection for blobs on all storage accounts that do not contain a given tag to a central backup vault. Auto-protection backs up all blob containers in the storage account, including containers created in the future. Doing this can help you manage vaulted backup of blobs contained across multiple storage accounts at scale. For more details, refer to https://aka.ms/AB-BlobBackupAzPolicies'
Version = '1.0.0-preview'
Preview = $true
Category = 'Backup'
PolicyVersion = '1.0.0-preview'
Mode = 'Indexed'
}
Parameter VaultLocation @{
Type = 'String'
DisplayName = 'Location (Specify the location of the storage accounts that you want to protect)'
Description = 'Specify the location of the storage accounts that you want to protect. Blobs in the storage accounts should be backed up to a vault in the same location. For example - CanadaCentral'
Metadata = [ordered]@{ strongType = 'location' }
}
Parameter BackupPolicyId @{
Type = 'String'
DisplayName = 'Backup Policy (of type Azure Blobs (Azure Storage) from a vault in the location chosen above)'
Description = 'Specify the ID of the backup policy to be used for configuring vaulted backup for blobs. The selected Azure Backup policy should be of type Azure Blobs (Azure Storage) and should support vaulted backup. This policy needs to be in a vault that is present in the location chosen above. For example - /subscriptions/<SubscriptionId>/resourceGroups/<resourceGroupName>/providers/Microsoft.DataProtection/vaults/<VaultName>/backupPolicies/<BackupPolicyName>. Also, make sure that this Backup vault''s managed identity has the Storage Account Backup Contributor role assigned on the storage accounts for which backup is to be configured.'
}
Parameter ExclusionTagName @{
Type = 'String'
DisplayName = 'Exclusion Tag Name'
Description = 'Name of the tag to use for excluding storage accounts in the scope of this policy. This should be used along with the Exclusion Tag Value parameter. Learn more at https://aka.ms/AB-BlobBackupAzPolicies'
}
Parameter ExclusionTagValues @{
Type = 'Array'
DisplayName = 'Exclusion Tag Values'
Description = 'Value of the tag to use for excluding storage accounts in the scope of this policy (in case of multiple values, use a comma-separated list). This should be used along with the Exclusion Tag Name parameter. Learn more at https://aka.ms/AB-BlobBackupAzPolicies.'
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'AuditIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Storage/storageAccounts' {
When {
Field kind | Must -Be 'StorageV2'
Field sku.name | Must -ContainText 'Standard'
Field isHnsEnabled | Must -Not -Be 'true'
Field isNfsV3Enabled | Must -Not -Be 'true'
Field location | Must -Be (Param VaultLocation)
}
Require 'tag (Param ExclusionTagName) is one of the ExclusionTagValues parameter' {
Tag (Param ExclusionTagName) | Must -BeIn (Param ExclusionTagValues)
}
Require 'Requirement 2' {
Arm '[empty(parameters(''exclusionTagValues''))]' | Must -Not -Be 'true'
}
Require 'Requirement 3' {
Arm '[empty(parameters(''exclusionTagName''))]' | Must -Not -Be 'true'
}
}
DeployIfNotExists 'Microsoft.DataProtection/backupInstances' -Role 'Backup Contributor' -EvaluationDelay AfterProvisioning -Effect (Param Effect) {
Deployment -TemplateFile './templates/e876c60c-da8a-46eb-a85e-54d791446f6b.json' -Parameters ([ordered]@{
storageAccountResourceId = (Arm '[field(''id'')]')
backupPolicyId = (Param BackupPolicyId)
location = (Arm '[field(''location'')]')
})
}
}Its deployment templates are written beside it:
templates/e876c60c-da8a-46eb-a85e-54d791446f6b.json
Source: built-in-policies/policyDefinitions/Backup/BlobVaultedBackupAutoProtectForStorageAccountsWithoutTag_DINE.json in Azure/azure-policy, under the MIT licence.
Bylaw