Gallery › Backup › Azure built-in policies
Immutability must be enabled for Recovery Services vaults
Converted Policy Audit Disabled Mode Indexed Version 1.0.2
This policy audits if the immutable vaults property is enabled for Recovery Services vaults in the scope. This helps protect your backup data from being deleted before its intended expiry. Learn more at https://aka.ms/AB-ImmutableVaults.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONRecoveryServices_Immutability_Audit.json · 81 lines
{
"properties": {
"displayName": "Immutability must be enabled for Recovery Services vaults",
"description": "This policy audits if the immutable vaults property is enabled for Recovery Services vaults in the scope. This helps protect your backup data from being deleted before its intended expiry. Learn more at https://aka.ms/AB-ImmutableVaults.",
"policyType": "BuiltIn",
"mode": "Indexed",
"metadata": {
"version": "1.0.2",
"category": "Backup"
},
"version": "1.0.2",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy."
},
"allowedValues": [
"Audit",
"Disabled"
],
"defaultValue": "Audit"
},
"checkLockedImmutabilityOnly": {
"type": "Boolean",
"metadata": {
"displayName": "CheckLockedImmutabilityOnly",
"description": "This parameter checks if Immutability is locked for Recovery Services Vaults in scope. Selecting 'true' will mark only vaults with Immutability 'Locked' as compliant. Selecting 'false' will mark vaults that have Immutability either 'Enabled' or 'Locked' as compliant."
},
"allowedValues": [
true,
false
],
"defaultValue": true
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.RecoveryServices/vaults"
},
{
"anyOf": [
{
"field": "Microsoft.RecoveryServices/vaults/securitySettings.immutabilitySettings.state",
"notIn": [
"Locked",
"Unlocked"
]
},
{
"allOf": [
{
"value": "[parameters('checkLockedImmutabilityOnly')]",
"equals": true
},
{
"field": "Microsoft.RecoveryServices/vaults/securitySettings.immutabilitySettings.state",
"notEquals": "Locked"
}
]
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.2",
"1.0.1-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/d6f6f560-14b7-49a4-9fc8-d2c3a9807868",
"name": "d6f6f560-14b7-49a4-9fc8-d2c3a9807868"
}Bylawd6f6f560-14b7-49a4-9fc8-d2c3a9807868.bylaw.ps1 · 42 lines
# Converted from RecoveryServices_Immutability_Audit.json by ConvertTo-Bylaw.
Policy 'd6f6f560-14b7-49a4-9fc8-d2c3a9807868' {
Properties @{
DisplayName = 'Immutability must be enabled for Recovery Services vaults'
Description = 'This policy audits if the immutable vaults property is enabled for Recovery Services vaults in the scope. This helps protect your backup data from being deleted before its intended expiry. Learn more at https://aka.ms/AB-ImmutableVaults.'
Version = '1.0.2'
Category = 'Backup'
PolicyVersion = '1.0.2'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy.'
}
Parameter CheckLockedImmutabilityOnly @{
Type = 'Boolean'
AllowedValues = @($true, $false)
Default = $true
DisplayName = 'CheckLockedImmutabilityOnly'
Description = 'This parameter checks if Immutability is locked for Recovery Services Vaults in scope. Selecting ''true'' will mark only vaults with Immutability ''Locked'' as compliant. Selecting ''false'' will mark vaults that have Immutability either ''Enabled'' or ''Locked'' as compliant.'
}
Resource 'Microsoft.RecoveryServices/vaults' {
Require 'securitySettings.immutabilitySettings.state is one of 2 values' {
Field securitySettings.immutabilitySettings.state | Must -BeIn @('Locked', 'Unlocked')
}
Require 'securitySettings.immutabilitySettings.state is as required' {
AnyOf {
Param CheckLockedImmutabilityOnly | Must -Not -Be $true
Field securitySettings.immutabilitySettings.state | Must -Be 'Locked'
}
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/Backup/RecoveryServices_Immutability_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw