You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Configure your own key for encrypting Azure Event Hubs data at rest
3
3
description: This article provides information on how to configure your own key for encrypting Azure Event Hubs data rest.
4
4
ms.topic: conceptual
5
-
ms.date: 08/18/2021
5
+
ms.date: 05/13/2024
6
6
---
7
7
8
8
# 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
12
12
> - The BYOK capability is supported by **premium** and **dedicated** tiers of Event Hubs.
13
13
> - The encryption can be enabled only for new or empty namespaces. If the namespace contains event hubs, the encryption operation will fail.
14
14
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)
16
16
17
17
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).
18
18
@@ -25,24 +25,45 @@ To enable customer-managed keys in the Azure portal, follow these steps. If you
> Currently you can't configure Azure Key Vault Managed HSM through the portal.
30
+
28
31
## Set up a key vault with keys
29
32
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).
30
33
31
34
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).
32
35
33
36
> [!IMPORTANT]
34
37
> 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.
35
-
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.
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.
39
+
# [Key Vault](#tab/Key-Vault)
41
40
42
-
```azurecli-interactive
43
-
az keyvault update --name ContosoVault --resource-group ContosoRG --enable-purge-protection true
44
-
```
45
-
1. Create keys by following these steps:
41
+
2. 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.
3. 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.
47
+
48
+
```azurecli-interactive
49
+
az keyvault update --name ContosoVault --resource-group ContosoRG --enable-purge-protection true
2. 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.
3. 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
+
4. Create keys by following these steps:
46
67
1. To create a new key, select **Generate/Import** from the **Keys** menu under **Settings**.
@@ -65,15 +86,13 @@ There are two types of managed identities that you can assign to an Event Hubs n
65
86
66
87
For more information, see [What are managed identities for Azure resources?](../active-directory/managed-identities-azure-resources/overview.md).
67
88
68
-
69
89
## Encrypt using system-assigned identities (template)
70
90
This section shows how to do the following tasks using **Azure Resource Manager templates**.
71
91
72
92
1. Create an **Event Hubs namespace** with a managed service identity.
73
93
2. Create a **key vault** and grant the service identity access to the key vault.
74
94
3. Update the Event Hubs namespace with the key vault information (key/value).
75
95
76
-
77
96
### Create an Event Hubs cluster and namespace with managed service identity
78
97
This section shows you how to create an Azure Event Hubs namespace with managed service identity by using an Azure Resource Manager template and PowerShell.
79
98
@@ -182,26 +201,13 @@ This section shows you how to create an Azure Event Hubs namespace with managed
182
201
183
202
### Grant Event Hubs namespace identity access to key vault
184
203
185
-
1. Run the following command to create a key vault with **purge protection** and **soft-delete** enabled.
204
+
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.
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.
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.
320
353
321
354
```powershell
@@ -334,27 +367,14 @@ Follow instructions from the [Create a user-assigned managed identity](../active
334
367
> [!NOTE]
335
368
> 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`.
336
369
337
-
### Create a key vault and grant access to user-assigned identity
370
+
### Grant access to user-assigned identity
338
371
339
-
1. Run the following command to create a key vault with purge protection and soft-delete enabled.
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.
372
+
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.
"userAssignedIdentity": "/subscriptions/<AZURE SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<USER MANAGED IDENTITY NAME>"
560
+
}
561
+
}
562
+
}
563
+
}
564
+
```
565
+
---
516
566
517
567
In the parameter file, replace placeholders with appropriate values.
518
568
@@ -526,13 +576,12 @@ This section gives you an example that shows you how to do the following tasks u
526
576
|`<RESOURCE GROUP NAME>`| Resource group of the user-managed identity. |
527
577
|`<USER MANAGED IDENTITY NAME>`| Name of the user-managed identity. |
528
578
529
-
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.
579
+
1. Run the following PowerShell command to deploy the Resource Manager template. Replace `{MyRG}` with the name of your resource group before running the command.
## Use both user-assigned and system-assigned identities
537
586
A namespace can have both system-assigned and user-assigned identities at the same time. In this case, the `type` property would be `SystemAssigned`, `UserAssigned` as shown in the following example.
0 commit comments