Skip to content

Commit ea12f03

Browse files
Added support for Managed HSM with CMK in EH
1 parent bfcfc37 commit ea12f03

File tree

1 file changed

+89
-34
lines changed

1 file changed

+89
-34
lines changed

articles/event-hubs/configure-customer-managed-key.md

Lines changed: 89 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Configure your own key for encrypting Azure Event Hubs data at rest
33
description: This article provides information on how to configure your own key for encrypting Azure Event Hubs data rest.
44
ms.topic: conceptual
5-
ms.date: 08/18/2021
5+
ms.date: 05/13/2024
66
---
77

88
# Configure customer-managed keys for encrypting Azure Event Hubs data at rest
@@ -12,7 +12,7 @@ Azure Event Hubs provides encryption of data at rest with Azure Storage Service
1212
> - The BYOK capability is supported by **premium** and **dedicated** tiers of Event Hubs.
1313
> - The encryption can be enabled only for new or empty namespaces. If the namespace contains event hubs, the encryption operation will fail.
1414
15-
You can use Azure Key Vault to manage your keys and audit your key usage. You can either create your own keys and store them in a key vault, or you can use the Azure Key Vault APIs to generate keys. For more information about Azure Key Vault, see [What is Azure Key Vault?](../key-vault/general/overview.md)
15+
You can use Azure Key Vault (including Azure Key Vault Managed HSM) to manage your keys and audit your key usage. You can either create your own keys and store them in a key vault, or you can use the Azure Key Vault APIs to generate keys. For more information about Azure Key Vault, see [What is Azure Key Vault?](../key-vault/general/overview.md)
1616

1717
This article shows how to configure a key vault with customer-managed keys by using the Azure portal. To learn how to create a key vault using the Azure portal, see [Quickstart: Create an Azure Key Vault using the Azure portal](../key-vault/general/quick-create-portal.md).
1818

@@ -25,13 +25,19 @@ To enable customer-managed keys in the Azure portal, follow these steps. If you
2525

2626
![Enable customer managed key](./media/configure-customer-managed-key/enable-customer-managed-key.png)
2727

28+
> [!NOTE]
29+
> Currently you can't configure Azure Key Vault Managed HSM through the portal.
30+
2831
## Set up a key vault with keys
2932
After you enable customer-managed keys, you need to associate the customer managed key with your Azure Event Hubs namespace. Event Hubs supports only Azure Key Vault. If you enable the **Encryption with customer-managed key** option in the previous section, you need to have the key imported into Azure Key Vault. Also, the keys must have **Soft Delete** and **Do Not Purge** configured for the key. These settings can be configured using [PowerShell](../key-vault/general/key-vault-recovery.md) or [CLI](../key-vault/general/key-vault-recovery.md).
3033

3134
1. To create a new key vault, follow the Azure Key Vault [Quickstart](../key-vault/general/overview.md). For more information about importing existing keys, see [About keys, secrets, and certificates](../key-vault/general/about-keys-secrets-certificates.md).
3235

3336
> [!IMPORTANT]
3437
> Using customer-managed keys with Azure Event Hubs requires that the key vault have two required properties configured. They are: **Soft Delete** and **Do Not Purge**. These properties are enabled by default when you create a new key vault in the Azure portal. However, if you need to enable these properties on an existing key vault, you must use either PowerShell or Azure CLI.
38+
39+
# [Key Vault](#tab/Key-Vault)
40+
3541
1. To turn on both soft delete and purge protection when creating a vault, use the [az keyvault create](/cli/azure/keyvault#az-keyvault-create) command.
3642

3743
```azurecli-interactive
@@ -42,6 +48,22 @@ After you enable customer-managed keys, you need to associate the customer manag
4248
```azurecli-interactive
4349
az keyvault update --name ContosoVault --resource-group ContosoRG --enable-purge-protection true
4450
```
51+
52+
# [Key Vault Managed HSM](#tab/Key-Vault-Managed-HSM)
53+
54+
1. To turn on both soft delete and purge protection when creating a vault, use the [az keyvault create](/cli/azure/keyvault#az-keyvault-create) command.
55+
56+
```azurecli-interactive
57+
az keyvault create --hsm-name ContosoVault --resource-group ContosoRG --location westus --enable-soft-delete true --enable-purge-protection true
58+
```
59+
1. To add purge protection to an existing vault (that already has soft delete enabled), use the [az keyvault update](/cli/azure/keyvault#az-keyvault-update) command.
60+
61+
```azurecli-interactive
62+
az keyvault update --hsm-name ContosoVault --resource-group ContosoRG --enable-purge-protection true
63+
```
64+
65+
---
66+
4567
1. Create keys by following these steps:
4668
1. To create a new key, select **Generate/Import** from the **Keys** menu under **Settings**.
4769
@@ -182,20 +204,7 @@ This section shows you how to create an Azure Event Hubs namespace with managed
182204
183205
### Grant Event Hubs namespace identity access to key vault
184206
185-
1. Run the following command to create a key vault with **purge protection** and **soft-delete** enabled.
186-
187-
```powershell
188-
New-AzureRmKeyVault -Name {keyVaultName} -ResourceGroupName {RGName} -Location {location} -EnableSoftDelete -EnablePurgeProtection
189-
```
190-
191-
(OR)
192-
193-
Run the following command to update an **existing key vault**. Specify values for resource group and key vault names before running the command.
194-
195-
```powershell
196-
($updatedKeyVault = Get-AzureRmResource -ResourceId (Get-AzureRmKeyVault -ResourceGroupName {RGName} -VaultName {keyVaultName}).ResourceId).Properties| Add-Member -MemberType "NoteProperty" -Name "enableSoftDelete" -Value "true"-Force | Add-Member -MemberType "NoteProperty" -Name "enablePurgeProtection" -Value "true" -Force
197-
```
198-
2. Set the key vault access policy so that the managed identity of the Event Hubs namespace can access key value in the key vault. Use the ID of the Event Hubs namespace from the previous section.
207+
1. Set the key vault access policy so that the managed identity of the Event Hubs namespace can access key value in the key vault. Use the ID of the Event Hubs namespace from the previous section.
199208
200209
```powershell
201210
$identity = (Get-AzureRmResource -ResourceId $EventHubNamespaceId -ExpandProperties).Identity
@@ -293,6 +302,8 @@ In this step, you will update the Event Hubs namespace with key vault informatio
293302
> - `<KeyVaultName>` - Name of your key vault
294303
> - `<KeyName>` - Name of the key in the key vault
295304
305+
# [Key Vault](#tab/Key-Vault)
306+
296307
```json
297308
{
298309
"$schema":"https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
@@ -315,7 +326,33 @@ In this step, you will update the Event Hubs namespace with key vault informatio
315326
}
316327
}
317328
}
318-
```
329+
```
330+
331+
# [Key Vault Managed HSM](#tab/Key-Vault-Managed-HSM)
332+
333+
```json
334+
{
335+
"$schema":"https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
336+
"contentVersion":"1.0.0.0",
337+
"parameters":{
338+
"namespaceName":{
339+
"value":"<ServiceBusNamespaceName>"
340+
},
341+
"location":{
342+
"value":"<Location>"
343+
},
344+
"keyName":{
345+
"value":"<KeyName>"
346+
},
347+
"keyVaultUri":{
348+
"value":"https://<KeyVaultName>.managedhsm.azure.net"
349+
}
350+
}
351+
}
352+
```
353+
354+
---
355+
319356
3. Run the following PowerShell command to deploy the Resource Manager template. Replace `{MyRG}` with the name of your resource group before running the command.
320357
321358
```powershell
@@ -334,27 +371,14 @@ Follow instructions from the [Create a user-assigned managed identity](../active
334371
> [!NOTE]
335372
> You can assign up to **4** user identities to a namespace. These associations are deleted when the namespace is deleted or when you pass the `identity -> type` in the template to `None`.
336373
337-
### Create a key vault and grant access to user-assigned identity
338-
339-
1. Run the following command to create a key vault with purge protection and soft-delete enabled.
340-
341-
```azurepowershell-interactive
342-
New-AzureRmKeyVault -Name "{keyVaultName}" -ResourceGroupName {RGName} -Location "{location}" -EnableSoftDelete -EnablePurgeProtection
343-
```
344-
345-
(OR)
346-
347-
Run the following command to update an existing key vault. Specify values for resource group and key vault names before running the command.
374+
### Ggrant access to user-assigned identity
348375
349-
```azurepowershell-interactive
350-
($updatedKeyVault = Get-AzureRmResource -ResourceId (Get-AzureRmKeyVault -ResourceGroupName {RGName} -VaultName {keyVaultName}).ResourceId).Properties| Add-Member -MemberType "NoteProperty" -Name "enableSoftDelete" -Value "true"-Force | Add-Member -MemberType "NoteProperty" -Name "enablePurgeProtection" -Value "true" -Force
351-
```
352-
2. Get the **Service principal ID** for the user identity using the following PowerShell command. In the example, `ud1` is the user-assigned identity to be used for encryption.
376+
1. Get the **Service principal ID** for the user identity using the following PowerShell command. In the example, `ud1` is the user-assigned identity to be used for encryption.
353377
354378
```azurepowershell-interactive
355379
$servicePrincipal=Get-AzADServicePrincipal -SearchString "ud1"
356380
```
357-
3. Grant the user-assigned identity access to the key vault by assigning an access policy.
381+
1. Grant the user-assigned identity access to the key vault by assigning an access policy.
358382
359383
```azurepowershell-interactive
360384
Set-AzureRmKeyVaultAccessPolicy -VaultName {keyVaultName} -ResourceGroupName {RGName} -ObjectId $servicePrincipal.Id -PermissionsToKeys get,wrapKey,unwrapKey,list
@@ -393,7 +417,6 @@ This section gives you an example that shows you how to do the following tasks u
393417
}
394418
```
395419
396-
397420
1. Create a JSON file named **CreateEventHubsNamespaceWithUserIdentityAndEncryption.json** with the following content:
398421
399422
```json
@@ -488,6 +511,8 @@ This section gives you an example that shows you how to do the following tasks u
488511
```
489512
1. Create a template parameter file: **CreateEventHubsNamespaceWithUserIdentityAndEncryptionParams.json**.
490513
514+
# [Key Vault](#tab/Key-Vault)
515+
491516
```json
492517
{
493518
"$schema":"https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
@@ -514,6 +539,36 @@ This section gives you an example that shows you how to do the following tasks u
514539
}
515540
```
516541
542+
# [Key Vault Managed HSM](#tab/Key-Vault-Managed-HSM)
543+
544+
```json
545+
{
546+
"$schema":"https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
547+
"contentVersion":"1.0.0.0",
548+
"parameters":{
549+
"namespaceName":{
550+
"value":"<ServiceBusNamespaceName>"
551+
},
552+
"location":{
553+
"value":"<Location>"
554+
},
555+
"keyVaultUri":{
556+
"value":"https://<KeyVaultName>.managedhsm.azure.net"
557+
},
558+
"keyName":{
559+
"value":"<KeyName>"
560+
},
561+
"identity": {
562+
"value": {
563+
"userAssignedIdentity": "/subscriptions/<AZURE SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<USER MANAGED IDENTITY NAME>"
564+
}
565+
}
566+
}
567+
}
568+
```
569+
570+
---
571+
517572
In the parameter file, replace placeholders with appropriate values.
518573
519574
| Placeholder | value |

0 commit comments

Comments
 (0)