Skip to content

Commit ed9ca18

Browse files
authored
Merge pull request #102520 from roygara/CMKNewIns
Cmdlets for existing disks
2 parents 4648e74 + 24bf08a commit ed9ca18

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

articles/virtual-machines/linux/disk-encryption.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,19 @@ diskEncryptionSetId=$(az disk-encryption-set show -n $diskEncryptionSetName -g $
132132
az vm create -g $rgName -n $vmName -l $location --image $image --size $vmSize --generate-ssh-keys --os-disk-encryption-set $diskEncryptionSetId --data-disk-sizes-gb 128 128 --data-disk-encryption-sets $diskEncryptionSetId $diskEncryptionSetId
133133
```
134134

135+
136+
#### Encrypt existing unattached managed disks
137+
138+
Your existing disks must not be attached to a running VM in order for you to encrypt them using the following script:
139+
140+
```azurecli
141+
rgName=yourResourceGroupName
142+
diskName=yourDiskName
143+
diskEncryptionSetName=yourDiskEncryptionSetName
144+
145+
az disk update -n $diskName -g $rgName --encryption-type EncryptionAtRestWithCustomerKey --disk-encryption-set $diskEncryptionSetId
146+
```
147+
135148
#### Create a virtual machine scale set using a Marketplace image, encrypting the OS and data disks with customer-managed keys
136149

137150
```azurecli

articles/virtual-machines/windows/disk-encryption.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,20 @@ Update-AzVM -ResourceGroupName $rgName -VM $vm
174174
175175
```
176176

177+
#### Encrypt existing unattached managed disks
178+
179+
Your existing disks must not be attached to a running VM in order for you to encrypt them using the following script:
180+
181+
```PowerShell
182+
$rgName = "yourResourceGroupName"
183+
$diskName = "yourDiskName"
184+
$diskEncryptionSetName = "yourDiskEncryptionSetName"
185+
186+
$diskEncryptionSet = Get-AzDiskEncryptionSet -ResourceGroupName $rgName -Name $diskEncryptionSetName
187+
188+
New-AzDiskUpdateConfig -EncryptionType "EncryptionAtRestWithCustomerKey" -DiskEncryptionSetId $diskEncryptionSet.Id | Update-AzDisk -ResourceGroupName $rgName -DiskName $diskName
189+
```
190+
177191
#### Create a virtual machine scale set using a Marketplace image, encrypting the OS and data disks with customer-managed keys
178192

179193
```PowerShell

0 commit comments

Comments
 (0)