Gallery › Mission › Azure built-in policies
[Mission] SQL servers should use customer-managed keys to encrypt data at rest
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. It mandates customer-managed Transparent Data Encryption keys for Azure SQL servers to maintain control over cryptographic material and satisfy mission compliance requirements (see https://learn.microsoft.com/azure/azure-sql/database/transparent-data-encryption-byok-overview).
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONsqlServerEncryptWithCMK.json · 82 lines
{
"properties": {
"displayName": "[Mission] SQL servers should use customer-managed keys to encrypt data at rest",
"policyType": "BuiltIn",
"mode": "All",
"description": "This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. It mandates customer-managed Transparent Data Encryption keys for Azure SQL servers to maintain control over cryptographic material and satisfy mission compliance requirements (see https://learn.microsoft.com/azure/azure-sql/database/transparent-data-encryption-byok-overview).",
"metadata": {
"version": "1.0.0",
"category": "Mission"
},
"version": "1.0.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"anyOf": [
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.Sql/servers"
},
{
"value": "[resourcegroup().managedBy]",
"notContains": "/providers/Microsoft.Synapse/"
},
{
"anyOf": [
{
"field": "Microsoft.Sql/servers/keyid",
"exists": false
},
{
"field": "Microsoft.Sql/servers/keyid",
"equals": ""
}
]
}
]
},
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.Sql/servers/encryptionProtector"
},
{
"value": "[resourcegroup().managedBy]",
"notContains": "/providers/Microsoft.Synapse/"
},
{
"field": "Microsoft.Sql/servers/encryptionProtector/serverKeyType",
"notEquals": "AzureKeyVault"
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/5105a3c5-4ad7-44fd-be94-149ca62920b7",
"name": "5105a3c5-4ad7-44fd-be94-149ca62920b7"
}Bylaw5105a3c5-4ad7-44fd-be94-149ca62920b7.bylaw.ps1 · 40 lines
# Converted from sqlServerEncryptWithCMK.json by ConvertTo-Bylaw.
Policy '5105a3c5-4ad7-44fd-be94-149ca62920b7' {
Properties @{
DisplayName = '[Mission] SQL servers should use customer-managed keys to encrypt data at rest'
Description = 'This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. It mandates customer-managed Transparent Data Encryption keys for Azure SQL servers to maintain control over cryptographic material and satisfy mission compliance requirements (see https://learn.microsoft.com/azure/azure-sql/database/transparent-data-encryption-byok-overview).'
Version = '1.0.0'
Category = 'Mission'
PolicyVersion = '1.0.0'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Deny', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource * {
Require 'type and keyid are as required' {
AnyOf {
Field type | Must -Not -Be 'Microsoft.Sql/servers' -IfPresent
Arm '[resourcegroup().managedBy]' | Must -ContainText '/providers/Microsoft.Synapse/'
Field 'Microsoft.Sql/servers/keyid' | Must -Not -Be ''
}
}
Require 'type and serverKeyType are as required' {
AnyOf {
Field type | Must -Not -Be 'Microsoft.Sql/servers/encryptionProtector' -IfPresent
Arm '[resourcegroup().managedBy]' | Must -ContainText '/providers/Microsoft.Synapse/'
Field 'Microsoft.Sql/servers/encryptionProtector/serverKeyType' | Must -Be 'AzureKeyVault'
}
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/Mission/sqlServerEncryptWithCMK.json in Azure/azure-policy, under the MIT licence.
Bylaw