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 Service Bus data at rest
3
3
description: This article provides information on how to configure your own key for encrypting Azure Service Bus data rest.
4
4
ms.topic: conceptual
5
-
ms.date: 06/26/2023
5
+
ms.date: 05/13/2024
6
6
---
7
7
8
8
# Configure customer-managed keys for encrypting Azure Service Bus data at rest
@@ -12,7 +12,7 @@ There are some caveats to the customer managed key for service side encryption.
12
12
- 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.
13
13
- The encryption can only be enabled for new or empty namespaces. If the namespace contains any queues or topics, then the encryption operation fails.
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
## Enable customer-managed keys (Azure portal)
18
18
To enable customer-managed keys in the Azure portal, follow these steps:
@@ -23,6 +23,8 @@ To enable customer-managed keys in the Azure portal, follow these steps:
> Currently you can't configure Azure Key Vault Managed HSM through the portal.
26
28
27
29
## Set up a key vault with keys
28
30
@@ -32,6 +34,9 @@ After you enable customer-managed keys, you need to associate the customer manag
32
34
33
35
> [!IMPORTANT]
34
36
> 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.
37
+
38
+
# [Key Vault](#tab/Key-Vault)
39
+
35
40
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.
36
41
37
42
```azurecli-interactive
@@ -42,6 +47,22 @@ After you enable customer-managed keys, you need to associate the customer manag
42
47
```azurecli-interactive
43
48
az keyvault update --name contoso-SB-BYOK-keyvault --resource-group ContosoRG --enable-purge-protection true
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.
59
+
60
+
```azurecli-interactive
61
+
az keyvault update --hsm-name contoso-SB-BYOK-keyvault --resource-group ContosoRG --enable-purge-protection true
62
+
```
63
+
64
+
---
65
+
45
66
1. Create keys by following these steps:
46
67
1. To create a new key, select **Generate/Import** from the **Keys** menu under **Settings**.
47
68
@@ -61,23 +82,23 @@ After you enable customer-managed keys, you need to associate the customer manag
61
82
62
83
63
84
> [!IMPORTANT]
64
-
> If you are looking to use Customer managed key along with Geo disaster recovery, please review this section.
85
+
> If you are looking to use Customer managed key along with [Geo-Disaster Recovery](service-bus-geo-dr.md), please review this section.
65
86
>
66
87
> To enable encryption of Microsoft-managed key with a customer managed key, an [access policy](../key-vault/general/security-features.md) 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.
67
88
>
68
89
> Due to this:
69
90
>
70
-
> * 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
91
+
> * 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
71
92
> * Break the pairing
72
93
> * [Set up the access policy](../key-vault/general/assign-access-policy-portal.md) for the managed identity for both the primary and secondary namespaces to the key vault.
73
94
> * Set up encryption on the primary namespace.
74
95
> * Re-pair the primary and secondary namespaces.
75
96
>
76
-
> * If you are looking to enable Geo-DR on a Service Bus namespace where customer managed key is already set up, then -
97
+
> * If you are looking to enable Geo-Disaster Recovery on a Service Bus namespace where customer managed key is already set up, then -
77
98
> * [Set up the access policy](../key-vault/general/assign-access-policy-portal.md) for the managed identity for the secondary namespace to the key vault.
78
99
> * Pair the primary and secondary namespaces.
79
100
>
80
-
> * 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-DR 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.
101
+
> * 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.
81
102
82
103
## Managed identities
83
104
There are two types of managed identities that you can assign to a Service Bus namespace.
@@ -92,7 +113,7 @@ This section shows how to do the following tasks:
92
113
93
114
1. Create a **premium** Service Bus namespace with a **managed service identity**.
94
115
2. Create a **key vault** and grant the service identity access to the key vault.
95
-
3. Update the Service Bus namespace with the key vault information (key/value).
116
+
3. Update the Service Bus namespace with the key vault information (key/value).
96
117
97
118
### Create a premium Service Bus namespace with managed service identity
98
119
This section shows you how to create an Azure Service Bus namespace with managed service identity by using an Azure Resource Manager template and PowerShell.
@@ -145,7 +166,7 @@ This section shows you how to create an Azure Service Bus namespace with managed
145
166
}
146
167
}
147
168
```
148
-
2. Create a template parameter file named: **CreateServiceBusPremiumNamespaceParams.json**.
169
+
1. Create a template parameter file named: **CreateServiceBusPremiumNamespaceParams.json**.
149
170
150
171
> [!NOTE]
151
172
> Replace the following values:
@@ -166,7 +187,7 @@ This section shows you how to create an Azure Service Bus namespace with managed
166
187
}
167
188
}
168
189
```
169
-
3. Run the following PowerShell command to deploy the template to create a premium Service Bus namespace. Then, retrieve the ID of the Service Bus namespace to use it later. Replace `{MyRG}` with the name of the resource group before running the command.
190
+
1. Run the following PowerShell command to deploy the template to create a premium Service Bus namespace. Then, retrieve the ID of the Service Bus namespace to use it later. Replace `{MyRG}` with the name of the resource group before running the command.
2. Set the key vault access policy so that the managed identity of the Service Bus namespace can access key value in the key vault. Use the ID of the Service Bus namespace from the previous section.
200
+
1. Set the key vault access policy so that the managed identity of the Service Bus namespace can access key value in the key vault. Use the ID of the Service Bus namespace from the previous section.
@@ -201,7 +209,7 @@ This section shows you how to create an Azure Service Bus namespace with managed
201
209
You have done the following steps so far:
202
210
203
211
1. Created a premium namespace with a managed identity.
204
-
2. Create a key vault and granted the managed identity access to the key vault.
212
+
1. Create a key vault and granted the managed identity access to the key vault.
205
213
206
214
In this step, you update the Service Bus namespace with key vault information.
207
215
@@ -268,14 +276,16 @@ In this step, you update the Service Bus namespace with key vault information.
268
276
}
269
277
```
270
278
271
-
2. Create a template parameter file: **UpdateServiceBusNamespaceWithEncryptionParams.json**.
279
+
1. Create a template parameter file: **UpdateServiceBusNamespaceWithEncryptionParams.json**.
272
280
273
281
> [!NOTE]
274
282
> Replace the following values:
275
283
> - `<ServiceBusNamespaceName>` - Name of your Service Bus namespace
276
284
> - `<Location>` - Location of your Service Bus namespace
277
285
> - `<KeyVaultName>` - Name of your key vault
278
-
> - `<KeyName>` - Name of the key in the key vault
286
+
> - `<KeyName>` - Name of the key in the key vault
287
+
288
+
# [Key Vault](#tab/Key-Vault)
279
289
280
290
```json
281
291
{
@@ -296,8 +306,34 @@ In this step, you update the Service Bus namespace with key vault information.
296
306
}
297
307
}
298
308
}
299
-
```
300
-
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.
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.
@@ -315,27 +351,14 @@ Follow instructions from the [Create a user-assigned managed identity](../active
315
351
> [!NOTE]
316
352
> 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`.
317
353
318
-
### Create a key vault and grant access to user-assigned identity
319
-
320
-
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.
356
+
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>"
529
+
}
530
+
}
531
+
}
532
+
}
533
+
```
534
+
535
+
---
536
+
483
537
In the parameter file, replace placeholders with appropriate values.
484
538
485
539
| Placeholder | value |
@@ -592,29 +646,29 @@ Here are more details:
592
646
- If a key has been revoked, the key is removed from the record.
593
647
- 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.
594
648
595
-
## Considerations when using geo-disaster recovery
649
+
## Considerations when using Geo-Disaster Recovery
596
650
597
-
### Geo-disaster recovery - encryption with system-assigned identities
651
+
### Geo-Disaster Recovery - encryption with system-assigned identities
598
652
To enable encryption of Microsoft-managed key with a customer managed key, an [access policy](../key-vault/general/secure-your-key-vault.md) is set up for a system-assigned managed identity on the specified Azure KeyVault. This step ensures controlled access to the Azure KeyVault from the Azure Service Bus namespace. Therefore, you need to follow these steps:
599
653
600
654
601
-
- 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
655
+
- 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
602
656
- Break the pairing.
603
657
-[Set up the access policy](../key-vault/general/assign-access-policy-portal.md) for the system-assigned managed identity for both the primary and secondary namespaces to the key vault.
604
658
- Set up encryption on the primary namespace.
605
659
- Re-pair the primary and secondary namespaces.
606
-
- If you're looking to enable Geo-DR on a Service Bus namespace where customer-managed key is already set up, then follow these steps:
660
+
- If you're looking to enable Geo-Disaster Recovery on a Service Bus namespace where customer-managed key is already set up, then follow these steps:
607
661
-[Set up the access policy](../key-vault/general/assign-access-policy-portal.md) for the managed identity for the secondary namespace to the key vault.
608
662
- Pair the primary and secondary namespaces.
609
663
610
-
### Geo-disaster recovery - encryption with user-assigned identities
664
+
### Geo-Disaster Recovery - encryption with user-assigned identities
611
665
Here are a few recommendations:
612
666
613
667
1. Create managed identity and assign Key Vault permissions to your managed identity.
614
668
2. Add the identity as a user assigned identity, and enable encryption with the identity on both namespaces.
615
669
3. Pair namespaces together
616
670
617
-
Conditions for enabling Geo-DR and Encryption with User-Assigned Identities:
671
+
Conditions for enabling Geo-Disaster Recovery and Encryption with User-Assigned Identities:
618
672
619
673
1. Secondary namespace must already have Encryption enabled with a User-Assigned identity if it's to be paired with a primary namespace that has Encryption enabled.
620
674
2. It isn't possible to enable Encryption on an already paired primary, even if the secondary has a User-Assigned identity associated with the namespace.
@@ -633,4 +687,4 @@ Use the [`resource__versionless_id` or `versionless_id`](https://registry.terraf
633
687
## Next steps
634
688
See the following articles:
635
689
-[Service Bus overview](service-bus-messaging-overview.md)
0 commit comments