Azure Key Vault
Azure Key Vault centrally and securely stores secrets, keys, and certificates, providing
RBAC-based access control, network isolation, logging, and lifecycle automation - so
applications never embed credentials and crypto material has a managed lifecycle.
When to use
Managing application secrets, encryption keys (including customer-managed keys / BYOK), and
TLS certificates. Use this skill to pick standard vs Managed HSM, design access, and plan
rotation.
Do not use this skill for CA design (pki-design), Entra app credentials only
(entra-id), or PaaS networking topology (azure-network-security-design).
Pick the vault type and access model
| Requirement |
Choice |
Notes |
| Application secrets, TLS certs, software-protected keys |
Standard Key Vault |
Default; FIPS 140-2 Level 2 |
| Single-tenant HSM with FIPS 140-3 Level 3 keys (CMK, root CA) |
Managed HSM |
Regulated workloads |
| Per-app, per-environment isolation |
One vault per app per environment |
Limits blast radius |
| App reading secrets at runtime |
Managed identity + RBAC (Key Vault Secrets User) |
No secrets in code |
| App Service / Functions secret in config |
Key Vault references in app settings |
No code change |
| Customer-managed key for Storage / SQL |
Key in Key Vault (or HSM) + identity grant |
Rotate independently |
Rule of thumb: one vault per app per environment (dev / test / prod). Don't share a
vault across apps - a compromise of one app's identity reads all the others' secrets. Use
Managed HSM only when the regulator or CMK boundary requires FIPS 140-3 Level 3.
Approach
Use Azure RBAC for the data plane — Switch the vault to RBAC permission model (not
legacy access policies). Assign least-privilege roles (Key Vault Secrets User,
Key Vault Crypto User) to managed identities, not user accounts.
Verify: vault enableRbacAuthorization = true; no users with Key Vault Administrator
in prod.
App access via managed identity + Key Vault references — App authenticates with a
system-assigned or user-assigned managed identity, fetches secrets at runtime.
For App Service / Functions, use Key Vault references in app settings -
@Microsoft.KeyVault(SecretUri=...) - no SDK code change.
Verify: source code contains no plaintext secrets; managed identity has only the
secrets role on the target vault.
Enable soft delete + purge protection — Soft delete is on by default; turn on
purge protection to make accidental or malicious key deletion non-recoverable for
90 days. Required for CMK and most compliance scenarios.
Verify: softDeleteRetentionInDays >= 7; enablePurgeProtection = true.
Restrict network access — For sensitive vaults, disable public network access and
use private endpoint in the workload VNet. Firewall the rest with service tags or
selected networks.
Verify: publicNetworkAccess = Disabled; private endpoint resolves; public IP test
from internet = blocked.
One vault per app per environment — Per-app blast radius. Cross-app reads are then a
role grant, audited. Don't lump secrets into a shared vault.
Automate rotation + monitor expiry — Set expiry on secrets / certs; use rotation
policies for certificate auto-renewal from issuer; for secrets, use Event Grid → Logic
App / Function to rotate at the source and update the secret.
Verify: no secret in production has a NULL expiry; alerts fire 60 days before any cert
or secret expires.
Monitor + Defender — Enable diagnostic logs to Log Analytics; turn on Defender for
Key Vault for anomalous access detection.
Guardrails
- One vault per app per environment limits blast radius and simplifies access control.
Shared vaults are an over-permission anti-pattern.
- Purge protection is irreversible once on - required for CMK and many compliance
scenarios. Turn it on knowingly.
- Never store secrets in source / config; use managed identity + Key Vault references.
Code-stored secrets leak via repo, logs, env-var dumps.
- Disable public network access for sensitive vaults. Open-to-internet Key Vault is a
brute-force / credential-spray target.
- RBAC, not access policies. RBAC is the modern model with proper inheritance and
PIM-eligible roles.
- Don't grant
Key Vault Administrator to apps. Apps need read on secrets / keys, not
admin.
Common anti-patterns
- "Shared 'enterprise' Key Vault for all apps" - Compromise of one app reads everyone's
secrets. Per-app per-environment.
- "Access policies because we've always used them" - Legacy; harder to audit. Use RBAC.
- "No purge protection - we might need to delete" - First malicious / accidental purge
= data loss. Turn it on; deal with the irrevocability.
- "Public network access on for convenience" - Internet exposure. Private endpoint
- "Secrets in App Service application settings as plaintext" - Visible to anyone with
config read. Use Key Vault references.
- "No expiry / no rotation" - Long-lived secrets are a perpetual liability. Expiry +
rotation policy.
- "Same vault for app + CA root key" - Mix of blast radii. CA / HSM keys in Managed
HSM, separate from app secret vault.
Example prompts
Set up Azure Key Vault with RBAC, purge protection, and a private endpoint.
Configure an App Service to read secrets via managed identity and Key Vault references.
When should I use Managed HSM instead of standard Key Vault?
Plan one-vault-per-app-per-environment for our microservices estate.
Automate certificate rotation in Key Vault with a 60-day expiry alert.
Review my Key Vault access model for least privilege.
Microsoft Learn
1---2name: azure-key-vault3description: "Guidance for Azure Key Vault — securely storing and managing secrets, keys, and certificates with RBAC, network isolation, managed identity access, soft delete / purge protection, and rotation. Covers when to use standard Key Vault vs Managed HSM (FIPS 140-3 Level 3), one-vault-per-app blast radius principle, and Key Vault references in App Service / Functions. WHEN: Azure Key Vault, store secrets, manage certificates, encryption keys, secret rotation, Key Vault RBAC, purge protection, soft delete, private endpoint Key Vault, managed identity access secrets, Managed HSM, Key Vault references, BYOK CMK. DO NOT USE for certificate authority design (use pki-design), entra app credentials only (use entra-id), or PaaS networking topology (use azure-network-security-design)."4license: MIT5metadata:6 source: https://skillmd.com/skills/vinayaklatthe/azure-key-vault7 author: Microsoft8 version: "0.1.0"9---1011# Azure Key Vault1213Azure Key Vault centrally and securely stores **secrets, keys, and certificates**, providing14RBAC-based access control, network isolation, logging, and lifecycle automation - so15applications never embed credentials and crypto material has a managed lifecycle.1617## When to use18Managing application secrets, encryption keys (including customer-managed keys / BYOK), and19TLS certificates. Use this skill to pick standard vs Managed HSM, design access, and plan20rotation.2122**Do not use this skill** for CA design (`pki-design`), Entra app credentials only23(`entra-id`), or PaaS networking topology (`azure-network-security-design`).2425## Pick the vault type and access model2627| Requirement | Choice | Notes |28|---|---|---|29| Application secrets, TLS certs, software-protected keys | **Standard Key Vault** | Default; FIPS 140-2 Level 2 |30| Single-tenant HSM with FIPS 140-3 Level 3 keys (CMK, root CA) | **Managed HSM** | Regulated workloads |31| Per-app, per-environment isolation | **One vault per app per environment** | Limits blast radius |32| App reading secrets at runtime | **Managed identity + RBAC** (Key Vault Secrets User) | No secrets in code |33| App Service / Functions secret in config | **Key Vault references** in app settings | No code change |34| Customer-managed key for Storage / SQL | Key in Key Vault (or HSM) + identity grant | Rotate independently |3536> **Rule of thumb:** **one vault per app per environment** (dev / test / prod). Don't share a37> vault across apps - a compromise of one app's identity reads all the others' secrets. Use38> Managed HSM only when the regulator or CMK boundary requires FIPS 140-3 Level 3.3940## Approach41421. **Use Azure RBAC for the data plane** — Switch the vault to **RBAC permission model** (not43 legacy access policies). Assign least-privilege roles (`Key Vault Secrets User`,44 `Key Vault Crypto User`) to **managed identities**, not user accounts.45 *Verify: vault `enableRbacAuthorization = true`; no users with `Key Vault Administrator`46 in prod.*47482. **App access via managed identity + Key Vault references** — App authenticates with a49 system-assigned or user-assigned managed identity, fetches secrets at runtime.50 For App Service / Functions, use **Key Vault references** in app settings -51 `@Microsoft.KeyVault(SecretUri=...)` - no SDK code change.52 *Verify: source code contains no plaintext secrets; managed identity has only the53 secrets role on the target vault.*54553. **Enable soft delete + purge protection** — Soft delete is on by default; **turn on56 purge protection** to make accidental or malicious key deletion non-recoverable for57 90 days. Required for CMK and most compliance scenarios.58 *Verify: `softDeleteRetentionInDays >= 7`; `enablePurgeProtection = true`.*59604. **Restrict network access** — For sensitive vaults, **disable public network access** and61 use **private endpoint** in the workload VNet. Firewall the rest with service tags or62 selected networks.63 *Verify: `publicNetworkAccess = Disabled`; private endpoint resolves; public IP test64 from internet = blocked.*65665. **One vault per app per environment** — Per-app blast radius. Cross-app reads are then a67 role grant, audited. Don't lump secrets into a shared vault.68696. **Automate rotation + monitor expiry** — Set expiry on secrets / certs; use **rotation70 policies** for certificate auto-renewal from issuer; for secrets, use Event Grid → Logic71 App / Function to rotate at the source and update the secret.72 *Verify: no secret in production has a NULL expiry; alerts fire 60 days before any cert73 or secret expires.*74757. **Monitor + Defender** — Enable diagnostic logs to Log Analytics; turn on **Defender for76 Key Vault** for anomalous access detection.7778## Guardrails79- **One vault per app per environment limits blast radius and simplifies access control.**80 Shared vaults are an over-permission anti-pattern.81- **Purge protection is irreversible once on - required for CMK and many compliance82 scenarios.** Turn it on knowingly.83- **Never store secrets in source / config; use managed identity + Key Vault references.**84 Code-stored secrets leak via repo, logs, env-var dumps.85- **Disable public network access for sensitive vaults.** Open-to-internet Key Vault is a86 brute-force / credential-spray target.87- **RBAC, not access policies.** RBAC is the modern model with proper inheritance and88 PIM-eligible roles.89- **Don't grant `Key Vault Administrator` to apps.** Apps need read on secrets / keys, not90 admin.9192## Common anti-patterns93- **"Shared 'enterprise' Key Vault for all apps"** - Compromise of one app reads everyone's94 secrets. Per-app per-environment.95- **"Access policies because we've always used them"** - Legacy; harder to audit. Use RBAC.96- **"No purge protection - we might need to delete"** - First malicious / accidental purge97 = data loss. Turn it on; deal with the irrevocability.98- **"Public network access on for convenience"** - Internet exposure. Private endpoint99 + firewall.100- **"Secrets in App Service application settings as plaintext"** - Visible to anyone with101 config read. Use Key Vault references.102- **"No expiry / no rotation"** - Long-lived secrets are a perpetual liability. Expiry +103 rotation policy.104- **"Same vault for app + CA root key"** - Mix of blast radii. CA / HSM keys in **Managed105 HSM**, separate from app secret vault.106107## Example prompts108- `Set up Azure Key Vault with RBAC, purge protection, and a private endpoint.`109- `Configure an App Service to read secrets via managed identity and Key Vault references.`110- `When should I use Managed HSM instead of standard Key Vault?`111- `Plan one-vault-per-app-per-environment for our microservices estate.`112- `Automate certificate rotation in Key Vault with a 60-day expiry alert.`113- `Review my Key Vault access model for least privilege.`114115## Microsoft Learn116- Key Vault overview: https://learn.microsoft.com/azure/key-vault/general/overview117- Security features: https://learn.microsoft.com/azure/key-vault/general/secure-key-vault118- RBAC guide: https://learn.microsoft.com/azure/key-vault/general/rbac-guide119- Soft delete + purge protection: https://learn.microsoft.com/azure/key-vault/general/soft-delete-overview120- Private endpoints: https://learn.microsoft.com/azure/key-vault/general/private-link-service121- Key Vault references in App Service: https://learn.microsoft.com/azure/app-service/app-service-key-vault-references122- Managed HSM: https://learn.microsoft.com/azure/key-vault/managed-hsm/overview123- Defender for Key Vault: https://learn.microsoft.com/azure/defender-for-cloud/defender-for-key-vault-introduction