01 Run keyvault create command (Windows/macOS/Linux) to create the Microsoft Azure Key Vault where the required Customer Managed Key will be placed:
az keyvault create
--name cc-production-vault
--resource-group cloud-shell-storage-westeurope
--location westeurope
--enabled-for-deployment true
--enabled-for-template-deployment true
--query 'properties.accessPolicies[*].objectId'
02 The command output should return the object ID of the new Microsoft Azure Key Vault:
[
"abcdabcd-1234-1234-1234-abcdabcdabcd"
]
03 Run keyvault set-policy command (Windows/macOS/Linux) using the object ID and the name of the newly created key vault as the identifier parameters to assign the right permissions for the selected vault:
az keyvault set-policy
--name cc-production-vault
--object-id abcdabcd-1234-1234-1234-abcdabcdabcd
--key-permissions get recover unwrapKey wrapKey
04 The command output should return the modified key vault configuration metadata:
{
"id": "/subscriptions/abcdabcd-1234-1234-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.KeyVault/vaults/cc-production-vault",
"location": "westeurope",
"name": "cc-production-vault",
"properties": {
"accessPolicies": [
{
"applicationId": null,
"objectId": "abcdabcd-1234-1234-1234-abcdabcdabcd",
"permissions": {
"certificates": [
"get",
"list",
"delete",
"create",
"import",
"update",
"managecontacts",
"getissuers",
"listissuers",
"setissuers",
"deleteissuers",
"manageissuers",
"recover"
],
"keys": [
"get",
"wrapKey",
"recover",
"unwrapKey"
],
"secrets": [
"get",
"list",
"set",
"delete",
"backup",
"restore",
"recover"
],
"storage": [
"get",
"list",
"delete",
"set",
"update",
"regeneratekey",
"setsas",
"listsas",
"getsas",
"deletesas"
]
},
"tenantId": "abcdabcd-1234-1234-1234-abcdabcdabcd"
}
],
"createMode": null,
"enablePurgeProtection": null,
"enableRbacAuthorization": null,
"enableSoftDelete": true,
"enabledForDeployment": true,
"enabledForDiskEncryption": null,
"enabledForTemplateDeployment": true,
"hsmPoolResourceId": null,
"networkAcls": null,
"privateEndpointConnections": null,
"provisioningState": "Succeeded",
"sku": {
"family": "A",
"name": "standard"
},
"softDeleteRetentionInDays": 90,
"tenantId": "abcdabcd-1234-1234-1234-abcdabcdabcd",
"vaultUri": "https://cc-production-vault.vault.azure.net/"
},
"resourceGroup": "cloud-shell-storage-westeurope",
"systemData": {
"createdAt": "2021-10-12T08:46:41.338000+00:00",
"createdBy": "admin@domain.com",
"createdByType": "User",
"lastModifiedAt": "2021-10-12T08:45:05.813000+00:00",
"lastModifiedBy": "admin@domain.com",
"lastModifiedByType": "User"
},
"tags": {},
"type": "Microsoft.KeyVault/vaults"
}
05 Run keyvault key create command (Windows/macOS/Linux) to create the Customer Managed Key (CMK), required to encrypt data within your Microsoft Azure Storage account:
az keyvault key create
--name cc-production-cmk
--vault-name cc-production-vault
--kty RSA
--size 2048
--ops decrypt encrypt sign unwrapKey verify wrapKey
--expires "2022-12-10T10:30:00Z"
--protection software
--disabled false
--query 'key.kid'
06 The command output should return the ID of the new CMK. This identifier contains the encryption key version, a 32-digit number (e.g. "12345678901234567890123456789012") that will be used later as the value for the --encryption-key-version command parameter, to enable encryption for your storage account:
"12345678901234567890123456789012"
07 Run storage account update command (Windows/macOS/Linux) using the name of the Azure Storage account that you want to reconfigure as the identifier parameter, to enable encryption with Customer Managed Keys (CMKs) for the selected storage account (the command does not produce an output):
az storage account update
--name abcdabcdabcd123412341234
--encryption-key-name cc-production-cmk
--encryption-key-version 12345678901234567890123456789012
--encryption-key-source Microsoft.Keyvault
--encryption-key-vault https://cc-production-vault.vault.azure.net/
08 Repeat step no. 7 for each storage account created within the current Azure subscription.
09 Repeat steps no. 1 – 8 for each subscription available in your Microsoft Azure cloud account.