|
1 | 1 | --- |
2 | 2 | title: "Key Vault" |
3 | | -description: API coverage for Microsoft.KeyVault in LocalStack for Azure. |
| 3 | +description: Get started with Azure Key Vault on LocalStack |
4 | 4 | template: doc |
5 | 5 | --- |
6 | 6 |
|
7 | 7 | import AzureFeatureCoverage from "../../../../components/feature-coverage/AzureFeatureCoverage"; |
8 | 8 |
|
| 9 | +## Introduction |
| 10 | + |
| 11 | +Azure Key Vault is a managed service for securely storing and accessing secrets, keys, and certificates. |
| 12 | +It helps centralize sensitive configuration and credentials for your applications and services. |
| 13 | +Key Vault also supports secure key management and certificate lifecycle operations. For more information, see [About Azure Key Vault](https://learn.microsoft.com/en-us/azure/key-vault/general/overview). |
| 14 | + |
| 15 | +LocalStack for Azure provides a local environment for building and testing applications that make use of Azure Key Vault. |
| 16 | +The supported APIs are available on our [API Coverage section](#api-coverage), which provides information on the extent of Key Vault's integration with LocalStack. |
| 17 | + |
| 18 | +## Getting started |
| 19 | + |
| 20 | +This guide is designed for users new to Key Vault and assumes basic knowledge of the Azure CLI and our `azlocal` wrapper script. |
| 21 | + |
| 22 | +Start your LocalStack container using your preferred method. |
| 23 | +Then start CLI interception: |
| 24 | + |
| 25 | +```bash |
| 26 | +azlocal start_interception |
| 27 | +``` |
| 28 | + |
| 29 | +### Create a resource group |
| 30 | + |
| 31 | +Create a resource group that will contain your Key Vault resources: |
| 32 | + |
| 33 | +```bash |
| 34 | +az group create \ |
| 35 | + --name rg-keyvault-demo \ |
| 36 | + --location westeurope |
| 37 | +``` |
| 38 | + |
| 39 | +```bash title="Output" |
| 40 | +{ |
| 41 | + "name": "rg-keyvault-demo", |
| 42 | + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-keyvault-demo", |
| 43 | + "location": "westeurope", |
| 44 | + "properties": { |
| 45 | + "provisioningState": "Succeeded" |
| 46 | + } |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +### Create a Key Vault |
| 51 | + |
| 52 | +Create a Key Vault in your resource group: |
| 53 | + |
| 54 | +```bash |
| 55 | +az keyvault create \ |
| 56 | + --name kv-demo-localstack \ |
| 57 | + --resource-group rg-keyvault-demo \ |
| 58 | + --location westeurope |
| 59 | +``` |
| 60 | + |
| 61 | +```bash title="Output" |
| 62 | +{ |
| 63 | + "name": "kv-demo-localstack", |
| 64 | + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-keyvault-demo/providers/Microsoft.KeyVault/vaults/kv-demo-localstack", |
| 65 | + "location": "westeurope", |
| 66 | + "properties": { |
| 67 | + "provisioningState": "Succeeded", |
| 68 | + "vaultUri": "https://kv-demo-localstack.localhost.localstack.cloud:4566" |
| 69 | + } |
| 70 | + ... |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +### Add and read a secret |
| 75 | + |
| 76 | +Create a secret in the vault: |
| 77 | + |
| 78 | +```bash |
| 79 | +az keyvault secret set \ |
| 80 | + --vault-name kv-demo-localstack \ |
| 81 | + --name app-secret \ |
| 82 | + --value "super-secret-value" |
| 83 | +``` |
| 84 | + |
| 85 | +```bash title="Output" |
| 86 | +{ |
| 87 | + "name": "app-secret", |
| 88 | + "id": "https://kv-demo-localstack.localhost.localstack.cloud:4566/secrets/app-secret/d8a709f96aee4bea901bd8825f28a281", |
| 89 | + "attributes": { |
| 90 | + "enabled": true |
| 91 | + }, |
| 92 | + "value": "super-secret-value" |
| 93 | + ... |
| 94 | +} |
| 95 | +``` |
| 96 | + |
| 97 | +Read the secret value: |
| 98 | + |
| 99 | +```bash |
| 100 | +az keyvault secret show \ |
| 101 | + --vault-name kv-demo-localstack \ |
| 102 | + --name app-secret |
| 103 | +``` |
| 104 | + |
| 105 | +```bash title="Output" |
| 106 | +{ |
| 107 | + "name": "app-secret", |
| 108 | + "id": "https://kv-demo-localstack.localhost.localstack.cloud:4566/secrets/app-secret/d8a709f96aee4bea901bd8825f28a281", |
| 109 | + "attributes": { |
| 110 | + "enabled": true |
| 111 | + }, |
| 112 | + "value": "super-secret-value" |
| 113 | + ... |
| 114 | +} |
| 115 | +``` |
| 116 | + |
| 117 | +List all secrets in the vault: |
| 118 | + |
| 119 | +```bash |
| 120 | +az keyvault secret list \ |
| 121 | + --vault-name kv-demo-localstack |
| 122 | +``` |
| 123 | + |
| 124 | +```bash title="Output" |
| 125 | +[ |
| 126 | + { |
| 127 | + "name": "app-secret", |
| 128 | + "id": "https://kv-demo-localstack.localhost.localstack.cloud:4566/secrets/app-secret" |
| 129 | + ... |
| 130 | + } |
| 131 | +] |
| 132 | +``` |
| 133 | + |
9 | 134 | ## API Coverage |
10 | 135 |
|
11 | 136 | <AzureFeatureCoverage service="Microsoft.KeyVault" client:load /> |
0 commit comments