Bylaw

Gallery › SQL › Azure built-in policies

[Deprecated]: SQL managed instances should use customer-managed keys to encrypt data at rest

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.2-deprecated Deprecated

This policy is deprecated. Please use /providers/Microsoft.Authorization/policyDefinitions/ac01ad65-10e5-46df-bdd9-6b0cad13e1d2 instead

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONSqlManagedInstance_EnsureServerTDEisEncrypted_Audit.json · 62 lines
{
  "properties": {
    "displayName": "[Deprecated]: SQL managed instances should use customer-managed keys to encrypt data at rest",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "This policy is deprecated. Please use /providers/Microsoft.Authorization/policyDefinitions/ac01ad65-10e5-46df-bdd9-6b0cad13e1d2 instead",
    "metadata": {
      "version": "1.0.2-deprecated",
      "category": "SQL",
      "deprecated": true
    },
    "version": "1.0.2",
    "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"
              }
            ]
          }
        }
      }
    },
    "versions": [
      "1.0.2"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/048248b0-55cd-46da-b1ff-39efd52db260",
  "name": "048248b0-55cd-46da-b1ff-39efd52db260"
}
Bylaw048248b0-55cd-46da-b1ff-39efd52db260.bylaw.ps1 · 31 lines
# Converted from SqlManagedInstance_EnsureServerTDEisEncrypted_Audit.json by ConvertTo-Bylaw.
Policy '048248b0-55cd-46da-b1ff-39efd52db260' {

    Properties @{
        DisplayName   = '[Deprecated]: SQL managed instances should use customer-managed keys to encrypt data at rest'
        Description   = 'This policy is deprecated. Please use /providers/Microsoft.Authorization/policyDefinitions/ac01ad65-10e5-46df-bdd9-6b0cad13e1d2 instead'
        Version       = '1.0.2-deprecated'
        Category      = 'SQL'
        Deprecated    = $true
        PolicyVersion = '1.0.2'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('AuditIfNotExists', 'Disabled')
        Default       = 'AuditIfNotExists'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.Sql/managedInstances'

    AuditIfNotExists 'Microsoft.Sql/managedInstances/encryptionProtector' -Name 'current' -Effect (Param Effect) {
        Require 'serverKeyType is AzureKeyVault, uri is not and uri exists' {
            Field serverKeyType | Must -Be 'AzureKeyVault'
            Field uri | Must -Not -Be '' -IfPresent
            Field uri | Must -Exist
        }
    }
}

Source: built-in-policies/policyDefinitions/SQL/SqlManagedInstance_EnsureServerTDEisEncrypted_Audit.json in Azure/azure-policy, under the MIT licence.