Gallery › SQL › Azure built-in policies
SQL servers with auditing to storage account destination should be configured with 90 days retention or higher
Converted Policy AuditIfNotExists Disabled Mode Indexed Version 3.0.0
For incident investigation purposes, we recommend setting the data retention for your SQL Server' auditing to storage account destination to at least 90 days. Confirm that you are meeting the necessary retention rules for the regions in which you are operating. This is sometimes required for compliance with regulatory standards.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONSqlServerAuditingRetentionDays_Audit.json · 77 lines
{
"properties": {
"displayName": "SQL servers with auditing to storage account destination should be configured with 90 days retention or higher",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "For incident investigation purposes, we recommend setting the data retention for your SQL Server' auditing to storage account destination to at least 90 days. Confirm that you are meeting the necessary retention rules for the regions in which you are operating. This is sometimes required for compliance with regulatory standards.",
"metadata": {
"version": "3.0.0",
"category": "SQL"
},
"version": "3.0.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "AuditIfNotExists"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Sql/servers"
},
{
"field": "kind",
"notContains": "analytics"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Sql/servers/auditingSettings",
"name": "default",
"existenceCondition": {
"anyOf": [
{
"allOf": [
{
"field": "Microsoft.Sql/servers/auditingSettings/isAzureMonitorTargetEnabled",
"equals": true
},
{
"field": "Microsoft.Sql/servers/auditingSettings/storageEndpoint",
"equals": ""
}
]
},
{
"field": "Microsoft.Sql/servers/auditingSettings/retentionDays",
"equals": 0
},
{
"field": "Microsoft.Sql/servers/auditingSettings/retentionDays",
"greaterOrEquals": 90
}
]
}
}
}
},
"versions": [
"3.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/89099bee-89e0-4b26-a5f4-165451757743",
"name": "89099bee-89e0-4b26-a5f4-165451757743"
}Bylaw89099bee-89e0-4b26-a5f4-165451757743.bylaw.ps1 · 39 lines
# Converted from SqlServerAuditingRetentionDays_Audit.json by ConvertTo-Bylaw.
Policy '89099bee-89e0-4b26-a5f4-165451757743' {
Properties @{
DisplayName = 'SQL servers with auditing to storage account destination should be configured with 90 days retention or higher'
Description = 'For incident investigation purposes, we recommend setting the data retention for your SQL Server'' auditing to storage account destination to at least 90 days. Confirm that you are meeting the necessary retention rules for the regions in which you are operating. This is sometimes required for compliance with regulatory standards.'
Version = '3.0.0'
Category = 'SQL'
PolicyVersion = '3.0.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Sql/servers' {
Require 'kind contains analytics' {
Field kind | Must -ContainText 'analytics'
}
}
AuditIfNotExists 'Microsoft.Sql/servers/auditingSettings' -Name 'default' -Effect (Param Effect) {
Require 'isAzureMonitorTargetEnabled, storageEndpoint and retentionDays are as required' {
AnyOf {
AllOf {
Field isAzureMonitorTargetEnabled | Must -Be $true
Field storageEndpoint | Must -Be ''
}
Field retentionDays | Must -Be 0
Field retentionDays | Must -BeGreaterOrEqual 90 -IfPresent
}
}
}
}Source: built-in-policies/policyDefinitions/SQL/SqlServerAuditingRetentionDays_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw