Skip to content

Commit 467e6d3

Browse files
authored
Merge pull request #224500 from roygara/doubleCode
Adding PowerShell and CLI for double encryption
2 parents 6e2d35a + a745d4c commit 467e6d3

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

articles/virtual-machines/linux/disks-enable-double-encryption-at-rest-cli.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Enable double encryption at rest - Azure CLI - managed disks
33
description: Enable double encryption at rest for your managed disk data using the Azure CLI.
44
author: roygara
5-
ms.date: 06/29/2021
5+
ms.date: 01/20/2023
66
ms.topic: how-to
77
ms.author: rogarana
88
ms.service: storage
@@ -14,17 +14,17 @@ ms.custom: references_regions, devx-track-azurecli
1414

1515
**Applies to:** :heavy_check_mark: Linux VMs :heavy_check_mark: Flexible scale sets
1616

17-
Azure Disk Storage supports double encryption at rest for managed disks. For conceptual information on double encryption at rest, as well as other managed disk encryption types, see the [Double encryption at rest](../disk-encryption.md#double-encryption-at-rest) section of our disk encryption article.
17+
Azure Disk Storage supports double encryption at rest for managed disks. For conceptual information on double encryption at rest, and other managed disk encryption types, see the [Double encryption at rest](../disk-encryption.md#double-encryption-at-rest) section of our disk encryption article.
1818

1919
## Prerequisites
2020

21-
Install the latest [Azure CLI](/cli/azure/install-az-cli2) and log in to an Azure account with [az login](/cli/azure/reference-index).
21+
Install the latest [Azure CLI](/cli/azure/install-az-cli2) and sign in to an Azure account with [az login](/cli/azure/reference-index).
2222

2323
## Getting started
2424

2525
1. Create an instance of Azure Key Vault and encryption key.
2626

27-
When creating the Key Vault instance, you must enable soft delete and purge protection. Soft delete ensures that the Key Vault holds a deleted key for a given retention period (90 day default). Purge protection ensures that a deleted key cannot be permanently deleted until the retention period lapses. These settings protect you from losing data due to accidental deletion. These settings are mandatory when using a Key Vault for encrypting managed disks.
27+
When creating the Key Vault instance, you must enable soft delete and purge protection. Soft delete ensures that the Key Vault holds a deleted key for a given retention period (90 day default). Purge protection ensures that a deleted key can't be permanently deleted until the retention period lapses. These settings protect you from losing data due to accidental deletion. These settings are mandatory when using a Key Vault for encrypting managed disks.
2828

2929

3030
```azurecli
@@ -43,12 +43,16 @@ Install the latest [Azure CLI](/cli/azure/install-az-cli2) and log in to an Azur
4343
az keyvault key create --vault-name $keyVaultName -n $keyName --protection software
4444
```
4545
46-
1. Create a DiskEncryptionSet with encryptionType set as EncryptionAtRestWithPlatformAndCustomerKeys. Use API version **2020-05-01** in the Azure Resource Manager (ARM) template.
46+
1. Get the key URL of the key you created with `az keyvault key show`.
47+
48+
```azurecli
49+
az keyvault key show --name $keyName --vault-name $keyVaultName
50+
```
51+
52+
1. Create a DiskEncryptionSet with encryptionType set as EncryptionAtRestWithPlatformAndCustomerKeys. Replace `yourKeyURL` with the URL you received from `az keyvault key show`.
4753
4854
```azurecli
49-
az deployment group create -g $rgName \
50-
--template-uri "https://raw.githubusercontent.com/Azure-Samples/managed-disks-powershell-getting-started/master/DoubleEncryption/CreateDiskEncryptionSetForDoubleEncryption.json" \
51-
--parameters "diskEncryptionSetName=$diskEncryptionSetName" "encryptionType=EncryptionAtRestWithPlatformAndCustomerKeys" "keyVaultId=$keyVaultId" "keyVaultKeyUrl=$keyVaultKeyUrl" "region=$location"
55+
az disk-encryption-set create --resource-group $rgName --name $diskEncryptionSetName --key-url yourKeyURL --source-vault $keyVaultName --encryption-type EncryptionAtRestWithPlatformAndCustomerKeys
5256
```
5357
5458
1. Grant the DiskEncryptionSet resource access to the key vault.

articles/virtual-machines/windows/disks-enable-double-encryption-at-rest-powershell.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Azure PowerShell - Enable double encryption at rest - managed disks
33
description: Enable double encryption at rest for your managed disk data using Azure PowerShell.
44
author: roygara
55

6-
ms.date: 06/29/2021
6+
ms.date: 01/20/2023
77
ms.topic: how-to
88
ms.author: rogarana
99
ms.service: storage
@@ -15,7 +15,7 @@ ms.custom: references_regions
1515

1616
**Applies to:** :heavy_check_mark: Windows VMs
1717

18-
Azure Disk Storage supports double encryption at rest for managed disks. For conceptual information on double encryption at rest, as well as other managed disk encryption types, see the [Double encryption at rest](../disk-encryption.md#double-encryption-at-rest) section of our disk encryption article.
18+
Azure Disk Storage supports double encryption at rest for managed disks. For conceptual information on double encryption at rest, and other managed disk encryption types, see the [Double encryption at rest](../disk-encryption.md#double-encryption-at-rest) section of our disk encryption article.
1919

2020
## Prerequisites
2121

@@ -25,7 +25,7 @@ Install the latest [Azure PowerShell version](/powershell/azure/install-az-ps),
2525

2626
1. Create an instance of Azure Key Vault and encryption key.
2727

28-
When creating the Key Vault instance, you must enable soft delete and purge protection. Soft delete ensures that the Key Vault holds a deleted key for a given retention period (90 day default). Purge protection ensures that a deleted key cannot be permanently deleted until the retention period lapses. These settings protect you from losing data due to accidental deletion. These settings are mandatory when using a Key Vault for encrypting managed disks.
28+
When creating the Key Vault instance, you must enable soft delete and purge protection. Soft delete ensures that the Key Vault holds a deleted key for a given retention period (90 day default). Purge protection ensures that a deleted key can't be permanently deleted until the retention period lapses. These settings protect you from losing data due to accidental deletion. These settings are mandatory when using a Key Vault for encrypting managed disks.
2929

3030
```powershell
3131
$ResourceGroupName="yourResourceGroupName"
@@ -40,16 +40,24 @@ Install the latest [Azure PowerShell version](/powershell/azure/install-az-ps),
4040
$key = Add-AzKeyVaultKey -VaultName $keyVaultName -Name $keyName -Destination $keyDestination
4141
```
4242
43-
1. Create a DiskEncryptionSet with encryptionType set as EncryptionAtRestWithPlatformAndCustomerKeys. Use API version **2020-05-01** in the Azure Resource Manager (ARM) template.
43+
1. Retrieve the URL for the key you created, you'll need it for subsequent commands. The ID output from `Get-AzKeyVaultKey` is the key URL.
44+
45+
```powershell
46+
Get-AzKeyVaultKey -VaultName $keyVaultName -KeyName $keyName
47+
```
48+
49+
1. Get the resource ID for the Key Vault instance you created, you'll need it for subsequent commands.
50+
51+
```powershell
52+
Get-AzKeyVault -VaultName $keyVaultName
53+
```
54+
55+
1. Create a DiskEncryptionSet with encryptionType set as EncryptionAtRestWithPlatformAndCustomerKeys. Replace `yourKeyURL` and `yourKeyVaultURL` with the URLs you retrieved earlier.
4456
4557
```powershell
46-
New-AzResourceGroupDeployment -ResourceGroupName $ResourceGroupName `
47-
-TemplateUri "https://raw.githubusercontent.com/Azure-Samples/managed-disks-powershell-getting-started/master/DoubleEncryption/CreateDiskEncryptionSetForDoubleEncryption.json" `
48-
-diskEncryptionSetName $diskEncryptionSetName `
49-
-keyVaultId $keyVault.ResourceId `
50-
-keyVaultKeyUrl $key.Key.Kid `
51-
-encryptionType "EncryptionAtRestWithPlatformAndCustomerKeys" `
52-
-region $LocationName
58+
$config = New-AzDiskEncryptionSetConfig -Location $locationName -KeyUrl "yourKeyURL" -SourceVaultId 'yourKeyVaultURL' -IdentityType 'SystemAssigned'
59+
60+
$config | New-AzDiskEncryptionSet -ResourceGroupName $ResourceGroupName -Name $diskEncryptionSetName -EncryptionType EncryptionAtRestWithPlatformAndCustomerKeys
5361
```
5462
5563
1. Grant the DiskEncryptionSet resource access to the key vault.

0 commit comments

Comments
 (0)