Skip to content

Commit 4d1642d

Browse files
Merge pull request #224949 from roygara/crossUpdates
Cross disk encryption set restrictions updates
2 parents 61d1e44 + 8797cb6 commit 4d1642d

9 files changed

+157
-37
lines changed

articles/virtual-machines/disk-encryption.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ By default, managed disks use platform-managed encryption keys. All managed disk
4141

4242
For now, customer-managed keys have the following restrictions:
4343

44-
- If this feature is enabled for your disk, you cannot disable it.
45-
If you need to work around this, you must copy all the data using either the [Azure PowerShell module](windows/disks-upload-vhd-to-managed-disk-powershell.md#copy-a-managed-disk) or the [Azure CLI](linux/disks-upload-vhd-to-managed-disk-cli.md#copy-a-managed-disk), to an entirely different managed disk that isn't using customer-managed keys.
4644
[!INCLUDE [virtual-machines-managed-disks-customer-managed-keys-restrictions](../../includes/virtual-machines-managed-disks-customer-managed-keys-restrictions.md)]
4745

4846
#### Supported regions

articles/virtual-machines/disks-enable-customer-managed-keys-portal.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Azure portal - Enable customer-managed keys with SSE - managed disks
33
description: Enable customer-managed keys on your managed disks through the Azure portal.
44
author: roygara
55

6-
ms.date: 01/19/2023
6+
ms.date: 02/22/2023
77
ms.topic: how-to
88
ms.author: rogarana
99
ms.service: storage
@@ -20,13 +20,6 @@ Azure Disk Storage allows you to manage your own keys when using server-side enc
2020

2121
For now, customer-managed keys have the following restrictions:
2222

23-
- If this feature is enabled for your disk, you can't disable it.
24-
If you need to work around this, you must copy all the data to an entirely different managed disk that isn't using customer-managed keys:
25-
26-
- For Linux: [Copy a managed disk](./linux/disks-upload-vhd-to-managed-disk-cli.md#copy-a-managed-disk)
27-
28-
- For Windows: [Copy a managed disk](./windows/disks-upload-vhd-to-managed-disk-powershell.md#copy-a-managed-disk)
29-
3023
[!INCLUDE [virtual-machines-managed-disks-customer-managed-keys-restrictions](../../includes/virtual-machines-managed-disks-customer-managed-keys-restrictions.md)]
3124

3225
The following sections cover how to enable and use customer-managed keys for managed disks:

articles/virtual-machines/image-version-encryption.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.service: virtual-machines
66
ms.subservice: gallery
77
ms.workload: infrastructure-services
88
ms.topic: how-to
9-
ms.date: 1/11/2023
9+
ms.date: 02/22/2023
1010
ms.custom: devx-track-azurepowershell, devx-track-azurecli
1111
ms.devlang: azurecli
1212
---
@@ -40,9 +40,7 @@ When you're using customer-managed keys for encrypting images in an Azure Comput
4040

4141
- Encryption key sets are regional resources, so each region requires a different encryption key set.
4242

43-
- You can't copy or share images that use customer-managed keys.
44-
45-
- After you've used your own keys to encrypt a disk or image, you can't go back to using platform-managed keys for encrypting those disks or images.
43+
- After you've used your own keys to encrypt an image, you can't go back to using platform-managed keys for encrypting those images.
4644

4745
- VM image version source doesn't currently support customer-managed key encryption.
4846

articles/virtual-machines/linux/disks-enable-customer-managed-keys-cli.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Azure CLI - Enable customer-managed keys with SSE - managed disks
33
description: Enable customer-managed keys on your managed disks with the Azure CLI.
44
author: roygara
5-
ms.date: 03/15/2022
5+
ms.date: 02/22/2023
66
ms.topic: how-to
77
ms.author: rogarana
88
ms.service: storage
@@ -20,8 +20,6 @@ Azure Disk Storage allows you to manage your own keys when using server-side enc
2020

2121
For now, customer-managed keys have the following restrictions:
2222

23-
- If this feature is enabled for your disk, you cannot disable it.
24-
If you need to work around this, you must [copy all the data](disks-upload-vhd-to-managed-disk-cli.md#copy-a-managed-disk) to an entirely different managed disk that isn't using customer-managed keys.
2523
[!INCLUDE [virtual-machines-managed-disks-customer-managed-keys-restrictions](../../../includes/virtual-machines-managed-disks-customer-managed-keys-restrictions.md)]
2624

2725
## Create resources

articles/virtual-machines/scripts/copy-managed-disks-to-same-or-different-subscription.md

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ ms.subservice: disks
99
ms.devlang: azurecli
1010
ms.topic: sample
1111
ms.workload: infrastructure
12-
ms.date: 02/23/2022
12+
ms.date: 02/22/2023
1313
ms.author: ramankum
1414
ms.custom: mvc
1515
---
1616

1717
# Copy managed disks to same or different subscription with CLI
1818

19-
This script copies a managed disk to same or different subscription but in the same region. The copy works only when the subscriptions are part of the same Azure AD tenant.
19+
This article contains two scripts. The first script copies a managed disk that's using platform-managed keys to same or different subscription but in the same region. The second script copies a managed disk that's using customer-managed keys to the same or a different subscription in the same region. Either copy only works when the subscriptions are part of the same Azure AD tenant.
2020

2121
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
2222

@@ -26,10 +26,54 @@ This script copies a managed disk to same or different subscription but in the s
2626

2727
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
2828

29-
### Run the script
29+
### Disks with platform-managed keys
3030

3131
:::code language="azurecli" source="~/azure_cli_scripts/virtual-machine/copy-managed-disks-to-same-or-different-subscription/copy-managed-disks-to-same-or-different-subscription.sh" id="FullScript":::
3232

33+
### Disks with customer-managed keys
34+
35+
```azurecli
36+
#Provide the subscription Id of the subscription where managed disk exists
37+
sourceSubscriptionId="<subscriptionId>"
38+
39+
#Provide the name of your resource group where managed disk exists
40+
sourceResourceGroupName=mySourceResourceGroupName
41+
42+
#Provide the name of the managed disk
43+
managedDiskName=myDiskName
44+
45+
#Provide the name of the target disk encryption set
46+
diskEncryptionSetName=myName
47+
48+
#Provide the target disk encryption set resource group
49+
diskEncryptionResourceGroup=myGroup
50+
51+
#Set the context to the subscription Id where managed disk exists
52+
az account set --subscription $sourceSubscriptionId
53+
54+
#Get the managed disk Id
55+
managedDiskId=$(az disk show --name $managedDiskName --resource-group $sourceResourceGroupName --query [id] -o tsv)
56+
57+
#If managedDiskId is blank then it means that managed disk does not exist.
58+
echo 'source managed disk Id is: ' $managedDiskId
59+
60+
#Get the disk encryption set ID
61+
diskEncryptionSetId=$(az disk-encryption-set show --name $diskEncryptionSetName --resource-group $diskEncryptionResourceGroup)
62+
63+
#Provide the subscription Id of the subscription where managed disk will be copied to
64+
targetSubscriptionId=6492b1f7-f219-446b-b509-314e17e1efb0
65+
66+
#Name of the resource group where managed disk will be copied to
67+
targetResourceGroupName=mytargetResourceGroupName
68+
69+
#Set the context to the subscription Id where managed disk will be copied to
70+
az account set --subscription $targetSubscriptionId
71+
72+
#Copy managed disk to different subscription using managed disk Id and disk encryption set ID
73+
#Add --location parameter to change the location
74+
az disk create -g $targetResourceGroupName -n $managedDiskName --source $managedDiskId --disk-encryption-set $diskEncrpytonSetId
75+
```
76+
3377
## Clean up resources
3478

3579
Run the following command to remove the resource group, VM, and all related resources.
@@ -53,4 +97,4 @@ This script uses following commands to create a new managed disk in the target s
5397

5498
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
5599

56-
Additional virtual machine and managed disks CLI script samples can be found in the [Azure Linux VM documentation](../linux/cli-samples.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).
100+
More virtual machine and managed disks CLI script samples can be found in the [Azure Linux VM documentation](../linux/cli-samples.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).

articles/virtual-machines/scripts/copy-snapshot-to-same-or-different-subscription.md

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ ms.service: storage
88
ms.subservice: disks
99
ms.topic: sample
1010
ms.workload: infrastructure
11-
ms.date: 02/23/2022
11+
ms.date: 02/22/2023
1212
ms.author: ramankum
1313
ms.custom: mvc
1414
---
1515

1616
# Copy snapshot of a managed disk to same or different subscription with CLI
1717

18-
This script copies a snapshot of a managed disk to same or different subscription. Use this script for the following scenarios:
18+
This article contains two scripts. The first script copies a snapshot of a managed disk that was using platform-managed keys to the same or a different subscription. The second script copies a snapshot of a managed disk that was using customer-managed keys to the same or a different subscription. These scripts can be used for the following scenarios:
1919

2020
- Migrate a snapshot in Premium storage (Premium_LRS) to Standard storage (Standard_LRS or Standard_ZRS) to reduce your cost.
2121
- Migrate a snapshot from locally redundant storage (Premium_LRS, Standard_LRS) to zone redundant storage (Standard_ZRS) to benefit from the higher reliability of ZRS storage.
@@ -32,10 +32,58 @@ This script copies a snapshot of a managed disk to same or different subscriptio
3232

3333
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
3434

35-
### Run the script
35+
### Disks with platform-managed keys
3636

3737
:::code language="azurecli" source="~/azure_cli_scripts/virtual-machine/copy-snapshot-to-same-or-different-subscription/copy-snapshot-to-same-or-different-subscription.sh" id="FullScript":::
3838

39+
### Disks with customer-managed keys
40+
41+
```azurecli
42+
#Provide the subscription Id of the subscription where snapshot exists
43+
sourceSubscriptionId="<subscriptionId>"
44+
45+
#Provide the name of your resource group where snapshot exists
46+
sourceResourceGroupName=mySourceResourceGroupName
47+
48+
#Provide the name of the target disk encryption set
49+
diskEncryptionSetName=myName
50+
51+
#Provide the target disk encryption set resource group
52+
diskEncryptionResourceGroup=myGroup
53+
54+
#Provide the name of the snapshot
55+
snapshotName=mySnapshotName
56+
57+
#Set the context to the subscription Id where snapshot exists
58+
az account set --subscription $sourceSubscriptionId
59+
60+
#Get the snapshot Id
61+
snapshotId=$(az snapshot show --name $snapshotName --resource-group $sourceResourceGroupName --query [id] -o tsv)
62+
63+
#If snapshotId is blank then it means that snapshot does not exist.
64+
echo 'source snapshot Id is: ' $snapshotId
65+
66+
#Get the disk encryption set ID
67+
diskEncryptionSetId=$(az disk-encryption-set show --name $diskEncryptionSetName --resource-group $diskEncryptionResourceGroup)
68+
69+
#Provide the subscription Id of the subscription where snapshot will be copied to
70+
#If snapshot is copied to the same subscription then you can skip this step
71+
targetSubscriptionId=6492b1f7-f219-446b-b509-314e17e1efb0
72+
73+
#Name of the resource group where snapshot will be copied to
74+
targetResourceGroupName=mytargetResourceGroupName
75+
76+
#Set the context to the subscription Id where snapshot will be copied to
77+
#If snapshot is copied to the same subscription then you can skip this step
78+
az account set --subscription $targetSubscriptionId
79+
80+
#Copy snapshot to different subscription using the snapshot Id
81+
#We recommend you to store your snapshots in Standard storage to reduce cost. Please use Standard_ZRS in regions where zone redundant storage (ZRS) is available, otherwise use Standard_LRS
82+
#Please check out the availability of ZRS here: https://docs.microsoft.com/en-us/azure/storage/common/storage-redundancy-zrs#support-coverage-and-regional-availability
83+
#To change the region, use the --location parameter
84+
az snapshot create -g $targetResourceGroupName -n $snapshotName --source $snapshotId --disk-encryption-set $diskEncryptionSetID --sku Standard_LRS --encryption-type EncryptionAtRestWithCustomerKey
85+
```
86+
3987
## Clean up resources
4088

4189
Run the following command to remove the resource group, VM, and all related resources.
@@ -59,4 +107,4 @@ This script uses following commands to create a snapshot in the target subscript
59107

60108
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
61109

62-
Additional virtual machine and managed disks CLI script samples can be found in the [Azure Linux VM documentation](../linux/cli-samples.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).
110+
More virtual machine and managed disks CLI script samples can be found in the [Azure Linux VM documentation](../linux/cli-samples.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).

articles/virtual-machines/scripts/create-managed-disk-from-snapshot.md

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ ms.devlang: azurecli
1515
ms.topic: sample
1616
ms.tgt_pltfrm: vm-linux
1717
ms.workload: infrastructure
18-
ms.date: 02/23/2022
18+
ms.date: 02/22/2023
1919
ms.author: ramankum
2020
ms.custom: mvc
2121
---
2222

2323
# Create a managed disk from a snapshot with CLI (Linux)
2424

25-
This script creates a managed disk from a snapshot. Use it to restore a virtual machine from snapshots of OS and data disks. Create OS and data managed disks from respective snapshots and then create a new virtual machine by attaching managed disks. You can also restore data disks of an existing VM by attaching data disks created from snapshots.
25+
This article contains two scripts for creating a managed disk from a snapshot. The first script is for a managed disk with platform-managed keys and the second script is for a managed disk with customer-managed keys. Use these scripts to restore a virtual machine from snapshots of OS and data disks. Create OS and data managed disks from respective snapshots and then create a new virtual machine by attaching managed disks. You can also restore data disks of an existing VM by attaching data disks created from snapshots.
2626

2727
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
2828

@@ -32,10 +32,52 @@ This script creates a managed disk from a snapshot. Use it to restore a virtual
3232

3333
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
3434

35-
### Run the script
35+
### Disks with platform-managed keys
3636

3737
:::code language="azurecli" source="~/azure_cli_scripts/virtual-machine/create-managed-disks-from-snapshot/create-managed-disks-from-snapshot.sh" id="FullScript":::
3838

39+
### Disks with customer-managed keys
40+
41+
```azurecli
42+
#Provide the subscription Id of the subscription where you want to create Managed Disks
43+
subscriptionId="<subscriptionId>"
44+
45+
#Provide the name of your resource group
46+
resourceGroupName=myResourceGroupName
47+
48+
#Provide the name of the snapshot that will be used to create Managed Disks
49+
snapshotName=mySnapshotName
50+
51+
#Provide the name of the new Managed Disks that will be create
52+
diskName=myDiskName
53+
54+
#Provide the size of the disks in GB. It should be greater than the VHD file size.
55+
diskSize=128
56+
57+
#Provide the storage type for Managed Disk. Premium_LRS or Standard_LRS.
58+
storageType=Premium_LRS
59+
60+
#Provide the name of the target disk encryption set
61+
diskEncryptionSetName=myName
62+
63+
#Provide the target disk encryption set resource group
64+
diskEncryptionResourceGroup=myGroup
65+
66+
#Set the context to the subscription Id where Managed Disk will be created
67+
az account set --subscription $subscriptionId
68+
69+
#Get the snapshot Id
70+
snapshotId=$(az snapshot show --name $snapshotName --resource-group $resourceGroupName --query [id] -o tsv)
71+
72+
#Get the disk encryption set ID
73+
diskEncryptionSetId=$(az disk-encryption-set show --name $diskEncryptionSetName --resource-group $diskEncryptionResourceGroup)
74+
75+
#Create a new Managed Disks using the snapshot Id
76+
#Note that managed disk will be created in the same location as the snapshot
77+
#To change the location, add the --location parameter
78+
az disk create -g $resourceGroupName -n $diskName --source $snapshotId --disk-encryption-set $diskEncryptionSetID --location eastus2euap
79+
```
80+
3981
## Clean up resources
4082

4183
Run the following command to remove the resource group, VM, and all related resources.
@@ -59,4 +101,4 @@ This script uses following commands to create a managed disk from a snapshot. Ea
59101

60102
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
61103

62-
Additional virtual machine and managed disks CLI script samples can be found in the [Azure Linux VM documentation](../linux/cli-samples.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).
104+
More virtual machine and managed disks CLI script samples can be found in the [Azure Linux VM documentation](../linux/cli-samples.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).

articles/virtual-machines/windows/disks-enable-customer-managed-keys-powershell.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Azure PowerShell - Enable customer-managed keys with SSE - managed disks
33
description: Enable server-side encryption using customer-managed keys on your managed disks with Azure PowerShell.
44
author: roygara
5-
ms.date: 11/02/2021
5+
ms.date: 02/22/2023
66
ms.topic: how-to
77
ms.author: rogarana
88
ms.service: storage
@@ -20,8 +20,6 @@ Azure Disk Storage allows you to manage your own keys when using server-side enc
2020

2121
For now, customer-managed keys have the following restrictions:
2222

23-
- If this feature is enabled for your disk, you cannot disable it.
24-
If you need to work around this, you must [copy all the data](disks-upload-vhd-to-managed-disk-powershell.md#copy-a-managed-disk) to an entirely different managed disk that isn't using customer-managed keys.
2523
[!INCLUDE [virtual-machines-managed-disks-customer-managed-keys-restrictions](../../../includes/virtual-machines-managed-disks-customer-managed-keys-restrictions.md)]
2624

2725
## Set up an Azure Key Vault and DiskEncryptionSet optionally with automatic key rotation

includes/virtual-machines-managed-disks-customer-managed-keys-restrictions.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55
author: roygara
66
ms.service: virtual-machines
77
ms.topic: include
8-
ms.date: 10/12/2022
8+
ms.date: 02/21/2023
99
ms.author: rogarana
1010
ms.custom: include file
1111
---
12+
- If this feature is enabled for a disk with incremental snapshots, it can't be disabled on that disk or its snapshots.
13+
To work around this, copy all the data to an entirely different managed disk that isn't using customer-managed keys. You can do that with either the [Azure CLI](../articles/virtual-machines/linux/disks-upload-vhd-to-managed-disk-cli.md#copy-a-managed-disk) or the [Azure PowerShell module](../articles/virtual-machines/windows/disks-upload-vhd-to-managed-disk-powershell.md#copy-a-managed-disk).
1214
- Only [software and HSM RSA keys](../articles/key-vault/keys/about-keys.md) of sizes 2,048-bit, 3,072-bit and 4,096-bit are supported, no other keys or sizes.
1315
- [HSM](../articles/key-vault/keys/hsm-protected-keys.md) keys require the **premium** tier of Azure Key vaults.
14-
- Disks created from custom images that are encrypted using server-side encryption and customer-managed keys must be encrypted using the same customer-managed keys. Your disks and their images must be in the same subscription, the keys used to encrypt your disks can be in a different subscription.
15-
- Snapshots created from disks that are encrypted with server-side encryption and customer-managed keys must be encrypted with the same customer-managed keys.
16+
- For Ultra Disks only: Snapshots created from disks that are encrypted with server-side encryption and customer-managed keys must be encrypted with the same customer-managed keys.
1617
- Most resources related to your customer-managed keys (disk encryption sets, VMs, disks, and snapshots) must be in the same subscription and region.
1718
- Azure Key Vaults may be used from a different subscription but must be in the same region as your disk encryption set. As a preview, you can use Azure Key Vaults from [different Azure Active Directory tenants](../articles/virtual-machines/disks-cross-tenant-customer-managed-keys.md).
1819
- Disks encrypted with customer-managed keys can only move to another resource group if the VM they are attached to is deallocated.
19-
- Disks, snapshots, and images encrypted with customer-managed keys cannot be moved between subscriptions.
20-
- Managed disks currently or previously encrypted using Azure Disk Encryption cannot be encrypted using customer-managed keys.
20+
- Disks, snapshots, and images encrypted with customer-managed keys can't be moved between subscriptions.
21+
- Managed disks currently or previously encrypted using Azure Disk Encryption can't be encrypted using customer-managed keys.
2122
- Can only create up to 5000 disk encryption sets per region per subscription.
2223
- For information about using customer-managed keys with shared image galleries, see [Preview: Use customer-managed keys for encrypting images](../articles/virtual-machines/image-version-encryption.md).

0 commit comments

Comments
 (0)