Gallery › Backup › Azure built-in policies
[Preview]: Configure backup for Azure Files Shares without a given tag to an existing recovery services vault in the same location
Doesn't convert yet Policy AuditIfNotExists DeployIfNotExists Disabled Mode All Version 2.0.0-preview Preview
Enforce backup for all Azure Files by backing them up to an existing central Recovery Services vault in the same region as the storage account. The vault can be in the same or a different subscription. This is useful when a central team manages backups across subscriptions. You can optionally exclude Azure Files in storage accounts with a specified tag to control the scope of the policy assignment.
ConvertTo-Bylaw can't convert this policy yet:
- BYL6003 The converted file doesn't compile, which is a ConvertTo-Bylaw bug: BYL3002: DisplayName is 130 characters; Azure allows at most 128.
Azure Policy JSONFileShare_EnableAzureBackupWithoutTag_DINE.json · 248 lines
{
"properties": {
"displayName": "[Preview]: Configure backup for Azure Files Shares without a given tag to an existing recovery services vault in the same location",
"policyType": "BuiltIn",
"mode": "All",
"description": "Enforce backup for all Azure Files by backing them up to an existing central Recovery Services vault in the same region as the storage account. The vault can be in the same or a different subscription. This is useful when a central team manages backups across subscriptions. You can optionally exclude Azure Files in storage accounts with a specified tag to control the scope of the policy assignment.",
"metadata": {
"version": "2.0.0-preview",
"preview": true,
"category": "Backup"
},
"version": "2.0.0-preview",
"parameters": {
"registerStorageAccount": {
"type": "Boolean",
"metadata": {
"displayName": "Register Storage Account",
"description": "Set to true if the existing Storage Account has to be registered to the Recovery Services Vault; set to false otherwise."
},
"defaultValue": false
},
"vaultLocation": {
"type": "String",
"metadata": {
"displayName": "Location (Specify the location of the FileShares that you want to protect)",
"description": "Location of the FileShares. The FileShares should be in the same location as the vault."
}
},
"backupPolicyId": {
"type": "String",
"metadata": {
"displayName": "Backup Policy Id (of type Azure FileShare from a Recovery Services Vault in the location chosen above)",
"description": "Specify the Id of the Azure Backup policy to configure backup of the file shares. The selected Azure Backup policy should be of type Azure File Share. This policy needs to be in a vault that is present in the location chosen above. For example - /subscriptions/<SubscriptionId>/resourceGroups/<resourceGroupName>/providers/Microsoft.RecoveryServices/vaults/<VaultName>/backupPolicies/<BackupPolicyName>"
}
},
"exclusionTagName": {
"type": "String",
"metadata": {
"displayName": "Exclusion Tag Name",
"description": "Name of the tag to use for excluding FileShares in the scope of this policy. This should be used along with the Exclusion Tag Value parameter."
},
"defaultValue": ""
},
"exclusionTagValue": {
"type": "Array",
"metadata": {
"displayName": "Exclusion Tag Values",
"description": "Value of the tag to use for excluding FileShares 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."
},
"defaultValue": []
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"AuditIfNotExists",
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Storage/storageAccounts/fileServices/shares"
},
{
"field": "location",
"equals": "[parameters('vaultLocation')]"
},
{
"anyOf": [
{
"not": {
"field": "[concat('tags[', parameters('exclusionTagName'), ']')]",
"in": "[parameters('exclusionTagValue')]"
}
},
{
"value": "[empty(parameters('exclusionTagValue'))]",
"equals": "true"
},
{
"value": "[empty(parameters('exclusionTagName'))]",
"equals": "true"
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.RecoveryServices/backupprotecteditems",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/17d1049b-9a84-46fb-8f53-869881c3d3ab",
"/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": {
"registerStorageAccount": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Set to true if the existing Storage Account needs to be registered to the Recovery Services Vault; set to false otherwise."
}
},
"existingStorageAccountArmId": {
"type": "string",
"metadata": {
"description": "Existing Storage Account ARM Id."
}
},
"existingResourceGroupName": {
"type": "string",
"metadata": {
"description": "Existing Resource Group Name."
}
},
"existingFileShareName": {
"type": "string",
"metadata": {
"description": "Existing File Share Name."
}
},
"backupPolicyId": {
"type": "string",
"metadata": {
"description": "Backup Policy Id."
}
},
"existingStorageAccountName": {
"type": "string",
"metadata": {
"description": "Name of the Storage Account."
}
},
"location": {
"type": "string",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {
"existingStorageAccountArmId": "[parameters('existingStorageAccountArmId')]",
"existingStorageAccountName": "[parameters('existingStorageAccountName')]",
"existingResourceGroupName": "[parameters('existingResourceGroupName')]",
"existingFileShareName": "[parameters('existingFileShareName')]",
"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))]",
"backupFabric": "Azure",
"backupManagementType": "AzureStorage"
},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2021-04-01",
"resourceGroup": "[variables('vaultResourceGroup')]",
"subscriptionId": "[variables('vaultSubscriptionId')]",
"name": "[concat('DeployProtection-', uniqueString(concat(variables('existingStorageAccountName'), variables('existingFileShareName'))))]",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"resources": [
{
"condition": "[parameters('registerStorageAccount')]",
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers",
"apiVersion": "2021-12-01",
"name": "[format('{0}/{1}/storagecontainer;Storage;{2};{3}', variables('vaultName'), variables('backupFabric'), parameters('existingResourceGroupName'), parameters('existingStorageAccountName'))]",
"properties": {
"backupManagementType": "[variables('backupManagementType')]",
"containerType": "StorageContainer",
"sourceResourceId": "[parameters('existingStorageAccountArmId')]"
}
},
{
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems",
"apiVersion": "2021-12-01",
"name": "[format('{0}/{1}/{2}/{3}', split(format('{0}/{1}/storagecontainer;Storage;{2};{3}', variables('vaultName'), variables('backupFabric'), parameters('existingResourceGroupName'), parameters('existingStorageAccountName')), '/')[0], split(format('{0}/{1}/storagecontainer;Storage;{2};{3}', variables('vaultName'), variables('backupFabric'), parameters('existingResourceGroupName'), parameters('existingStorageAccountName')), '/')[1], split(format('{0}/{1}/storagecontainer;Storage;{2};{3}', variables('vaultName'), variables('backupFabric'), parameters('existingResourceGroupName'), parameters('existingStorageAccountName')), '/')[2], format('AzureFileShare;{0}', parameters('existingFileShareName')))]",
"properties": {
"protectedItemType": "AzureFileShareProtectedItem",
"sourceResourceId": "[parameters('existingStorageAccountArmId')]",
"policyId": "[parameters('backupPolicyId')]",
"isInlineInquiry": true
},
"dependsOn": [
"[resourceId(variables('vaultSubscriptionId'), variables('vaultResourceGroup'),'Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers', variables('vaultName'), variables('backupFabric'), format('storagecontainer;Storage;{0};{1}', parameters('existingResourceGroupName'), parameters('existingStorageAccountName')))]"
]
}
]
}
}
}
]
},
"parameters": {
"existingStorageAccountArmId": {
"value": "[concat('/subscriptions/', split(field('id'), '/')[2],'/resourceGroups/', split(field('id'), '/')[4],'/providers/Microsoft.Storage/storageAccounts/', split(field('id'), '/')[8])]"
},
"existingStorageAccountName": {
"value": "[first(skip(split(field('id'), '/'), 8))]"
},
"existingFileShareName": {
"value": "[field('name')]"
},
"existingResourceGroupName": {
"value": "[resourceGroup().name]"
},
"registerStorageAccount": {
"value": "[parameters('registerStorageAccount')]"
},
"backupPolicyId": {
"value": "[parameters('backupPolicyId')]"
},
"location": {
"value": "[field('location')]"
}
}
}
}
}
}
},
"versions": [
"2.0.0-PREVIEW",
"1.0.0-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/e159e079-0ddd-4905-97c9-79a8fca6d880",
"name": "e159e079-0ddd-4905-97c9-79a8fca6d880"
}Source: built-in-policies/policyDefinitions/Backup/FileShare_EnableAzureBackupWithoutTag_DINE.json in Azure/azure-policy, under the MIT licence.
Bylaw