{
   "properties": {
      "displayName": "Deploy Threat Detection on SQL servers",
      "mode": "Indexed",
      "description": "This policy ensures that Threat Detection is enabled on SQL Servers.",
      "metadata": {
         "category": "SQL"
      },
      "parameters": {},
      "policyRule": {
         "if": {
            "field": "type",
            "equals": "Microsoft.Sql/servers"
         },
         "then": {
            "effect": "DeployIfNotExists",
            "details": {
               "type": "Microsoft.Sql/servers/securityAlertPolicies",
               "name": "Default",
               "existenceCondition": {
                  "field": "Microsoft.Sql/securityAlertPolicies.state",
                  "equals": "Enabled"
               },
               "roleDefinitionIds": [
                  "/providers/microsoft.authorization/roleDefinitions/9b7fa17d-e63e-47b0-bb0a-15c516ac86ec"
               ],
               "deployment": {
                  "properties": {
                     "mode": "incremental",
                     "template": {
                        "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                        "contentVersion": "1.0.0.0",
                        "parameters": {
                           "serverName": {
                              "type": "string"
                           }
                        },
                        "variables": {},
                        "resources": [
                           {
                              "name": "[concat(parameters('serverName'), '/Default')]",
                              "type": "Microsoft.Sql/servers/securityAlertPolicies",
                              "apiVersion": "2017-03-01-preview",
                              "properties": {
                                 "state": "Enabled",
                                 "emailAccountAdmins": true
                              }
                           }
                        ]
                     },
                     "parameters": {
                        "serverName": {
                           "value": "[field('name')]"
                        }
                     }
                  }
               }
            }
         }
      }
   }
}