Using Console
Using CLI
az keyvault key create --vault-name <key-vault-name> --name <key-name> --protection software
Replace <key-vault-name>
with the name of your Azure Key Vault and <key-name>
with a name for your new key.
az keyvault key show --vault-name <key-vault-name> --name <key-name> --query key.kid -o tsv
This command will return the key ID in the format:
/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.KeyVault/vaults/<key-vault-name>/keys/<key-name>/<key-version>
az disk encryption set --resource-group <resource-group-name> --name <disk-name> --key-url <key-id> --key-vault <key-vault-name> --encryption-type <encryption-type>
Replace <resource-group-name>
with the name of the resource group containing the VHD, <disk-name>
with the name of the VHD to be encrypted, <key-id>
with the key ID retrieved in step 3, <key-vault-name>
with the name of the Azure Key Vault, and <encryption-type>
with the type of encryption to use (e.g. “AES256”).
az disk encryption show --resource-group <resource-group-name> --name <disk-name>
This command will return the encryption status of the disk.
Using Python
<subscription-id>
, <key-vault-uri>
and <key-secret-url>
placeholders with the actual values.By following the above steps, you can remediate the misconfiguration “Use Customer Managed Keys for Virtual Hard Disk Encryption” for AZURE using Python.