{
   "properties": {
      "displayName": "Deploy SQL DB transparent data encryption",
      "policyType": "BuiltIn",
      "mode": "Indexed",
      "description": "Enables transparent data encryption on SQL databases",
      "metadata": {
         "version": "1.0.0",
         "category": "SQL"
      },
      "parameters": {},
      "policyRule": {
         "if": {
            "allOf": [
               {
                  "field": "type",
                  "equals": "Microsoft.Sql/servers/databases"
               },
               {
                  "field": "name",
                  "notEquals": "master"
               }
            ]
         },
         "then": {
            "effect": "DeployIfNotExists",
            "details": {
               "type": "Microsoft.Sql/servers/databases/transparentDataEncryption",
               "name": "current",
               "existenceCondition": {
                  "field": "Microsoft.Sql/transparentDataEncryption.status",
                  "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": {
                           "fullDbName": {
                              "type": "string"
                           }
                        },
                        "resources": [
                           {
                              "name": "[concat(parameters('fullDbName'), '/current')]",
                              "type": "Microsoft.Sql/servers/databases/transparentDataEncryption",
                              "apiVersion": "2014-04-01",
                              "properties": {
                                 "status": "Enabled"
                              }
                           }
                        ]
                     },
                     "parameters": {
                        "fullDbName": {
                           "value": "[field('fullName')]"
                        }
                     }
                  }
               }
            }
         }
      }
   },
   "id": "/providers/Microsoft.Authorization/policyDefinitions/86a912f6-9a06-4e26-b447-11b16ba8659f",
   "name": "86a912f6-9a06-4e26-b447-11b16ba8659f"
}