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
Copy file name to clipboardExpand all lines: articles/service-bus-messaging/configure-customer-managed-key.md
+66-51Lines changed: 66 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,14 +15,15 @@ There are some caveats to the customer managed key for service side encryption.
15
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)
16
16
17
17
## Enable customer-managed keys (Azure portal)
18
+
18
19
To enable customer-managed keys in the Azure portal, follow these steps:
19
20
20
21
1. Navigate to your Service Bus Premium namespace.
21
-
2. On the **Settings** page of your Service Bus namespace, select **Encryption**.
22
-
3. Select the **Customer-managed key encryption at rest** as shown in the following image.
1. On the **Settings** page of your Service Bus namespace, select **Encryption**.
23
+
1. Select the **Customer-managed key encryption at rest** as shown in the following image.
25
24
25
+

26
+
26
27
> [!NOTE]
27
28
> Currently you can't configure Azure Key Vault Managed HSM through the portal.
28
29
@@ -36,49 +37,52 @@ After you enable customer-managed keys, you need to associate the customer manag
36
37
> 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
38
39
# [Key Vault](#tab/Key-Vault)
39
-
40
+
40
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.
46
-
47
-
```azurecli-interactive
48
-
az keyvault update --name contoso-SB-BYOK-keyvault --resource-group ContosoRG --enable-purge-protection true
49
-
```
50
-
48
+
49
+
```azurecli-interactive
50
+
az keyvault update --name contoso-SB-BYOK-keyvault --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.
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
-
4. Create keys by following these steps:
66
-
1. To create a new key, select **Generate/Import** from the **Keys** menu under **Settings**.
1. Set **Options** to **Generate** and give the key a name.
71
-
72
-

63
+
```azurecli-interactive
64
+
az keyvault update --hsm-name contoso-SB-BYOK-keyvault --resource-group ContosoRG --enable-purge-protection true
65
+
```
66
+
---
73
67
74
-
1. You can now select this key to associate with the Service Bus namespace for encrypting from the drop-down list.
68
+
Create keys by following these steps:
75
69
76
-

77
-
> [!NOTE]
78
-
> 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.
70
+
1. To create a new key, select **Generate/Import** from the **Keys** menu under **Settings**.
71
+
72
+

73
+
74
+
1. Set **Options** to **Generate** and give the key a name.
75
+
76
+

77
+
78
+
1. You can now select this key to associate with the Service Bus namespace for encrypting from the drop-down list.
79
+
80
+

81
+
82
+
> [!NOTE]
83
+
> 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.
79
84
80
-
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).
81
-
85
+
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).
82
86
83
87
> [!IMPORTANT]
84
88
> If you are looking to use Customer managed key along with [Geo-Disaster Recovery](service-bus-geo-dr.md), please review this section.
@@ -105,16 +109,18 @@ There are two types of managed identities that you can assign to a Service Bus n
105
109
-**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.
106
110
-**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.
107
111
108
-
For more information, see [What are managed identities for Azure resources?](../active-directory/managed-identities-azure-resources/overview.md).
112
+
For more information, see [What are managed identities for Azure resources?](../active-directory/managed-identities-azure-resources/overview.md).
109
113
110
114
## Encrypt using system-assigned identities (template)
111
-
This section shows how to do the following tasks:
112
115
113
-
1. Create a **premium** Service Bus namespace with a **managed service identity**.
114
-
2. Create a **key vault** and grant the service identity access to the key vault.
115
-
3. Update the Service Bus namespace with the key vault information (key/value).
116
+
This section shows you how to do the following tasks:
117
+
118
+
- Create a **premium** Service Bus namespace with a **managed service identity**.
119
+
- Create a **key vault** and grant the service identity access to the key vault.
120
+
- Update the Service Bus namespace with the key vault information (key/value).
116
121
117
122
### Create a premium Service Bus namespace with managed service identity
123
+
118
124
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.
119
125
120
126
1. Create an Azure Resource Manager template to create a Service Bus premium tier namespace with a managed service identity. Name the file: **CreateServiceBusPremiumNamespace.json**:
### Encrypt data in Service Bus namespace with customer-managed key from key vault
214
+
208
215
You have done the following steps so far:
209
216
210
217
1. Created a premium namespace with a managed identity.
@@ -344,6 +351,7 @@ In this step, you update the Service Bus namespace with key vault information.
344
351
1. Create a **premium** Service Bus namespace with the managed user-identity and the key vault information.
345
352
346
353
### Create a user-assigned identity
354
+
347
355
Follow instructions from the [Create a user-assigned managed identity](../active-directory/managed-identities-azure-resources/how-to-manage-ua-identity-portal.md#create-a-user-assigned-managed-identity) article to create a user-assigned identity. You can also create a user-assigned identity using [CLI](../active-directory/managed-identities-azure-resources/how-to-manage-ua-identity-cli.md), [PowerShell](../active-directory/managed-identities-azure-resources/how-to-manage-ua-identity-powershell.md), [Azure Resource Manager template](../active-directory/managed-identities-azure-resources/how-to-manage-ua-identity-arm.md), and [REST](../active-directory/managed-identities-azure-resources/how-to-manage-ua-identity-rest.md).
348
356
349
357
> [!NOTE]
@@ -550,6 +558,7 @@ This section gives you an example that shows you how to do the following tasks u
550
558
```
551
559
552
560
## Use both user-assigned and system-assigned identities
561
+
553
562
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.
554
563
555
564
```json
@@ -599,6 +608,7 @@ See the following example for using the user-managed identity for the encryption
599
608
```
600
609
601
610
## Enable infrastructure (double) encryption of data
611
+
602
612
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.
603
613
604
614
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.
@@ -644,10 +654,9 @@ Here are more details:
644
654
645
655
## Considerations when using Geo-Disaster Recovery
646
656
647
-
### Geo-Disaster Recovery - encryption with system-assigned identities
657
+
### Encryption with system-assigned identities
648
658
To enable encryption of Microsoft-managed key with a customer managed key, an [access policy](/azure/key-vault/general/secure-your-key-vault) 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:
649
659
650
-
651
660
- 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
652
661
- Break the pairing.
653
662
-[Set up the access policy](/azure/key-vault/general/assign-access-policy-portal) for the system-assigned managed identity for both the primary and secondary namespaces to the key vault.
@@ -657,30 +666,36 @@ To enable encryption of Microsoft-managed key with a customer managed key, an [a
657
666
-[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.
658
667
- Pair the primary and secondary namespaces.
659
668
660
-
### Geo-Disaster Recovery - encryption with user-assigned identities
669
+
### Encryption with user-assigned identities
670
+
661
671
Here are a few recommendations:
662
672
663
-
1. Create managed identity and assign Key Vault permissions to your managed identity.
664
-
2. Add the identity as a user assigned identity, and enable encryption with the identity on both namespaces.
665
-
3. Pair namespaces together
673
+
-Create managed identity and assign Key Vault permissions to your managed identity.
674
+
-Add the identity as a user assigned identity, and enable encryption with the identity on both namespaces.
675
+
-Pair namespaces together.
666
676
667
677
Conditions for enabling Geo-Disaster Recovery and Encryption with User-Assigned Identities:
668
678
669
-
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.
670
-
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.
679
+
- 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.
680
+
- 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.
671
681
672
682
## Troubleshoot
673
683
674
684
### Symptom
685
+
675
686
You get an error stating that the Service Bus namespace is disabled because the encryption key is no longer valid.
676
687
677
688
### Cause
689
+
678
690
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.
679
691
680
692
### Resolution
693
+
681
694
Use the [`resource__versionless_id` or `versionless_id`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_key#attributes-reference) instead of using `resource_id` or `version`.
682
695
683
696
## Next steps
697
+
684
698
See the following articles:
699
+
685
700
-[Service Bus overview](service-bus-messaging-overview.md)
0 commit comments