Gallery › SQL › Azure Community Policy
Audit SQL server level Auditing settings
Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.0
Audits the existence of SQL Auditing at the server level
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 44 lines
{
"name": "b8ef6623-67f2-46cb-be57-f0e518aaec52",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Audit SQL server level Auditing settings",
"description": "Audits the existence of SQL Auditing at the server level",
"metadata": {
"version": "1.0.0",
"category": "SQL"
},
"mode": "All",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "AuditIfNotExists or Disabled the execution of the Policy"
},
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "AuditIfNotExists"
}
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.Sql/servers"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Sql/servers/auditingSettings",
"name": "default",
"existenceCondition": {
"field": "Microsoft.Sql/auditingSettings.state",
"equals": "Enabled"
}
}
}
}
}
}Bylawb8ef6623-67f2-46cb-be57-f0e518aaec52.bylaw.ps1 · 26 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'b8ef6623-67f2-46cb-be57-f0e518aaec52' {
Properties @{
DisplayName = 'Audit SQL server level Auditing settings'
Description = 'Audits the existence of SQL Auditing at the server level'
Version = '1.0.0'
Category = 'SQL'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'AuditIfNotExists or Disabled the execution of the Policy'
}
Resource 'Microsoft.Sql/servers'
AuditIfNotExists 'Microsoft.Sql/servers/auditingSettings' -Name 'default' -Effect (Param Effect) {
Require 'auditingSettings.state is Enabled' {
Field 'Microsoft.Sql/auditingSettings.state' | Must -Be 'Enabled'
}
}
}Source: policyDefinitions/SQL/audit-sql-server-level-auditing-settings/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw