Skip to content

Commit a10fe13

Browse files
Merge pull request #294000 from spelluru/sbuscmk0203
Service Bus - Key Vault managed HSM updates
2 parents b2883f6 + 73fe32e commit a10fe13

File tree

1 file changed

+48
-47
lines changed

1 file changed

+48
-47
lines changed

articles/service-bus-messaging/configure-customer-managed-key.md

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
title: Configure your own key for encrypting Azure Service Bus data at rest
33
description: This article provides information on how to configure your own key for encrypting Azure Service Bus data rest.
44
ms.topic: conceptual
5-
ms.date: 05/13/2024
5+
ms.date: 02/03/2025
66
---
77

88
# Configure customer-managed keys for encrypting Azure Service Bus data at rest
9-
Azure Service Bus Premium provides encryption of data at rest with Azure Storage Service Encryption (Azure SSE). Service Bus Premium uses Azure Storage to store the data. All the data that's stored with Azure Storage is encrypted using Microsoft-managed keys. If you use your own key (also referred to as Bring Your Own Key (BYOK) or customer-managed key), the data is still encrypted using the Microsoft-managed key, but in addition the Microsoft-managed key is encrypted using the customer-managed key. This feature enables you to create, rotate, disable, and revoke access to customer-managed keys that are used for encrypting Microsoft-managed keys. Enabling the BYOK feature is a one time setup process on your namespace.
9+
Azure Service Bus Premium provides encryption of data at rest with Azure Storage Service Encryption (Azure SSE). Service Bus Premium uses Azure Storage to store the data. All the data that's stored in Azure Storage is encrypted using Microsoft-managed keys. If you use your own key (also referred to as Bring Your Own Key (BYOK) or customer-managed key), the data is still encrypted using the Microsoft-managed key, but in addition the Microsoft-managed key is encrypted using the customer-managed key. This feature enables you to create, rotate, disable, and revoke access to customer-managed keys that are used for encrypting Microsoft-managed keys. Enabling the BYOK feature is a one time setup process on your namespace.
1010

1111
There are some caveats to the customer managed key for service side encryption.
1212
- This feature is supported by [Azure Service Bus Premium](service-bus-premium-messaging.md) tier. It can't be enabled for standard tier Service Bus namespaces.
1313
- The encryption can only be enabled for new or empty namespaces. If the namespace contains any queues or topics, then the encryption operation fails.
1414

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?](/azure/key-vault/general/overview)
15+
You can use Azure Key Vault (including Azure Key Vault Managed Hardware Security Module (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?](/azure/key-vault/general/overview)
1616

17-
If you only need to encrypt certain properties of your messages, consider using a library like [NServiceBus](https://docs.particular.net/nservicebus/security/property-encryption) for that.
17+
If you only need to encrypt certain properties of your messages, consider using a library like [NServiceBus](https://docs.particular.net/nservicebus/security/property-encryption).
1818

1919
## Enable customer-managed keys (Azure portal)
2020

@@ -33,83 +33,84 @@ To enable customer-managed keys in the Azure portal, follow these steps:
3333

3434
After you enable customer-managed keys, you need to associate the customer managed key with your Azure Service Bus namespace. Service Bus 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](/azure/key-vault/general/key-vault-recovery) or [CLI](/azure/key-vault/general/key-vault-recovery).
3535

36-
1. To create a new key vault, follow the Azure Key Vault [Quickstart](/azure/key-vault/general/overview). For more information about importing existing keys, see [About keys, secrets, and certificates](/azure/key-vault/general/about-keys-secrets-certificates).
36+
### Create key vault or key vault managed HSM
3737

38-
> [!IMPORTANT]
39-
> Using customer-managed keys with Azure Service Bus requires that the key vault have two required properties configured. They are: **Soft Delete** and **Do Not Purge**. The Soft Delete property is enabled by default when you create a new key vault in the Azure portal whereas the Purge Protection is optional so make sure to select it when creating the Key Vault. Also, if you need to enable these properties on an existing key vault, you must use either PowerShell or Azure CLI.
38+
> [!IMPORTANT]
39+
> Using customer-managed keys with Azure Service Bus requires that the vault have two required properties configured. They are: **Soft Delete** and **Do Not Purge**. The Soft Delete property is enabled by default when you create a new vault in the Azure portal whereas the Purge Protection is optional so make sure to select it when creating the vault. Also, if you need to enable these properties on an existing key vault, you must use either PowerShell or Azure CLI.
4040
4141
# [Key Vault](#tab/Key-Vault)
42+
43+
- To create a new Key Vault, follow the Azure Key Vault [Quickstart](/azure/key-vault/general/quick-create-cli). For information about Azure KeyVault, see [About Azure KeyVault](/azure/key-vault/general/overview).
44+
- 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.
4245

43-
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.
44-
45-
```azurecli-interactive
46-
az keyvault create --name contoso-SB-BYOK-keyvault --resource-group ContosoRG --location westus --enable-soft-delete true --enable-purge-protection true
47-
```
48-
49-
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.
46+
```azurecli-interactive
47+
az keyvault create --name contoso-SB-BYOK-keyvault --resource-group ContosoRG --location westus --enable-soft-delete true --enable-purge-protection true
48+
```
49+
- 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.
5050
51-
```azurecli-interactive
52-
az keyvault update --name contoso-SB-BYOK-keyvault --resource-group ContosoRG --enable-purge-protection true
53-
```
51+
```azurecli-interactive
52+
az keyvault update --name contoso-SB-BYOK-keyvault --resource-group ContosoRG --enable-purge-protection true
53+
```
5454
5555
# [Key Vault Managed HSM](#tab/Key-Vault-Managed-HSM)
56+
57+
- To create a new Managed HSM, follow the Managed HSM [Quickstart](/azure/key-vault/managed-hsm/quick-create-cli). For information about Azure KeyVault, see [About Azure KeyVault](/azure/key-vault/general/overview).
58+
- 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.
5659
57-
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.
58-
59-
```azurecli-interactive
60-
az keyvault create --hsm-name contoso-SB-BYOK-keyvault --resource-group ContosoRG --location westus --enable-soft-delete true --enable-purge-protection true
61-
```
60+
```azurecli-interactive
61+
az keyvault create --hsm-name contoso-SB-BYOK-keyvault --resource-group ContosoRG --location westus --enable-purge-protection true --retention-days 90 --administrators aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb
62+
```
6263
63-
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.
64+
After creation, you need to [activate the Managed HSM](/azure/key-vault/managed-hsm/quick-create-cli#activate-your-managed-hsm) and ensure that you have the correct permissions to generate keys by [assigning an RBAC role and local RBAC role](/azure/key-vault/managed-hsm/secure-your-managed-hsm) with the correct permissions.
65+
- 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.
6466
65-
```azurecli-interactive
66-
az keyvault update --hsm-name contoso-SB-BYOK-keyvault --resource-group ContosoRG --enable-purge-protection true
67-
```
67+
```azurecli-interactive
68+
az keyvault update --hsm-name contoso-SB-BYOK-keyvault --resource-group ContosoRG --enable-purge-protection true
69+
```
70+
6871
---
6972
73+
## Create keys
7074
Create keys by following these steps:
7175
7276
1. To create a new key, select **Generate/Import** from the **Keys** menu under **Settings**.
7377
74-
![Screenshot showing the Generate/Import button.](./media/configure-customer-managed-key/select-generate-import.png)
75-
78+
![Screenshot showing the Generate/Import button.](./media/configure-customer-managed-key/select-generate-import.png)
7679
1. Set **Options** to **Generate** and give the key a name.
7780
78-
![Screenshot that shows how to name a key.](./media/configure-customer-managed-key/create-key.png)
79-
81+
![Screenshot that shows how to name a key.](./media/configure-customer-managed-key/create-key.png)
8082
1. You can now select this key to associate with the Service Bus namespace for encrypting from the drop-down list.
8183
8284
![Screenshot that shows how to select a key from key vault.](./media/configure-customer-managed-key/select-key-from-key-vault.png)
8385
8486
> [!NOTE]
85-
> For redundancy, you can add up to 3 keys. In the event that one of the keys has expired, or is not accessible, the other keys will be used for encryption.
86-
87-
1. Fill in the details for the key and click **Select**. This enables the encryption of the Microsoft-managed key with your key (customer-managed key).
87+
> For redundancy, you can add up to three keys. If one of the keys is expired, or isn't accessible, the other keys are used for encryption.
88+
1. Fill in the details for the key and click **Select**. It enables the encryption of the Microsoft-managed key with your key (customer-managed key).
8889
8990
> [!IMPORTANT]
90-
> If you are looking to use Customer managed key along with [Geo-Disaster Recovery](service-bus-geo-dr.md), please review this section.
91+
> If you're looking to use Customer managed key along with [Geo-Disaster Recovery](service-bus-geo-dr.md), review this section.
9192
>
9293
> To enable encryption of Microsoft-managed key with a customer managed key, an [access policy](/azure/key-vault/general/security-features) is set up for the Service Bus' managed identity on the specified Azure KeyVault. This ensures controlled access to the Azure KeyVault from the Azure Service Bus namespace.
9394
>
94-
> Due to this:
95+
> Due to this behavior:
9596
>
96-
> * If [Geo-Disaster Recovery](service-bus-geo-dr.md) is already enabled for the Service Bus namespace and you are looking to enable customer managed key, then
97+
> * If [Geo-Disaster Recovery](service-bus-geo-dr.md) is already enabled for the Service Bus namespace and you're looking to enable customer managed key, then
9798
> * Break the pairing
9899
> * [Set up the access policy](/azure/key-vault/general/assign-access-policy-portal) for the managed identity for both the primary and secondary namespaces to the key vault.
99100
> * Set up encryption on the primary namespace.
100101
> * Re-pair the primary and secondary namespaces.
101102
>
102-
> * If you are looking to enable Geo-Disaster Recovery on a Service Bus namespace where customer managed key is already set up, then -
103+
> * If you're looking to enable Geo-Disaster Recovery on a Service Bus namespace where customer managed key is already set up, then -
103104
> * [Set up the access policy](/azure/key-vault/general/assign-access-policy-portal) for the managed identity for the secondary namespace to the key vault.
104105
> * Pair the primary and secondary namespaces.
105106
>
106-
> * Once paired, the secondary namespace will use the key vault configured for the primary namespace. If the key vault for both namespaces is different before Geo-Disaster Recovery pairing, the user must delegate an access policy or RBAC role for the managed identity of the secondary namespace in the key vault associated with primary namespace.
107+
> * Once paired, the secondary namespace uses the key vault configured for the primary namespace. If the key vault for both namespaces is different before Geo-Disaster Recovery pairing, the user must delegate an access policy or RBAC role for the managed identity of the secondary namespace in the key vault associated with primary namespace.
107108
108109
## Managed identities
109110
There are two types of managed identities that you can assign to a Service Bus namespace.
110111
111112
- **System-assigned**: You can enable a managed identity directly on a Service Bus namespace. When you enable a system-assigned managed identity, an identity is created in Microsoft Entra that's tied to the lifecycle of that Service Bus namespace. So when the namespace is deleted, Azure automatically deletes the identity for you. By design, only that Azure resource (namespace) can use this identity to request tokens from Microsoft Entra ID.
112-
- **User-assigned**: You may also create a managed identity as a standalone Azure resource, which is called user-assigned identity. You can create a user-assigned managed identity and assign it to one or more Service Bus namespaces. When you use user-assigned managed identities, the identity is managed separately from the resources that use it. They aren't tied to the lifecycle of the namespace. You can explicitly delete a user-assigned identity when you no longer need it.
113+
- **User-assigned**: You can also create a managed identity as a standalone Azure resource, which is called user-assigned identity. You can create a user-assigned managed identity and assign it to one or more Service Bus namespaces. When you use user-assigned managed identities, the identity is managed separately from the resources that use it. They aren't tied to the lifecycle of the namespace. You can explicitly delete a user-assigned identity when you no longer need it.
113114
114115
For more information, see [What are managed identities for Azure resources?](../active-directory/managed-identities-azure-resources/overview.md).
115116
@@ -214,7 +215,7 @@ Set-AzureRmKeyVaultAccessPolicy -VaultName {keyVaultName} -ResourceGroupName {RG
214215

215216
### Encrypt data in Service Bus namespace with customer-managed key from key vault
216217

217-
You have done the following steps so far:
218+
You did the following steps so far:
218219

219220
1. Created a premium namespace with a managed identity.
220221
1. Create a key vault and granted the managed identity access to the key vault.
@@ -613,9 +614,9 @@ See the following example for using the user-managed identity for the encryption
613614

614615
If you require a higher level of assurance that your data is secure, you can enable infrastructure level encryption, which is also known as Double Encryption.
615616

616-
When infrastructure encryption is enabled, data in the Azure Service Bus is encrypted twice, once at the service level and once at the infrastructure level, using two different encryption algorithms and two different keys. Hence, infrastructure encryption of Azure Service Bus data protects against a scenario where one of the encryption algorithms or keys may be compromised.
617+
When infrastructure encryption is enabled, data in the Azure Service Bus is encrypted twice, once at the service level and once at the infrastructure level, using two different encryption algorithms and two different keys. Hence, infrastructure encryption of Azure Service Bus data protects against a scenario where one of the encryption algorithms or keys can be compromised.
617618

618-
You can enable infrastructure encryption by updating the Azure Resource Manager template with `requireInfrastructureEncryption` property in the above **UpdateServiceBusNamespaceWithEncryption.json** as shown below.
619+
You can enable infrastructure encryption by updating the Azure Resource Manager template with `requireInfrastructureEncryption` property in the **UpdateServiceBusNamespaceWithEncryption.json** as shown in the following example.
619620

620621
```json
621622
"properties":{
@@ -645,14 +646,14 @@ Revoking access to the encryption keys won't purge the data from Service Bus. Ho
645646
Once the encryption key is revoked, the Service Bus service on the encrypted namespace becomes inoperable. If the access to the key is enabled or the deleted key is restored, Service Bus service picks the key so you can access the data from the encrypted Service Bus namespace.
646647

647648
### Caching of keys
648-
The Service Bus instance polls its listed encryption keys every 5 minutes. It caches and uses them until the next poll, which is after 5 minutes. As long as at least one key is available, queues and topics are accessible. If all listed keys are inaccessible when it polls, all queues and topics become unavailable.
649+
The Service Bus instance polls its listed encryption keys every 5 minutes. It caches and uses them until the next poll, which is after 5 minutes. As long as at least one key is available, queues, and topics are accessible. If all listed keys are inaccessible when it polls, all queues and topics become unavailable.
649650

650651
Here are more details:
651652

652653
- Every 5 minutes, the Service Bus service polls all customer-managed keys listed in the namespace’s record:
653-
- If a key has been rotated, the record is updated with the new key.
654-
- If a key has been revoked, the key is removed from the record.
655-
- If all keys have been revoked, the namespace’s encryption status is set to **Revoked**. The data can't be accessed from the Service Bus namespace.
654+
- If a key was rotated, the record is updated with the new key.
655+
- If a key was revoked, the key is removed from the record.
656+
- If all keys were revoked, the namespace’s encryption status is set to **Revoked**. The data can't be accessed from the Service Bus namespace.
656657

657658
## Considerations when using Geo-Disaster Recovery
658659

@@ -689,7 +690,7 @@ You get an error stating that the Service Bus namespace is disabled because the
689690

690691
### Cause
691692

692-
You may be using the `resource_id` or `version`, which links to a specific version of the key, which may have expired. If a specific version is provided, Service Bus uses that version of the key, even if the key is rotated.
693+
You're be using the `resource_id` or `version`, which links to a specific version of the key, which is expired. If a specific version is provided, Service Bus uses that version of the key, even if the key is rotated.
693694

694695
### Resolution
695696

0 commit comments

Comments
 (0)