Configure customer-managed keys for Azure Load Testing with Azure Key Vault
Article
Azure Load Testing 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.
The keys you provide are stored securely using Azure Key Vault. You can create a separate key for each Azure load testing resource you enable with customer-managed keys.
When you use customer-managed encryption keys, you need to specify a user-assigned managed identity to retrieve the keys from Azure Key Vault.
Azure Load Testing uses the customer-managed key to encrypt the following data in the load testing resource:
Test script and configuration files
Secrets
Environment variables
Note
Azure Load Testing does not encrypt metrics data for a test run with your customer-managed key, including the JMeter metrics sampler names that you specify in the JMeter script and the request names that you specify in the Locust script. Microsoft has access to this metrics data.
Prerequisites
An Azure account with an active subscription. If you don't have an Azure subscription, create a free account before you begin.
An existing user-assigned managed identity. For more information about creating a user-assigned managed identity, see Manage user-assigned managed identities.
Limitations
Customer-managed keys are only available for new Azure load testing resources. You should configure the key during resource creation.
Once customer-managed key encryption is enabled on a resource, it can't be disabled.
Azure Load Testing can't 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.
Configure your Azure key vault
To use customer-managed encryption keys with Azure Load Testing, you need to store the key in Azure Key Vault. You can use an existing key vault or create a new one. The load testing resource and key vault may be in different regions or subscriptions in the same tenant.
Make sure to configure the following key vault settings when you use customer-managed encryption keys.
Configure key vault networking settings
If you restricted access to your Azure key vault by a firewall or virtual networking, you need to grant access to Azure Load Testing for retrieving your customer-managed keys. Follow these steps to grant access to trusted Azure services.
Important
Retrieving customer-managed keys from a private Azure key vault that has access restrictions is currently not supported in US Gov Virginia region.
Configure soft delete and purge protection
You have to set the Soft Delete and Purge Protection properties on your key vault to use customer-managed keys with Azure Load Testing. Soft delete is enabled by default when you create a new key vault and can't be disabled. You can enable purge protection at any time. Learn more about soft delete and purge protection in Azure Key Vault.
You can enable purge protection when you create a new key vault by selecting the Enable purge protection settings.
To enable purge protection on an existing key vault, follow these steps:
Navigate to your key vault in the Azure portal.
Under Settings, choose Properties.
In the Purge protection section, choose Enable purge protection.
To create a new key vault with PowerShell, install version 2.0.0 or later of the Az.KeyVault PowerShell module. Then call 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.
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.
To create a new key vault using Azure CLI, call az keyvault create. Soft delete is enabled by default when you create a new key vault.
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.
To enable purge protection on an existing key vault with Azure CLI:
Azure CLI
az keyvault update --subscription<subscription-id>-g<resource-group>-n<key-vault-name>--enable-purge-protectiontrue
Add a customer-managed key to Azure Key Vault
Next, add a key to the key vault. Azure Load Testing encryption supports RSA keys. For more information about supported key types in Azure Key Vault, see About keys.
To add a key with PowerShell, call Add-AzKeyVaultKey. Remember to replace the placeholder values in brackets with your own values and to use the variables defined in the previous examples.
To add a key with Azure CLI, call az keyvault key create. Remember to replace the placeholder values in brackets with your own values.
Azure CLI
az keyvault key create \
--name<key-name> \
--vault-name<key-vault-name>
Add an access policy to your key vault
When you use customer-managed encryption keys, you have to specify a user-assigned managed identity. The user-assigned managed identity for accessing the customer-managed keys in Azure Key Vault must have appropriate permissions to access the key vault.
In 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.
Select + Add Access Policy.
In the Key permissions drop-down menu, select Get, Unwrap Key, and Wrap Key permissions.
In Select principal, select None selected.
Search for the user-assigned managed identity you created earlier, and select it from the list.
Choose Select at the bottom.
Select Add to add the new access policy.
Select Save on the key vault instance to save all changes.
Use customer-managed keys with Azure Load Testing
You can only configure customer-managed encryption keys when you create a new Azure load testing resource. When you specify the encryption key details, you also have to select a user-assigned managed identity to retrieve the key from Azure Key Vault.
To configure customer-managed keys for a new load testing resource, follow these steps:
Go to the Encryption tab, and then select Customer-managed keys (CMK) for the Encryption type field.
In the Key URI field, paste the URI/key identifier of the Azure Key Vault key including the key version.
For the User-assigned identity field, select an existing user-assigned managed identity.
Select Review + create to validate and create the new resource.
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:
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:
az deployment group create --resource-group<resource-group-name>--template-file<path-to-template>
Change the managed identity for retrieving the encryption key
You can change the managed identity for customer-managed keys for an existing load testing resource at any time.
In the Azure portal, go to your Azure load testing resource.
On the Settings page, select Encryption.
The Encryption type shows the encryption type that was used for creating the load testing resource.
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.
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.
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.
Is there an extra charge to enable customer-managed keys?
No, there's no charge to enable this feature.
Are customer-managed keys supported for existing Azure load testing resources?
This feature is currently only available for new Azure load testing resources.
How can I tell if customer-managed keys are enabled on my Azure load testing resource?
In the Azure portal, go to your Azure load testing resource.
Go to the Encryption item in the left navigation bar.
You can verify the Encryption type on your resource.
How do I revoke an encryption key?
You can revoke a key by disabling the latest version of the key in Azure Key Vault. Alternatively, to revoke all keys from a key vault instance, you can delete the access policy granted to the managed identity of the load testing resource.
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's recommended to rotate the key instead of revoking it to manage resource security and retain your data.
In this module, you learn about essential concepts for using encryption keys and digital certificates in Azure to help secure cloud workloads and ensure data sovereignty.