Skip to content

Commit 5131abc

Browse files
authored
Merge pull request #193058 from ninallam/ninallam-cmk
Customer managed keys
2 parents bf27064 + ca31518 commit 5131abc

7 files changed

+326
-0
lines changed
Lines changed: 324 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,324 @@
1+
---
2+
title: Configure customer-managed keys for encryption
3+
titleSuffix: Azure Load Testing
4+
description: Learn how to configure customer-managed keys for your Azure Load Testing resource with Azure Key Vault
5+
services: load-testing
6+
ms.service: load-testing
7+
ms.author: ninallam
8+
author: ninallam
9+
ms.date: 05/10/2022
10+
ms.topic: how-to
11+
---
12+
13+
# Configure customer-managed keys for your Azure Load Testing Preview resource with Azure Key Vault
14+
15+
Azure Load Testing Preview automatically encrypts all data stored in your load testing resource with keys that Microsoft provides (service-managed keys). Optionally, you can add a second layer of security by also providing your own (customer-managed) keys. Customer-managed keys offer greater flexibility for controlling access and using key-rotation policies.
16+
17+
The keys you provide are stored securely using [Azure Key Vault](/azure/key-vault/general/overview). You can create a separate key for each Azure Load Testing resource you enable with customer-managed keys.
18+
19+
Azure Load Testing uses the customer-managed key to encrypt the following data in the load testing resource:
20+
21+
- Test script and configuration files
22+
- Secrets
23+
- Environment variables
24+
25+
> [!IMPORTANT]
26+
> Azure Load Testing is currently in preview. For legal terms that apply to Azure features that are in beta, in preview, or otherwise not yet released into general availability, see the [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
27+
28+
## Prerequisites
29+
30+
- An Azure account with an active subscription. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
31+
32+
- An existing user-assigned managed identity. For more information about creating a user-assigned managed identity, see (Manage user-assigned managed identities)[/azure/active-directory/managed-identities-azure-resources/how-manage-user-assigned-managed-identities?pivots=identity-mi-methods-azp#create-a-user-assigned-managed-identity].
33+
34+
## Limitations
35+
36+
- Customer-managed keys are only available for new Azure Load Testing resources. You should configure the key during resource creation.
37+
38+
- Azure Load Testing cannot automatically rotate the customer-managed key to use the latest version of the encryption key. You should update the key URI in the resource after the key is rotated in the Azure Key Vault.
39+
40+
- Once customer-managed key encryption is enabled on a resource, it cannot be disabled.
41+
42+
## Configure your Azure Key Vault
43+
You can use a new or existing key vault to store customer-managed keys. The Azure Load Testing resource and key vault may be in different regions or subscriptions in the same tenant.
44+
45+
You have to set the **Soft Delete** and **Purge Protection** properties on your Azure Key Vault instance to use customer-managed keys with Azure Load Testing. Soft delete is enabled by default when you create a new key vault and cannot be disabled. You can enable purge protection at any time.
46+
47+
# [Azure portal](#tab/portal)
48+
49+
To learn how to create a key vault with the Azure portal, see [Create a key vault using the Azure portal](/azure/key-vault/general/quick-create-portal). When you create the key vault, select **Enable purge protection**, as shown in the following image.
50+
51+
:::image type="content" source="media/how-to-configure-customer-managed-keys/purge-protection-on-azure-key-vault.png" alt-text="Screenshot that shows how to enable purge protection on a new key vault.":::
52+
53+
To enable purge protection on an existing key vault, follow these steps:
54+
55+
1. Navigate to your key vault in the Azure portal.
56+
1. Under **Settings**, choose **Properties**.
57+
1. In the **Purge protection** section, choose **Enable purge protection**.
58+
59+
# [PowerShell](#tab/powershell)
60+
61+
To create a new key vault with PowerShell, install version 2.0.0 or later of the [Az.KeyVault](https://www.powershellgallery.com/packages/Az.KeyVault/2.0.0) PowerShell module. Then call [New-AzKeyVault](/powershell/module/az.keyvault/new-azkeyvault) to create a new key vault. With version 2.0.0 and later of the Az.KeyVault module, soft delete is enabled by default when you create a new key vault.
62+
63+
The following example creates a new key vault with both soft delete and purge protection enabled. Remember to replace the placeholder values in brackets with your own values.
64+
65+
```azurepowershell
66+
$keyVault = New-AzKeyVault -Name <key-vault> `
67+
-ResourceGroupName <resource_group> `
68+
-Location <location> `
69+
-EnablePurgeProtection
70+
```
71+
72+
To learn how to enable purge protection on an existing key vault with PowerShell, see [Azure Key Vault recovery overview](/azure/key-vault/general/key-vault-recovery?tabs=azure-powershell).
73+
74+
# [Azure CLI](#tab/azure-cli)
75+
76+
To create a new key vault using Azure CLI, call [az keyvault create](/cli/azure/keyvault#az-keyvault-create). Remember to replace the placeholder values in brackets with your own values:
77+
78+
```azurecli
79+
az keyvault create \
80+
--name <key-vault> \
81+
--resource-group <resource_group> \
82+
--location <region> \
83+
--enable-purge-protection
84+
```
85+
86+
To learn how to enable purge protection on an existing key vault with Azure CLI, see [Azure Key Vault recovery overview](/azure/key-vault/general/key-vault-recovery?tabs=azure-cli).
87+
88+
---
89+
90+
## Add a key
91+
92+
Next, add a key to the key vault. Azure Load Testing encryption supports RSA keys. For more information about supported key types, see [About keys](/azure/key-vault/keys/about-keys).
93+
94+
# [Azure portal](#tab/portal)
95+
96+
To learn how to add a key with the Azure portal, see [Set and retrieve a key from Azure Key Vault using the Azure portal](/azure/key-vault/keys/quick-create-portal).
97+
98+
# [PowerShell](#tab/powershell)
99+
100+
To add a key with PowerShell, call [Add-AzKeyVaultKey](/powershell/module/az.keyvault/add-azkeyvaultkey). Remember to replace the placeholder values in brackets with your own values and to use the variables defined in the previous examples.
101+
102+
```azurepowershell
103+
$key = Add-AzKeyVaultKey -VaultName $keyVault.VaultName `
104+
-Name <key> `
105+
-Destination 'Software'
106+
```
107+
108+
# [Azure CLI](#tab/azure-cli)
109+
110+
To add a key with Azure CLI, call [az keyvault key create](/cli/azure/keyvault/key#az-keyvault-key-create). Remember to replace the placeholder values in brackets with your own values.
111+
112+
```azurecli
113+
az keyvault key create \
114+
--name <key> \
115+
--vault-name <key-vault>
116+
```
117+
118+
---
119+
120+
## Add an access policy to your Azure Key Vault
121+
122+
The user-assigned managed identity that you will use to configure customer-managed keys on Azure Load Testing resource must have appropriate permissions to access the key vault.
123+
124+
1. From the Azure portal, go to the Azure Key Vault instance that you plan to use to host your encryption keys. Select **Access Policies** from the left menu:
125+
126+
:::image type="content" source="media/how-to-configure-customer-managed-keys/access-policies-azure-key-vault.png" alt-text="Screenshot that shows access policies option in Azure Key Vault.":::
127+
128+
1. Select **+ Add Access Policy**.
129+
130+
1. Under the **Key permissions** drop-down menu, select **Get**, **Unwrap Key**, and **Wrap Key** permissions:
131+
132+
:::image type="content" source="media/how-to-configure-customer-managed-keys/azure-key-vault-permissions.png" alt-text="Screenshot that shows Azure Key Vault permissions.":::
133+
134+
1. Under **Select principal**, select **None selected**.
135+
136+
1. Search for the user-assigned managed identity you created and select it.
137+
138+
1. Choose **Select** at the bottom.
139+
140+
1. Select **Add** to add the new access policy.
141+
142+
1. Select **Save** on the Key Vault instance to save all changes.
143+
144+
## Configure customer-managed keys for a new Azure Load Testing resource
145+
146+
To configure customer-managed keys for a new Azure Load Testing resource, follow these steps:
147+
148+
# [Azure portal](#tab/portal)
149+
150+
1. In the Azure portal, navigate to the **Azure Load Testing** page, and select the **Create** button to create a new resource.
151+
152+
1. Follow the steps outlined in [create an Azure Load Testing resource](/azure/load-testing/quickstart-create-and-run-load-test#create_resource) to fill out the fields on the **Basics** tab.
153+
154+
1. Go to the **Encryption** tab. In the **Encryption type** field, select **Customer-managed keys (CMK)**.
155+
156+
1. In the **Key URI** field, paste the URI/key identifier of the Azure Key Vault key including the key version.
157+
158+
1. For the **User-assigned identity** field, select an existing user-assigned managed identity.
159+
160+
1. Select **Review + create** to validate and create the new resource.
161+
162+
:::image type="content" source="media/how-to-configure-customer-managed-keys/encryption-new-azure-load-testing-resource.png" alt-text="Screenshot that shows how to enable customer managed key encryption while creating an Azure Load Testing resource.":::
163+
164+
# [PowerShell](#tab/powershell)
165+
166+
You can deploy an ARM template using PowerShell to automate the creation of your Azure resources. You can create any resource of type `Microsoft.LoadTestService/loadtests` with customer managed key enabled for encryption by adding the following properties:
167+
168+
```json
169+
"encryption": {
170+
"keyUrl": "https://contosovault.vault.azure.net/keys/contosokek/abcdef01234567890abcdef012345678",
171+
"identity": {
172+
"type": "UserAssigned",
173+
"resourceId": "User assigned managed identity resource id"
174+
}
175+
176+
```
177+
178+
For example, an Azure Load Testing resource might look like the following:
179+
180+
```json
181+
{
182+
"type": "Microsoft.LoadTestService/loadtests",
183+
"apiVersion": "2022-04-15-preview",
184+
"name": "[parameters('name')]",
185+
"location": "[parameters('location')]",
186+
"tags": "[parameters('tags')]",
187+
"identity": {
188+
"type": "userassigned",
189+
"userAssignedIdentities": {
190+
"User assigned managed identity resource id": {}
191+
}
192+
},
193+
"properties": {
194+
"encryption": {
195+
"identity": {
196+
"type": "UserAssigned",
197+
"resourceId": "User assigned managed identity resource id"
198+
},
199+
"keyUrl": "https://contosovault.vault.azure.net/keys/contosokek/abcdef01234567890abcdef012345678"
200+
}
201+
}
202+
}
203+
```
204+
205+
Deploy the above template to a resource group, using [New-AzResourceGroupDeployment](/powershell/module/az.resources/new-azresourcegroupdeployment):
206+
207+
```azurepowershell
208+
New-AzResourceGroupDeployment -ResourceGroupName <resource-group-name> -TemplateFile <path-to-template>
209+
```
210+
211+
# [Azure CLI](#tab/azure-cli)
212+
213+
You can deploy an ARM template using Azure CLI to automate the creation of your Azure resources. You can create any resource of type `Microsoft.LoadTestService/loadtests` with customer managed key enabled for encryption by adding the following properties:
214+
215+
```json
216+
"encryption": {
217+
"keyUrl": "https://contosovault.vault.azure.net/keys/contosokek/abcdef01234567890abcdef012345678",
218+
"identity": {
219+
"type": "UserAssigned",
220+
"resourceId": "User assigned managed identity resource id"
221+
}
222+
```
223+
224+
For example, an Azure Load Testing resource might look like the following:
225+
226+
```json
227+
{
228+
"type": "Microsoft.LoadTestService/loadtests",
229+
"apiVersion": "2022-04-15-preview",
230+
"name": "[parameters('name')]",
231+
"location": "[parameters('location')]",
232+
"tags": "[parameters('tags')]",
233+
"identity": {
234+
"type": "userassigned",
235+
"userAssignedIdentities": {
236+
"User assigned managed identity resource id": {}
237+
}
238+
},
239+
"properties": {
240+
"encryption": {
241+
"identity": {
242+
"type": "UserAssigned",
243+
"resourceId": "User assigned managed identity resource id"
244+
},
245+
"keyUrl": "https://contosovault.vault.azure.net/keys/contosokek/abcdef01234567890abcdef012345678"
246+
}
247+
}
248+
}
249+
```
250+
251+
Deploy the above template to a resource group, using [az deployment group create](/cli/azure/deployment/group#az-deployment-group-create):
252+
253+
```azurecli-interactive
254+
az deployment group create --resource-group <resource-group-name> --template-file <path-to-template>
255+
```
256+
257+
----
258+
259+
## Change the managed identity
260+
261+
You can change the managed identity for customer-managed keys for an existing Azure Load Testing resource at any time.
262+
263+
1. Navigate to your Azure Load Testing resource.
264+
265+
1. On the **Settings** page, select **Encryption**.
266+
267+
The **Encryption type** shows the encryption type you selected at resource creation time.
268+
269+
1. If the encryption type is **Customer-managed keys**, select the type of identity to use to authenticate to the key vault. The options include **System-assigned** (the default) or **User-assigned**.
270+
271+
To learn more about each type of managed identity, see [Managed identity types](/azure/active-directory/managed-identities-azure-resources/overview#managed-identity-types).
272+
273+
- If you select System-assigned, the system-assigned managed identity needs to be enabled on the resource and granted access to the AKV before changing the identity for customer-managed keys.
274+
- If you select **User-assigned**, you must select an existing user-assigned identity that has permissions to access the key vault. To learn how to create a user-assigned identity, see [Use managed identities for Azure Load Testing Preview](how-to-use-a-managed-identity.md).
275+
276+
1. Save your changes.
277+
278+
:::image type="content" source="media/how-to-configure-customer-managed-keys/change-identity-existing-azure-load-testing-resource.png" alt-text="Screenshot that shows how to change the managed identity for customer managed keys on an existing Azure Load Testing resource.":::
279+
280+
> [!NOTE]
281+
> The selected managed identity should have access granted on the Azure Key Vault.
282+
283+
## Change the key
284+
285+
You can change the key that you are using for Azure Load Testing encryption at any time. To change the key with the Azure portal, follow these steps:
286+
287+
1. Navigate to your Azure Load Testing resource.
288+
289+
1. On the **Settings** page, select **Encryption**. The **Encryption type** shows the encryption selected for the resource while creation.
290+
291+
1. If the selected encryption type is *Customer-managed keys*, you can edit the key URI field with the new key URI.
292+
293+
1. Save your changes.
294+
295+
## Key rotation
296+
297+
You can rotate a customer-managed key in Azure Key Vault according to your compliance policies. To rotate a key, in Azure Key Vault, update the key version or create a new key. You can then update the Azure Load Testing resource to [encrypt data using the new key URI](#change-the-key).
298+
299+
## Frequently asked questions
300+
301+
### Is there an additional charge to enable customer-managed keys?
302+
303+
No, there's no charge to enable this feature.
304+
305+
### Are customer-managed keys supported for existing Azure Load Testing resources?
306+
307+
This feature is currently only available for new Azure Load Testing resources.
308+
309+
### How can I tell if customer-managed keys are enabled on my Azure Load Testing account?
310+
311+
1. In the [Azure portal](https://portal.azure.com), go to your Azure Load Testing resource.
312+
1. Go to the **Encryption** item in the left navigation bar.
313+
1. You can verify the **Encryption type** on your resource.
314+
315+
### How do I revoke an encryption key?
316+
317+
You can revoke a key by disabling the latest version of the key in Azure Key Vault. Alternatively, to revoke all keys from an Azure Key Vault instance, you can delete the access policy granted to the managed identity of the Azure Load Testing resource.
318+
319+
When you revoke the encryption key you may be able to run tests for about 10 minutes, after which the only available operation is resource deletion. It is recommended to rotate the key instead of revoking it to manage resource security and retain your data.
320+
321+
## Next steps
322+
323+
- Learn how to [Monitor server-side application metrics](./how-to-monitor-server-side-metrics.md).
324+
- Learn how to [Parameterize a load test](./how-to-parameterize-load-tests.md).
158 KB
Loading
12.8 KB
Loading
Loading
Loading
159 KB
Loading

articles/load-testing/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
href: how-to-assign-roles.md
5454
- name: Use a managed identity
5555
href: how-to-use-a-managed-identity.md
56+
- name: Configure customer-managed keys
57+
href: how-to-configure-customer-managed-keys.md
5658
- name: Move between regions
5759
href: how-to-move-between-regions.md
5860
- name: Monitor Azure Load Testing

0 commit comments

Comments
 (0)