{
  "properties": {
    "displayName": "SQL managed instances should use customer-managed keys to encrypt data at rest",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Implementing Transparent Data Encryption (TDE) with your own key provides you with increased transparency and control over the TDE Protector, increased security with an HSM-backed external service, and promotion of separation of duties. This recommendation applies to organizations with a related compliance requirement.",
    "metadata": {
      "version": "1.0.2",
      "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/managedInstances"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Sql/managedInstances/encryptionProtector",
          "name": "current",
          "existenceCondition": {
            "allOf": [
              {
                "field": "Microsoft.Sql/managedInstances/encryptionProtector/serverKeyType",
                "equals": "AzureKeyVault"
              },
              {
                "field": "Microsoft.Sql/managedInstances/encryptionProtector/uri",
                "notEquals": ""
              },
              {
                "field": "Microsoft.Sql/managedInstances/encryptionProtector/uri",
                "exists": "true"
              }
            ]
          }
        }
      }
    }
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/048248b0-55cd-46da-b1ff-39efd52db260",
  "name": "048248b0-55cd-46da-b1ff-39efd52db260"
}