Skip to main content

Azure Key Vault

Azure Key Vault is a managed service for storing secrets, encryption keys, and certificates behind access control and audit logging. Applications fetch values at runtime using an Entra ID identity, so credentials never sit in code or config files.

Azure Key Vault

Key Vault holds three object types: secrets (passwords, connection strings), keys (RSA and EC keys, optionally HSM-backed on the Premium tier), and certificates. Applications authenticate with a managed identity and read what they need, and every access is logged to Azure Monitor. Rotating a secret in the vault updates every consumer that reads it, with no redeploy.

How Should You Control Access to a Key Vault?

Use Azure RBAC rather than legacy access policies. Roles such as Key Vault Secrets User (read) and Key Vault Secrets Officer (manage) let you scope access to a single vault or even one secret.

Bash
az keyvault create --name mumbai-prod-kv --resource-group mumbai-prod-rg \
--location centralindia --enable-rbac-authorization true \
--enable-purge-protection true
az role assignment create --assignee <managed-identity-object-id> \
--role "Key Vault Secrets User" \
--scope $(az keyvault show --name mumbai-prod-kv --query id -o tsv)
az keyvault secret set --vault-name mumbai-prod-kv \
--name db-connection-string --value "Server=tcp:10.20.2.10,1433;"

How Do You Protect Against Accidental Deletion?

Soft delete is always on and keeps deleted vaults and objects recoverable for 7 to 90 days. Enable purge protection as well, so nobody can permanently erase an object before the retention period ends.

Why It Matters in Production

A fintech like CRED can have its services pull the database password at startup through a managed identity. Nothing sensitive lands in environment variables, deployment logs, or image layers, and rotation becomes a vault operation.

Security

Never grant broad purge or full-vault permissions to application identities. Give each workload the narrowest read role at the narrowest scope.

Tip

Cache secrets in memory with a sensible lifetime instead of calling the vault on every request. This cuts latency and avoids throttling.

Frequently Asked Questions

What problem does Key Vault solve that environment variables do not?

Environment variables leak into logs, crash dumps, and image layers, and changing them means redeploying. Key Vault centralises secrets, audits each read, and lets you rotate without touching the apps.

Key Vault or Managed HSM?

Key Vault Premium is enough for most workloads, including HSM-protected keys. Managed HSM is a dedicated single-tenant service for strict compliance needs such as FIPS 140-3 Level 3 and full key sovereignty.

Can App Service read Key Vault secrets without code changes?

Yes. Key Vault references in app settings resolve the secret at runtime using the app's managed identity.

Found a mistake, an outdated step or a broken link?