Gallery › SQL › Azure built-in policies
SQL Auditing settings should have Action-Groups configured to capture critical activities
Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0
The AuditActionsAndGroups property should contain at least SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, FAILED_DATABASE_AUTHENTICATION_GROUP, BATCH_COMPLETED_GROUP to ensure a thorough audit logging
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONSqlServerAuditing_ActionsAndGroups_Audit.json · 67 lines
{
"properties": {
"displayName": "SQL Auditing settings should have Action-Groups configured to capture critical activities",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "The AuditActionsAndGroups property should contain at least SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, FAILED_DATABASE_AUTHENTICATION_GROUP, BATCH_COMPLETED_GROUP to ensure a thorough audit logging",
"metadata": {
"version": "1.0.0",
"category": "SQL"
},
"version": "1.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": {
"field": "type",
"equals": "Microsoft.Sql/servers"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Sql/servers/auditingSettings",
"name": "default",
"existenceCondition": {
"allOf": [
{
"not": {
"field": "Microsoft.Sql/servers/auditingSettings/auditActionsAndGroups[*]",
"notEquals": "SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP"
}
},
{
"not": {
"field": "Microsoft.Sql/servers/auditingSettings/auditActionsAndGroups[*]",
"notEquals": "FAILED_DATABASE_AUTHENTICATION_GROUP"
}
},
{
"not": {
"field": "Microsoft.Sql/servers/auditingSettings/auditActionsAndGroups[*]",
"notEquals": "BATCH_COMPLETED_GROUP"
}
}
]
}
}
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/7ff426e2-515f-405a-91c8-4f2333442eb5",
"name": "7ff426e2-515f-405a-91c8-4f2333442eb5"
}Bylaw7ff426e2-515f-405a-91c8-4f2333442eb5.bylaw.ps1 · 36 lines
# Converted from SqlServerAuditing_ActionsAndGroups_Audit.json by ConvertTo-Bylaw.
Policy '7ff426e2-515f-405a-91c8-4f2333442eb5' {
Properties @{
DisplayName = 'SQL Auditing settings should have Action-Groups configured to capture critical activities'
Description = 'The AuditActionsAndGroups property should contain at least SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, FAILED_DATABASE_AUTHENTICATION_GROUP, BATCH_COMPLETED_GROUP to ensure a thorough audit logging'
Version = '1.0.0'
Category = 'SQL'
PolicyVersion = '1.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'
AuditIfNotExists 'Microsoft.Sql/servers/auditingSettings' -Name 'default' -Effect (Param Effect) {
Require 'auditActionsAndGroups is as required' {
Count 'auditActionsAndGroups[*]' -Where {
Element | Must -Be 'SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP'
} | Must -BeGreaterThan 0
Count 'auditActionsAndGroups[*]' -Where {
Element | Must -Be 'FAILED_DATABASE_AUTHENTICATION_GROUP'
} | Must -BeGreaterThan 0
Count 'auditActionsAndGroups[*]' -Where {
Element | Must -Be 'BATCH_COMPLETED_GROUP'
} | Must -BeGreaterThan 0
}
}
}Source: built-in-policies/policyDefinitions/SQL/SqlServerAuditing_ActionsAndGroups_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw