Understanding Azure Key Vault for Developers
This lesson explains why secrets belong in Key Vault, the objects, versions and attributes it holds, access control, protection settings and limits.
Learning outcomes
After completing this lesson, you will be able to:
- Explain when Key Vault is needed and when an identity removes the secret.
- Describe secret versions and attributes.
- Choose a least-privilege Key Vault role.
- Describe soft delete, purge protection and throttling.
Why secrets belong in Key Vault
AI back ends depend on secrets: API keys for external model providers, database passwords where managed identities are not possible, webhook signing keys, and certificates. Secrets kept in source code, configuration files or container images spread to every copy of the code, cannot be rotated without redeployment, and leave no record of who read them. Azure Key Vault centralizes them: applications authenticate with Microsoft Entra ID, authorization decides exactly which secrets each identity can read, every access can be logged, and values can be versioned and rotated in one place.
The best secret is one that does not exist. Where a service supports Microsoft Entra authentication, as Cosmos DB, Service Bus, Event Grid, Azure Managed Redis, Storage and PostgreSQL do, a managed identity removes the secret entirely. Key Vault is for the secrets that remain.
Key Vault or managed identity?
Objects, versions and attributes
A vault holds three kinds of object. Secrets are values of up to 25 KB that applications retrieve, such as passwords and API keys. Keys are cryptographic keys that perform operations, such as signing or wrapping, inside the vault, so the key material never leaves it. Certificates are X.509 certificates with their private keys and renewal policies.
Every object has versions. Setting a secret that already exists creates a new version and leaves the old ones in place. A secret's identifier is a URI: https://VAULT.vault.azure.net/secrets/NAME refers to the current version, and https://VAULT.vault.azure.net/secrets/NAME/VERSION to a specific one. Each version has attributes: enabled, an activation date (nbf), an expiry date (exp), a content type such as text/plain or application/json, and tags. Key Vault does not refuse to return an expired secret, but the expiry date drives near-expiry events and monitoring.
Objects and versions
Access control
Requests to a vault are authenticated with Microsoft Entra ID and authorized on two planes. The control plane manages the vault resource, such as its network settings; the data plane reaches its contents. With the Azure RBAC permission model, which is the default for vaults created with current API versions, data access uses dedicated roles.
| Role | Allows | Typical holder |
|---|---|---|
| Key Vault Secrets User | Read secret values | An application's managed identity |
| Key Vault Secrets Officer | Create, update, delete and read secrets | A rotation function or a deployment pipeline |
| Key Vault Reader | Read metadata, not secret values | Inventory and monitoring tools |
| Key Vault Crypto User | Perform operations with keys | A service that signs or encrypts |
| Key Vault Administrator | All data plane operations | Vault administrators |
Roles are normally assigned at vault scope, which is why the recommended design is one vault per application per environment: the vault becomes the access boundary, and a compromised application cannot read other applications' secrets. The legacy access policy model is still supported for existing vaults.
The following diagram shows the role each identity holds and what it allows.

Key Vault roles
Protection, networking and limits
Soft delete is always on: deleted vaults and objects can be recovered for a retention period of 7 to 90 days (90 by default), set at creation. Purge protection, which cannot be turned off once enabled, prevents anyone from permanently deleting soft-deleted items before the retention period ends. The vault firewall can restrict access to selected networks, and private endpoints give private access, in which case applications must reach the vault over that network.
Key Vault throttles requests above service limits, which are counted per vault per region within short time windows, and returns HTTP 429. Applications that read a secret on every request can hit these limits under load, so they cache secrets. Every data plane operation can be recorded in the AuditEvent category of the vault's diagnostic logs, sent to a Log Analytics workspace.
az keyvault create --resource-group RG --name VAULT --location LOCATION --enable-purge-protection true
az role assignment create --assignee-object-id APP_PRINCIPAL_ID --assignee-principal-type ServicePrincipal \
--role "Key Vault Secrets User" --scope $(az keyvault show --name VAULT --query id -o tsv)
az keyvault secret set --vault-name VAULT --name model-api-key --value "VALUE" \
--content-type text/plain --expires 2027-05-01T00:00:00ZProtecting a vault
Least privilege for three identities
A web API must read a third-party model API key from Key Vault. A rotation function must write new versions of that key every 60 days. A security dashboard must list which secrets are near expiry but must never see values. All use managed identities.
The API's identity gets Key Vault Secrets User, which reads values but cannot change them. The rotation function's identity gets Key Vault Secrets Officer, which can set new versions. The dashboard's identity gets Key Vault Reader, which lists secrets and their attributes, including expiry dates, without values. All three are assigned at the scope of the application's own vault.
Key Vault Administrator for the function would work but exceeds its needs. Key Vault Secrets User for the dashboard would expose values it must not see. Contributor on the vault gives no data plane access under Azure RBAC.
Which Key Vault role lets a dashboard list secret names and expiry dates without reading values?
Show answer
Key Vault Reader, which reads metadata but not secret values.
Exam Tips
Remember for the exam
- Prefer managed identities; use Key Vault for the secrets that remain.
- Setting a secret creates a new version; a URI without a version means the current version.
- Secrets User reads values, Secrets Officer manages secrets, Reader sees metadata only.
- One vault per application per environment; cache secrets to avoid throttling.