{
  "properties": {
    "displayName": "Configure Advanced Threat Protection to be enabled on Azure database for MariaDB servers",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Enable Advanced Threat Protection on your non-Basic tier Azure database for MariaDB servers to detect anomalous activities indicating unusual and potentially harmful attempts to access or exploit databases.",
    "metadata": {
      "version": "1.0.0",
      "category": "SQL"
    },
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "DeployIfNotExists",
        "allowedValues": [
          "DeployIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.DBforMariaDB/servers"
          },
          {
            "field": "Microsoft.DBforMariaDB/servers/sku.tier",
            "notContains": "basic"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.DBforMariaDB/servers/securityAlertPolicies",
          "name": "Default",
          "existenceCondition": {
            "field": "Microsoft.DBforMariaDB/servers/securityAlertPolicies/Default.state",
            "equals": "Enabled"
          },
          "roleDefinitionIds": [
            "/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
          ],
          "deployment": {
            "properties": {
              "mode": "incremental",
              "template": {
                "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
                "contentVersion": "1.0.0.0",
                "parameters": {
                  "serverName": {
                    "type": "string"
                  }
                },
                "variables": {},
                "resources": [
                  {
                    "name": "[concat(parameters('serverName'), '/Default')]",
                    "type": "Microsoft.DBforMariaDB/servers/securityAlertPolicies",
                    "apiVersion": "2018-06-01",
                    "properties": {
                      "state": "Enabled",
                      "emailAccountAdmins": false
                    }
                  }
                ]
              },
              "parameters": {
                "serverName": {
                  "value": "[field('name')]"
                }
              }
            }
          }
        }
      }
    }
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/a6cf7411-da9e-49e2-aec0-cba0250eaf8c",
  "name": "a6cf7411-da9e-49e2-aec0-cba0250eaf8c"
}