Skip to content
Get Started for Free

Key Vault

Azure Key Vault is a managed service for securely storing and accessing secrets, keys, and certificates. It helps centralize sensitive configuration and credentials for your applications and services. Key Vault also supports secure key management and certificate lifecycle operations.

LocalStack for Azure allows you to build and test Key Vault workflows in your local environment. The supported APIs are available on our API Coverage section, which provides information on the extent of Key Vault’s integration with LocalStack.

This guide is designed for users new to Key Vault and assumes basic knowledge of the Azure CLI and our azlocal wrapper script.

Start your LocalStack container using your preferred method. Then start CLI interception:

Terminal window
azlocal start_interception

Create a resource group that will contain your Key Vault resources:

Terminal window
az group create \
--name rg-keyvault-demo \
--location westeurope
Output
{
"name": "rg-keyvault-demo",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-keyvault-demo",
"location": "westeurope",
"properties": {
"provisioningState": "Succeeded"
}
}

Create a Key Vault in your resource group:

Terminal window
az keyvault create \
--name kv-demo-localstack \
--resource-group rg-keyvault-demo \
--location westeurope
Output
{
"name": "kv-demo-localstack",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-keyvault-demo/providers/Microsoft.KeyVault/vaults/kv-demo-localstack",
"location": "westeurope",
"properties": {
"provisioningState": "Succeeded",
"vaultUri": "https://kv-demo-localstack.localhost.localstack.cloud:4566"
}
...
}

Create a secret in the vault:

Terminal window
az keyvault secret set \
--vault-name kv-demo-localstack \
--name app-secret \
--value "super-secret-value"
Output
{
"name": "app-secret",
"id": "https://kv-demo-localstack.localhost.localstack.cloud:4566/secrets/app-secret/d8a709f96aee4bea901bd8825f28a281",
"attributes": {
"enabled": true
},
"value": "super-secret-value"
...
}

Read the secret value:

Terminal window
az keyvault secret show \
--vault-name kv-demo-localstack \
--name app-secret
Output
{
"name": "app-secret",
"id": "https://kv-demo-localstack.localhost.localstack.cloud:4566/secrets/app-secret/d8a709f96aee4bea901bd8825f28a281",
"attributes": {
"enabled": true
},
"value": "super-secret-value"
...
}

List all secrets in the vault:

Terminal window
az keyvault secret list \
--vault-name kv-demo-localstack
Output
[
{
"name": "app-secret",
"id": "https://kv-demo-localstack.localhost.localstack.cloud:4566/secrets/app-secret"
...
}
]
OperationImplemented
Page 1 of 0
Was this page helpful?