# OS and data disks should be encrypted with a customer-managed key

Facts read 10 Nov 2026. Page reviewed 16 Nov 2026.

OS and data disks should be encrypted with a customer-managed key is an Azure guardrail written in Azure Policy. Denies managed disks that are not encrypted with a customer-managed key. What it breaks: you take on key lifecycle work: the definition says you have full control and responsibility for the key lifecycle, including rotation and management.

```text
Built-in policy definition: OS and data disks should be encrypted with a customer-managed key
Definition ID: 702dd420-7fcc-42c5-afe8-4026edd20fe0
Category: Compute
Supported effects: Audit, Deny, Disabled
policyRule (copied from the repository file):
{
    "if": {
      "anyOf": [
        {
          "allOf": [
            {
              "field": "type",
              "equals": "Microsoft.Compute/virtualMachines"
            },
            {
              "field": "Microsoft.Compute/virtualMachines/storageProfile.osDisk.managedDisk.diskEncryptionSet.id",
              "exists": "False"
            }
          ]
        },
        {
          "allOf": [
            {
              "field": "type",
              "equals": "Microsoft.Compute/virtualMachines"
            },
            {
              "value": "[length(field('Microsoft.Compute/virtualMachines/storageProfile.dataDisks'))]",
              "greater": 0
            },
            {
              "field": "Microsoft.Compute/virtualMachines/storageProfile.dataDisks[*].managedDisk.id",
              "exists": "False"
            },
            {
              "field": "Microsoft.Compute/virtualMachines/storageProfile.dataDisks[*].managedDisk.diskEncryptionSet.id",
              "exists": "False"
            }
          ]
        },
        {
          "allOf": [
            {
              "field": "type",
              "equals": "Microsoft.Compute/virtualMachineScaleSets"
            },
            {
              "field": "Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.storageProfile.osDisk.managedDisk.diskEncryptionSet.id",
              "exists": "False"
            }
          ]
        },
        {
          "allOf": [
            {
              "field": "type",
              "equals": "Microsoft.Compute/virtualMachineScaleSets"
            },
            {
              "count": {
                "field": "Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.storageProfile.dataDisks[*]"
              },
              "greater": 0
            },
            {
              "not": {
                "field": "Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.storageProfile.dataDisks[*].managedDisk.diskEncryptionSet.id",
                "exists": "true"
              }
            }
          ]
        },
        {
          "allOf": [
            {
              "field": "type",
              "equals": "Microsoft.Compute/disks"
            },
            {
              "field": "Microsoft.Compute/disks/encryption.diskEncryptionSetId",
              "exists": "False"
            }
          ]
        },
        {
          "allOf": [
            {
              "field": "type",
              "equals": "Microsoft.Compute/galleries/images/versions"
            },
            {
              "value": "[length(field('Microsoft.Compute/galleries/images/versions/publishingProfile.targetRegions[*].encryption.osDiskImage.diskEncryptionSetId'))]",
              "notEquals": "[length(field('Microsoft.Compute/galleries/images/versions/publishingProfile.targetRegions[*]'))]"
            }
          ]
        },
        {
          "allOf": [
            {
              "field": "type",
              "equals": "Microsoft.Compute/galleries/images/versions"
            },
            {
              "value": "[length(field('Microsoft.Compute/galleries/images/versions/storageProfile.dataDiskImages[*]'))]",
              "greater": 0
            },
            {
              "anyOf": [
                {
                  "count": {
                    "field": "Microsoft.Compute/galleries/images/versions/publishingProfile.targetRegions[*]",
                    "where": {
                      "value": "[length(current('Microsoft.Compute/galleries/images/versions/publishingProfile.targetRegions[*].encryption.dataDiskImages[*].diskEncryptionSetId'))]",
                      "notEquals": "[length(field('Microsoft.Compute/galleries/images/versions/storageProfile.dataDiskImages[*]'))]"
                    }
                  },
                  "greater": 0
                },
                {
                  "not": {
                    "field": "Microsoft.Compute/galleries/images/versions/publishingProfile.targetRegions[*].encryption.dataDiskImages[*].diskEncryptionSetId",
                    "exists": "true"
                  }
                }
              ]
            }
          ]
        },
        {
          "allOf": [
            {
              "field": "type",
              "equals": "Microsoft.Compute/images"
            },
            {
              "field": "Microsoft.Compute/images/storageProfile.osDisk.diskEncryptionSet.id",
              "exists": "False"
            }
          ]
        },
        {
          "allOf": [
            {
              "field": "type",
              "equals": "Microsoft.Compute/images"
            },
            {
              "value": "[length(field('Microsoft.Compute/images/storageProfile.dataDisks[*]'))]",
              "greater": 0
            },
            {
              "not": {
                "field": "Microsoft.Compute/images/storageProfile.dataDisks[*].diskEncryptionSet.id",
                "exists": "true"
              }
            }
          ]
        }
      ]
    },
    "then": {
      "effect": "[parameters('effect')]"
    }
  }
```

- **Blocks:** Denies managed disks that are not encrypted with a customer-managed key.
- **Breaks:** You take on key lifecycle work: the definition says you have full control and responsibility for the key lifecycle, including rotation and management. ([source](https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-policies/policyDefinitions/Compute/OSAndDataDiskCMKRequired_Deny.json))
- **Test before applying:** As for every Azure Policy guardrail: [how to test before enforcing](/mechanisms/azure-policy/)
- **Mechanism:** [Azure Policy (built-in definitions)](/mechanisms/azure-policy/): Resources at the scope of the assignment (management group, subscription, resource group) and their children, except notScopes and exemptions
- **Taken from:** [open source set](https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-policies/policyDefinitions/Compute/OSAndDataDiskCMKRequired_Deny.json), MIT License, Azure/azure-policy repository, https://raw.githubusercontent.com/Azure/azure-policy/master/LICENSE

## What the source says

"Use customer-managed keys to manage the encryption at rest of the contents of your managed disks." (read 10 Nov 2026).

On what it breaks: "You have full control and responsibility for the key lifecycle, including rotation and management."

## Related guardrails

- [Deny KMS key deletion](/guardrails/aws-scp-deny-kms-key-deletion/): AWS, Service control policies (SCPs), encryption and keys
- [Enforce a 30-day KMS key deletion window](/guardrails/aws-scp-kms-30-day-deletion-window/): AWS, Service control policies (SCPs), encryption and keys
- [Deny disabling default EBS encryption](/guardrails/aws-scp-deny-disable-ebs-default-encryption/): AWS, Service control policies (SCPs), encryption and keys
- [Storage accounts should have the specified minimum TLS version](/guardrails/azure-policy-storage-min-tls/): Azure, Azure Policy (built-in definitions), encryption and keys
- [Key vaults should have deletion protection enabled](/guardrails/azure-policy-keyvault-purge-protection/): Azure, Azure Policy (built-in definitions), encryption and keys

## Related pages

- [Azure SQL Database should have Microsoft Entra-only authentication enabled (Azure Azure Policy)](/guardrails/azure-policy-sql-entra-only/)
- [Deploy diagnostic settings for Key Vault to Event Hub (Azure Azure Policy)](/guardrails/azure-policy-keyvault-diagnostic-logs/)
- [Application Insights components should block non-Entra ingestion (Azure Azure Policy)](/guardrails/azure-policy-appinsights-entra-ingestion/)

## Sources

- OS and data disks should be encrypted with a customer-managed key: https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-policies/policyDefinitions/Compute/OSAndDataDiskCMKRequired_Deny.json (read 10 Nov 2026)
- How to test it first: https://learn.microsoft.com/en-us/azure/governance/policy/concepts/assignment-structure (read 10 Nov 2026)

Last reviewed 16 Nov 2026. Canonical: https://cloudgovernancetools.com/guardrails/azure-policy-disk-cmk/
