Gallery › SQL › Azure built-in policies
Long-term geo-redundant backup should be enabled for Azure SQL Databases
Converted Policy AuditIfNotExists Disabled Mode Indexed Version 2.0.0
This policy audits any Azure SQL Database with long-term geo-redundant backup not enabled.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONGeoRedundant_SQLDatabase_AINE.json · 69 lines
{
"properties": {
"displayName": "Long-term geo-redundant backup should be enabled for Azure SQL Databases",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "This policy audits any Azure SQL Database with long-term geo-redundant backup not enabled.",
"metadata": {
"version": "2.0.0",
"category": "SQL"
},
"version": "2.0.0",
"parameters": {
"effect": {
"type": "string",
"defaultValue": "AuditIfNotExists",
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Sql/servers/databases"
},
{
"field": "name",
"notEquals": "master"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Sql/servers/databases/backupLongTermRetentionPolicies",
"name": "default",
"existenceCondition": {
"anyOf": [
{
"field": "Microsoft.Sql/servers/databases/backupLongTermRetentionPolicies/weeklyRetention",
"notEquals": "PT0S"
},
{
"field": "Microsoft.Sql/servers/databases/backupLongTermRetentionPolicies/monthlyRetention",
"notEquals": "PT0S"
},
{
"field": "Microsoft.Sql/servers/databases/backupLongTermRetentionPolicies/yearlyRetention",
"notEquals": "PT0S"
}
]
}
}
}
},
"versions": [
"2.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/d38fc420-0735-4ef3-ac11-c806f651a570",
"name": "d38fc420-0735-4ef3-ac11-c806f651a570"
}Bylawd38fc420-0735-4ef3-ac11-c806f651a570.bylaw.ps1 · 37 lines
# Converted from GeoRedundant_SQLDatabase_AINE.json by ConvertTo-Bylaw.
Policy 'd38fc420-0735-4ef3-ac11-c806f651a570' {
Properties @{
DisplayName = 'Long-term geo-redundant backup should be enabled for Azure SQL Databases'
Description = 'This policy audits any Azure SQL Database with long-term geo-redundant backup not enabled.'
Version = '2.0.0'
Category = 'SQL'
PolicyVersion = '2.0.0'
Mode = 'Indexed'
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Sql/servers/databases' {
Require 'name is master' {
Field name | Must -Be 'master'
}
}
AuditIfNotExists 'Microsoft.Sql/servers/databases/backupLongTermRetentionPolicies' -Name 'default' -Effect (Param Effect) {
Require 'weeklyRetention, monthlyRetention and yearlyRetention are as required' {
AnyOf {
Field weeklyRetention | Must -Not -Be 'PT0S' -IfPresent
Field monthlyRetention | Must -Not -Be 'PT0S' -IfPresent
Field yearlyRetention | Must -Not -Be 'PT0S' -IfPresent
}
}
}
}Source: built-in-policies/policyDefinitions/SQL/GeoRedundant_SQLDatabase_AINE.json in Azure/azure-policy, under the MIT licence.
Bylaw