Setup guide - Azure Key Vault
To manage the lifecycle of the Azure Key Vault keys, you need to setup the
key management secrets engine using azurekeyvault
provider.
Setup
Enable the key management secrets engine.
Configure a KMS provider resource named,
example-kms
.The command specified the following:
- The full path to this KMS provider instance in Vault
(
keymgmt/kms/example-kms
). - A key collection, which corresponds to the name of the key vault instance in Azure.
- The KMS provider is set to
azurekeyvault
. - Azure client ID credential, that can also be specified with
AZURE_CLIENT_ID
environment variable. - Azure client secret credential, that can also be specified with
AZURE_CLIENT_SECRET
environment variable. - Azure tenant ID credential, that can also be specified with
AZURE_TENANT_ID
environment variable.
- The full path to this KMS provider instance in Vault
(
API documentation
Refer to the Azure Key Vault API documentation for a detailed description of individual configuration parameters.
Usage
Write a pair of RSA-2048 keys to the secrets engine. The following command will write a new key of type rsa-2048 to the path
keymgmt/key/rsa-1
.The key management secrets engine currently supports generation of the key types specified in Key Types.
Based on the Compatibility section of the documentation, Azure Key Vault currently supports use of RSA-2048, RSA-3072, and RSA-4096 key types.
Read the rsa-1 key you created. Use JSON as the output and pipe that into
jq
.To use the keys you wrote, you must distribute them to the key vault. Distribute the rsa-1 key to the key vault at the path
keymgmt/kms/example-kms/key/rsa-1
.Here you are instructing Vault to distribute the key and specify that its purpose is only to encrypt and decrypt. The protection type is dependent on the cloud provider and the value is either
hsm
orsoftware
. In the case of Azure, you specifyhsm
for the protection type. The key will be securely delivered to the key vault instance according to the Azure Bring Your Own Key (BYOK) specification.You can list the keys that have been distributed to the Azure Key Vault instance.
Rotate the rsa-1 key.
Confirm successful key rotation by reading the key, and getting the value of
.data.latest_version
.
Azure private link
The secrets engine can be configured to communicate with Azure Key Vault instances using Azure Private Endpoints. Follow the guide at Integrate Key Vault with Azure Private Link to set up a Private Endpoint for your target Key Vault instance in Azure. The Private Endpoint must be network reachable by Vault. This means Vault needs to be running in the same virtual network or a peered virtual network to properly resolve the Key Vault domain name to the Private Endpoint IP address.
The Private Endpoint configuration relies on a correct Azure Private DNS integration. From the host that Vault is running on, follow the steps in Validate that the private link connection works to ensure that the Key Vault domain name resolves to the Private Endpoint IP address you've configured.
The secrets engine doesn't require special configuration to communicate with a
Key Vault instance over an Azure Private Endpoint. For example, the given KMS
configuration
will result in the secrets engine resolving a Key Vault domain name of
keyvault-name.vault.azure.net
to the Private Endpoint IP address. Note that
it's possible to change the Key Vault DNS suffix using the
environment
configuration parameter or AZURE_ENVIRONMENT
environment variable.
Terraform example
If you are familiar with Terraform, you can use it to deploy the necessary Azure infrastructure.