{
  "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"
    },
    "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"
                }
              }
            ]
          }
        }
      }
    }
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/7ff426e2-515f-405a-91c8-4f2333442eb5",
  "name": "7ff426e2-515f-405a-91c8-4f2333442eb5"
}