Free tech learning for everyone, from basics to pro

Azure SecurityCloud SecurityIntermediate

Azure Key Vault: secrets, keys, certificates, access control and rotation

In short: Azure Key Vault is a managed store for secrets, cryptographic keys and certificates. Applications reach it with managed identities instead of stored passwords, Azure RBAC controls who can read or manage each item, and soft delete, purge protection, private endpoints, logging and rotation keep it safe.

Why a vault?

Passwords and API keys hard-coded in source code, config files or pipeline variables are one of the most common causes of breaches. Once a secret is in Git history, it is very hard to remove. A vault keeps secrets in one controlled place, so code holds only a reference, access is logged, and changing a secret does not mean redeploying everything.

What Key Vault storesAzure Key Vaultcentral secret storeSecretspasswords, connectionstringsKeysRSA and EC, HSM optionCertificatesTLS, auto-renew
Figure 1. Key Vault holds three kinds of object, each with its own permissions and lifecycle.
OptionProtectionUse when
Key Vault StandardSoftware-protected keysMost secrets and certificates
Key Vault PremiumAdds HSM-protected keysKeys needing hardware protection
Managed HSMDedicated single-tenant HSM poolStrict regulatory or key-sovereignty needs

Access control

Key Vault separates the management plane (creating the vault, changing network settings) from the data plane (reading a secret, signing with a key). For the data plane there are two permission models: the older vault access policies, and Azure RBAC, which Microsoft recommends. With RBAC you can grant narrow built-in roles such as Key Vault Secrets User (read secret values) or Key Vault Crypto User, at vault level or even on a single secret.

App reads a secret without a passwordApp ServicemanagedidentityEntra IDissues tokenKey Vaultchecks RBACroleSecretreturned overTLSAudit logaccessrecorded
Figure 2. With a managed identity the application holds no credential of its own, and every read is logged.

A managed identity gives an Azure resource its own identity in Entra ID with no secret to store or rotate. Grant that identity a data-plane role and the app fetches what it needs at run time:

az role assignment create --assignee <managed-identity-principal-id> --role "Key Vault Secrets User" --scope /subscriptions/<subscription-id>/resourceGroups/rg-app/providers/Microsoft.KeyVault/vaults/<your-vault>

Protecting the vault

  • Soft delete is always on: deleted vaults and items can be recovered during a retention period of 7 to 90 days.
  • Purge protection stops anyone, including admins, permanently deleting items before the retention period ends. Turn it on for production.
  • Disable public network access and use a private endpoint.
  • Send diagnostic logs (AuditEvent) to Log Analytics and alert on unusual reads or failed access.
  • Use separate vaults per application and environment, so one compromised app cannot read another's secrets.
  • Turn on Defender for Key Vault for anomaly detection.

Rotation and expiry

  1. Set expiry dates on secrets and keys so nothing lives forever.
  2. Give keys a rotation policy so Key Vault creates new versions automatically.
  3. For certificates, link to a supported certificate authority and set auto-renewal before expiry.
  4. For secrets such as database passwords, use the near-expiry event in Event Grid to trigger a function that rotates the password and stores the new version.
  5. Make apps read the latest version rather than pinning an old one.

Tip: the same pattern exists on other clouds, for example AWS Secrets Manager and Google Cloud Secret Manager. See secrets management for container workloads.

Practice

Why use a managed identity instead of a client secret for an app to reach Key Vault?
There is no credential to store, leak or rotate; Azure issues tokens to the identity automatically.
What does purge protection add on top of soft delete?
It prevents permanent deletion until the retention period has passed, even by administrators or attackers with admin rights.
Which built-in role lets an app read secret values but not manage the vault?
Key Vault Secrets User.

Key takeaways

  • Key Vault stores secrets, keys and certificates centrally.
  • Use Azure RBAC and managed identities for data-plane access.
  • Enable purge protection, private endpoints and audit logging.
  • Use separate vaults per app and environment.
  • Set expiry and rotate automatically.
Tracks your learning on this device only. See your progress on the learning paths.

About the author

Mohamed Fayas

Founder of FM TecHub. CCNA certified, with a BTEC HND in Network Engineering, and BEng (Hons) in Computer Networking and Cloud Security. He writes practical, plain-English guides on networking, security and cloud.

More about the author

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Stay up to date by email

New notes, tools and security news from FM TecHub, explained simply. Free.

We only use your email to send these updates. See our privacy policy.