Secure Secrets and Keys with Azure Key Vault (SC-500)
Azure Key Vault is Microsoft's managed service for storing and controlling access to secrets (passwords, connection strings, API tokens), cryptographic keys and certificates, so applications fetch them at runtime instead of keeping them in code or configuration files. Securing it is a set of separate decisions: which tier or service holds the keys (Standard, Premium or Managed HSM), which recovery settings protect against deletion (soft delete and purge protection), which permission model authorizes access (Azure RBAC or legacy access policies, and which role at which scope), how the vault is reached over the network (firewall rules, service endpoints, private endpoints and the trusted-services exception), and how keys, secrets and certificates are rotated and renewed. Around the vault, Microsoft Defender for Cloud adds two protections: Defender for Key Vault detects suspicious access to vaults, and Defender CSPM finds plaintext secrets that never made it into a vault. This lesson covers every one of those decisions and the behaviour that separates options that look alike.
On this page10 sections
- Deploy Key Vault: Standard, Premium, Managed HSM or Cloud HSM
- Configure Key Vault settings: soft delete and purge protection
- Vault access configuration for Azure platform services
- Configure access: control plane versus data plane
- Azure RBAC versus legacy access policies
- Least-privilege Key Vault roles and scopes
- Configure firewall settings and private endpoints
- Allow trusted Microsoft services to bypass the firewall
- Manage keys, secrets and certificates: rotation and renewal
- Defender for Key Vault and Defender CSPM secrets scanning
- Choose between Key Vault Standard, Key Vault Premium, Managed HSM and Azure Cloud HSM from tenancy, HSM, BYOK and object-type requirements
- Configure soft delete, purge protection and the vault access configuration switches, and predict what recovery does and does not restore
- Separate control-plane from data-plane access, pick the least-privilege Key Vault role at the right scope, and explain why Azure RBAC replaces access policies
- Restrict network access with IP rules, virtual network rules, the trusted-services exception and private endpoints, including the DNS each needs
- Automate key rotation, secret rotation and certificate renewal with rotation policies, Event Grid events and certificate lifetime actions
- Use Defender for Key Vault alerts and Defender CSPM secrets scanning to detect and remediate exposed secrets
Configure Key Vault settings: soft delete and purge protection
Soft delete makes deleting a vault, or a key, secret or certificate inside it, recoverable for a retention period of 7 to 90 days (90 by default). Soft delete is always on for new vaults. The retention period is chosen when the vault is created and cannot be changed afterwards; to meet a different retention rule you create a new vault with the right value and move the objects into it. Azure Policy cannot change it either, because the service makes it immutable.
While a vault is soft-deleted its name stays reserved, so redeploying a vault with the same name fails. The fix is to recover the deleted vault (from the list of deleted vaults, or with the recover command), which brings back its keys, secrets, certificates, their versions and the vault's own properties in one operation. Purging releases the name but destroys the contents. Azure Backup does not back up a key vault as a resource, so there is no Recovery Services restore for a deleted vault.
What recovery does not restore: deleting a vault also deletes the services integrated with it. Microsoft names Azure RBAC role assignments and Event Grid subscriptions. After recovering a vault you must recreate both, or apps receive 403 errors and event-driven automation (for example a near-expiry function) silently stops.
Purge protection is an optional, irreversible setting: once enabled it can never be turned off. It does not stop deletion; it blocks the second, permanent step. A deleted vault or object stays in the soft-deleted state, recoverable, until the retention period ends, and no one can purge it early — not a Key Vault Purge Operator, not a subscription Owner. It uses the same retention interval chosen at creation; it does not force 90 days.
| Setting | Protects against | Can be changed later? |
|---|---|---|
| Soft delete | Accidental deletion (recover within retention) | Always on; retention fixed at creation |
| Purge protection | Malicious or accidental permanent deletion during retention | Can be enabled later; can never be disabled |
| Object expiration date | Using a secret or key past its valid life (metadata only) | Yes; does not affect how long deleted objects are kept |
Services that encrypt data with a customer-managed key, such as Azure Storage, require the vault to have soft delete and purge protection, because losing the key makes the data unreadable.
Vault access configuration for Azure platform services
Three vault switches let specific Azure platform services retrieve material from the vault on your behalf; each serves one scenario only:
| Portal setting | Property | What it allows |
|---|---|---|
| Azure Virtual Machines for deployment | enabledForDeployment | The compute platform retrieves certificates stored as secrets and installs them on VMs as they are created |
| Azure Resource Manager for template deployment | enabledForTemplateDeployment | Resource Manager retrieves secrets referenced from template parameter files |
| Azure Disk Encryption for volume encryption | enabledForDiskEncryption | Azure Disk Encryption uses the vault for its secrets and key-wrapping keys |
For a template that references a secret (for example a SQL administrator password in a parameter file), two checks apply. The vault must have enabledForTemplateDeployment set, and the person or pipeline deploying must hold Microsoft.KeyVault/vaults/deploy/action on the vault's scope, so nobody can pull a secret merely by knowing the vault's resource ID. That permission grants the ability to deploy with the secret without granting read access to its value. Owner and Contributor include it; a custom role containing only that action keeps release engineers at least privilege.
These switches are permissions, not network rules. If the vault's firewall also blocks public traffic, the calling service must additionally be able to get through the firewall (see the trusted-services exception below).
Configure access: control plane versus data plane
Key Vault has two planes, and a role on one gives nothing on the other. The control plane (management plane) is Azure Resource Manager: creating and deleting vaults, changing tags, networking, the permission model and other vault properties. The data plane is the vault's own endpoint (https://<name>.vault.azure.net): listing, reading, creating and deleting keys, secrets and certificates, cryptographic operations, and recovering or purging deleted objects.
Key Vault Contributor is a control-plane role. On a vault that uses Azure RBAC it does not allow access to keys, secrets or certificates — a user with it can edit tags and network rules in the portal but gets an operation-not-allowed error on the Secrets page. It also lacks Microsoft.Authorization/roleAssignments/write, so it cannot grant itself a data role. Scope does not change this: a role assigned at a wider scope applies in more places but never gains actions it does not contain, and activating a role in PIM only makes its existing actions usable.
The two planes also log in different places. The subscription's Activity log records control-plane operations (vault updates, role assignments). Data-plane operations such as SecretGet or KeySign are recorded only in the vault's AuditEvent resource log, which is kept only when a diagnostic setting sends it to a Log Analytics workspace, storage account or event hub. To find out who read a secret, configure that diagnostic setting; adding Activity log categories never adds secret reads, and Key Vault publishes no Event Grid event for a read.
Azure RBAC versus legacy access policies
A vault authorizes data-plane access with one of two permission models, never both, and never split by object type. Azure RBAC (the recommended model) uses role assignments, which can be scoped to a management group, subscription, resource group, vault or an individual key, secret or certificate, and which work with PIM. Vault access policies (legacy) are a list of identities and permissions stored as a property of the vault.
The legacy model has a privilege-escalation path: access policies are a vault property, so anyone with Contributor (or Key Vault Contributor) on the vault's control plane can add an access policy for themselves and read every secret. Any fix that leaves data access defined by a vault property the Contributor can still write leaves that path open. Switching the vault to Azure RBAC does, because data access then requires a role assignment, which needs roleAssignments/write — a permission Contributor lacks.
Two behaviours to know when moving between models:
- Switching to Azure RBAC invalidates every access policy. Applications that relied on, say, a Get secret policy start receiving 403 Forbidden until an equivalent role (such as Key Vault Secrets User) is assigned. Assign the roles before you switch.
- The default changed. From Key Vault API version 2026-02-01,
enableRbacAuthorizationdefaults totruewhen a vault is created, so a new vault uses Azure RBAC unless the template explicitly sets it tofalse. Existing vaults keep their current model, and no portal confirmation is involved.
| Azure RBAC | Vault access policies | |
|---|---|---|
| Where grants live | Role assignments (Microsoft.Authorization) | A property of the vault |
| Who can grant data access | Owner, User Access Administrator, RBAC Administrator, Key Vault Data Access Administrator | Anyone who can write the vault, including Contributor |
| Granularity | Down to a single key, secret or certificate | Whole vault per object type |
| PIM, conditions | Supported | Not supported |
Least-privilege Key Vault roles and scopes
Least privilege on an RBAC vault means choosing the narrowest built-in data role and the narrowest scope that still works. The roles that matter most:
| Role | What it allows |
|---|---|
| Key Vault Secrets User | Read secret contents, nothing else — the role for an app that consumes a connection string |
| Key Vault Secrets Officer | Any action on secrets: create, update, delete, purge, as well as read |
| Key Vault Reader | Read metadata of the vault and its objects (names, attributes, tags) — never secret values or key material |
| Key Vault Crypto Service Encryption User | Read key metadata and wrap/unwrap — the role for a service identity using a customer-managed key (Storage, SQL) |
| Key Vault Crypto User / Crypto Officer | Cryptographic operations with keys / any action on keys, including delete and rotate |
| Key Vault Certificates Officer / Certificate User | Any action on certificates / read certificate contents |
| Key Vault Administrator | All data-plane operations on all object types — but cannot manage role assignments |
| Key Vault Purge Operator | Permanently delete soft-deleted vaults (blocked by purge protection) |
| Key Vault Data Access Administrator | Add and remove assignments of the Key Vault data roles only, enforced by a built-in ABAC condition |
| Key Vault Contributor | Manage the vault resource (control plane); no data access on RBAC vaults |
Delegating access management. To let a team lead grant and remove access to their team's vault objects without being able to hand out other Azure roles, assign Key Vault Data Access Administrator. User Access Administrator and Role Based Access Control Administrator (without a condition you author yourself) can assign any role, including Owner. Key Vault Administrator sounds right but works with data and cannot assign roles.
Scope. Assign at the vault scope by default, with one vault per application. Microsoft discourages per-object assignments but lists a documented exception: a secret shared between applications. If another team's app must read exactly one secret from a vault holding many, assign Key Vault Secrets User on that secret alone; a vault-scope assignment would expose every secret.
Applications should authenticate with a managed identity (system- or user-assigned) rather than a stored client secret, which removes the last plaintext credential from the app. Managed HSM uses its own local RBAC with similar Crypto roles rather than Azure RBAC data roles.
Configure firewall settings and private endpoints
The Key Vault firewall restricts which networks can reach the data plane. Public network access has three states: all networks, selected networks (only the rules below are admitted) and disabled (no public traffic except private endpoints and, while the bypass is on, the trusted Microsoft services described in the next section). The firewall does not filter control-plane calls through Azure Resource Manager.
- IP rules accept public IPv4 addresses and CIDR ranges only. Private (RFC 1918) ranges such as 10.0.0.0/8 are not valid, and service tags are not supported. On-premises callers that reach the vault through NAT appear as the NAT's public address, so that address is the rule to add.
- Virtual network rules admit specific Azure subnets that have the Microsoft.KeyVault service endpoint enabled. This is the way to admit VMs with private, dynamic addresses without a private endpoint. Traffic still goes to the vault's public endpoint; the service endpoint only carries the subnet's identity. It applies to traffic that originates in the subnet, not to on-premises traffic arriving over a VPN.
- A network security group rule on the client subnet controls what leaves that subnet; it does nothing to stop other networks reaching the vault.
The portal is a data-plane client too. When an administrator opens the vault in the portal, the vault's properties load (control plane), but listing keys, secrets or certificates is a data-plane call made from the administrator's browser. From a home IP that is not allowed, the list fails even though the role assignments are fine. The same machine's CLI calls fail the same way.
Private endpoints. A private endpoint (Azure Private Link) gives the vault a network interface with a private IP address in your virtual network. Combine it with public network access set to Disabled when clients must reach the vault only through private endpoints. Disabled does not switch off the trusted-services exception: services on that list can still reach the vault. For strictly private-only access, also turn the bypass off, or associate the vault with a Network Security Perimeter in Secure by perimeter mode, the one public-access mode that overrides the bypass. A service endpoint is the near-twin that does not keep traffic off the public endpoint: the vault keeps its public address.
DNS decides whether clients actually use the private endpoint. The vault's name (<name>.vault.azure.net) is a CNAME into privatelink.vaultcore.azure.net. Clients resolve it to the private IP only when a private DNS zone with exactly that name, holding the vault's A record, is linked to their virtual network. A zone named privatelink.vault.azure.net is never consulted. An approved connection on the endpoint proves only that the endpoint exists; check name resolution from the client itself to confirm the zone is linked. On-premises clients over VPN or ExpressRoute need their DNS servers to send vault.azure.net and vaultcore.azure.net lookups, through conditional forwarders, to a resolver that sees the private zone, such as Azure DNS Private Resolver; linking the zone to the hub VNet alone helps only resolvers inside Azure.
Allow trusted Microsoft services to bypass the firewall
The Allow trusted Microsoft services to bypass this firewall exception lets a defined list of Azure services reach a vault whose public access is limited to selected networks, and it keeps working when public network access is Disabled; only Secure by perimeter mode or turning the exception off stops it. Services on the list include the Azure Resource Manager template deployment service (passing secure values from parameter files), Azure Storage and other services that use customer-managed keys, Azure Disk Encryption and Azure Backup. Two rules govern it:
- Bypassing the firewall is not authorization. A trusted service still needs permission: a role or access policy for its identity, or the matching vault access configuration switch.
- Services that run customer code are not trusted. Azure DevOps (Microsoft-hosted pipeline agents) and your own applications running on App Service or Functions are not on the list, because anyone can run code there.
For Microsoft-hosted Azure DevOps agents blocked by the firewall, the options are to allow the agents' published IP ranges (broad and shared with other customers) or, better, to run self-hosted agents in a virtual network the vault allows (or reach the vault through a private endpoint). Permissions and network reachability are separate checks: a caller must pass both, and fixing one never fixes the other.
A private endpoint helps clients in its virtual network; it does not give the Resource Manager deployment service a path. When a template deployment fails to fetch a secret after the vault was locked to selected networks with no exceptions, enabling the trusted-services bypass is the fix.
Manage keys, secrets and certificates: rotation and renewal
Keys rotate through rotation policies, secrets through SecretNearExpiry events and a function that changes the value at its source, and certificates through issuers and lifetime actions; each object type has its own tooling.
Keys: rotation policies
A key rotation policy makes Key Vault generate a new key version on a schedule. It has an expiry time for new versions and lifetime actions: Rotate (create a new version, triggered a period after creation or before expiry) and Notify (publish a near-expiry event; requires an expiry time). For zero-touch rotation, the consuming service must reference the key with a versionless key URI, so it moves to the newest version on its own (services can take up to a day or more to pick it up). A versioned URI pins the old version and needs a manual update.
Autorotation only works when Key Vault can generate the new material itself. For a key whose material is imported from an on-premises HSM, use the Notify action: it emits a KeyNearExpiry event through Event Grid, and a subscriber (an Azure Function or Logic App) runs the import workflow.
Secrets: event-driven rotation
Rotation policies apply to keys, not secrets. A secret such as a SQL password must also change at its source, which Key Vault cannot do. The pattern is: set an expiration date on the secret, subscribe to its SecretNearExpiry Event Grid event, and have a function generate a new password, apply it to the database and store it as a new secret version. An expiration date on its own is metadata — when it passes, the value simply becomes expired and no new version appears. Key Vault's Event Grid events include new versions, near expiry, expiry and access policy changes; there is no read event.
Certificates: issuers and lifetime actions
A certificate's policy sets its issuer and a lifetime action: AutoRenew or EmailContacts, triggered a number of days before expiry or at a percentage of lifetime.
| Certificate source | Fully automatic renewal? | How it works |
|---|---|---|
| Integrated public CA (DigiCert, GlobalSign) | Yes | Configure an issuer; the vault enrolls, renews and stores new versions with no CSR handling |
| Self-signed | Yes | Key Vault renews it, but it is not publicly trusted, so unsuitable for a public website |
| Non-integrated CA (any other public CA or an internal enterprise CA) | No | Create the certificate in the vault with issuer Unknown, send the CSR to the CA, then merge the signed certificate |
Issuer integration exists only for the partnered CAs; an internal CA cannot be registered as an enrolling issuer. When policy says a private key must never leave the vault, create the certificate in the vault (it generates the key pair and a CSR carrying only the public key; the certificate stays pending), have the CA sign the CSR, and Merge Signed Request to complete it. Any workflow that generates the key pair outside the vault breaks the rule, and only the merge operation completes a pending certificate. For manually renewed certificates, add certificate contacts on the vault and an EmailContacts lifetime action so Key Vault emails the team before expiry.
Azure Policy has built-in definitions that audit keys, secrets and certificates (for example, requiring expiration dates or rotation policies); they report compliance but never rotate or renew anything (governance is covered in the Azure Policy lesson).
Defender for Key Vault and Defender CSPM secrets scanning
Defender for Cloud protects secrets in two directions: Microsoft Defender for Key Vault watches access to the vaults you have, and agentless secrets scanning finds secrets that are sitting outside any vault.
Defender for Key Vault
Defender for Key Vault is the threat-protection plan for vaults, enabled on the subscription. It analyzes vault access and raises alerts for unusual or potentially harmful activity — access from a suspicious IP address or a Tor exit node, an identity suddenly reading an unusual number of secrets, unusual applications or users — with no detection rules to write. Diagnostic logs in Log Analytics would need custom queries; Defender CSPM and Azure Policy look at configuration, not live access.
Microsoft's response to an alert: contact the owner of the identity to confirm whether the activity was legitimate, and never dismiss an alert just because the identity is familiar — stolen credentials of a known app look exactly like that. If it was not legitimate, restrict the vault firewall to trusted networks and resources, restrict or remove the identity's permissions, and rotate the secrets, keys and certificates that were accessed, then update the apps. Containment means cutting off access and replacing the exposed material; settings that hide alerts or protect against deletion do not contain a leak.
Secrets scanning with Defender CSPM
Agentless secrets scanning looks for plaintext credentials, such as connection strings, keys and tokens, in three places, and the plan you need depends on the place:
| Where secrets are found | Plans that include it |
|---|---|
| Machines: Azure VMs, AWS EC2 and GCP VM disks | Defender CSPM or Defender for Servers Plan 2 |
| Cloud deployment resources: ARM deployments, AWS CloudFormation stacks | Defender CSPM only |
| Code repositories (Azure DevOps, GitHub and others via DevOps connectors) | Defender CSPM only, plus the DevOps environment connected to Defender for Cloud |
The free Foundational CSPM tier and Defender for Key Vault include no secrets scanning. Repository scanning needs both pieces: the Defender CSPM plan and the Azure DevOps (or GitHub) connector, because Defender for Cloud cannot see repositories that are not onboarded.
Remediating findings such as Machines should have secrets findings resolved: treat the exposed value as compromised, so rotate the credential, store the new value in Key Vault and have the app read it at runtime through a managed identity, then remove the plaintext. Until the plaintext is removed and the credential rotated, the finding describes a live exposure, whatever else is configured.
Tip. SC-500 tests Key Vault through short scenarios with a stated constraint — least privilege, least administrative effort, no exposure to the internet, a key that must never leave the vault — and options that are all real Key Vault features. Expect to separate near-twins: Secrets User from Reader and Secrets Officer, Key Vault Contributor from data roles, Data Access Administrator from User Access Administrator, Premium from Managed HSM and Cloud HSM, service endpoints from private endpoints, a linked privatelink zone from on-premises DNS forwarding, and the trusted-services bypass from permissions. Several items ask what happens after a change (switching permission models, recovering a deleted vault, enabling purge protection), which object type a lifecycle feature applies to (rotation policies for keys, Event Grid for secrets, issuers and lifetime actions for certificates), and which Defender plan covers which scope of secrets scanning versus runtime threat alerts. Multi-response items ask for two parts of one solution.
- Standard vaults protect keys in software; Premium adds multitenant HSM-protected keys and BYOK; Managed HSM is single-tenant with a customer-held security domain but stores keys only; Azure Cloud HSM is an IaaS HSM cluster that does not serve Azure service CMKs.
- Soft delete retention (7–90 days) is fixed at vault creation; purge protection is irreversible and blocks purging, not recovery; CMK integrations such as Azure Storage require both.
- Recovering a deleted vault restores its objects and properties but not its Azure RBAC role assignments or Event Grid subscriptions.
- Key Vault Contributor manages the vault (control plane) and gives no access to secret values; data-plane reads appear in the AuditEvent resource log, not the Activity log.
- Under legacy access policies a Contributor can grant itself data access; Azure RBAC closes that path, switching to it invalidates all access policies, and it is the default for new vaults from API 2026-02-01.
- Use Secrets User to read, Crypto Service Encryption User for CMK wrap/unwrap, Data Access Administrator to delegate Key Vault role assignments only, and a single-secret scope only for a secret shared between apps.
- The firewall filters the data plane only: IP rules take public IPv4 addresses (no private ranges, no service tags), virtual network rules need the Microsoft.KeyVault service endpoint, and the portal's object lists come from the user's own IP.
- A private endpoint plus disabled public access keeps clients off the public endpoint (trusted services still pass unless the bypass is off or Secure by perimeter is used), and clients must resolve through a linked privatelink.vaultcore.azure.net zone, or conditional forwarders to Azure DNS Private Resolver from on-premises.
- Trusted-services bypass covers listed Azure services such as ARM template deployment and Storage CMK — not Azure DevOps or your own app code — survives disabled public access, and never replaces permissions.
- Rotate keys with rotation policies and versionless URIs, rotate secrets with SecretNearExpiry events and a function, auto-renew certificates only from DigiCert, GlobalSign or self-signed issuers, and remediate scanned secrets by rotating them into Key Vault.
Frequently asked questions
What is the difference between Key Vault Secrets User and Key Vault Reader?
Key Vault Secrets User can read the value of secrets in a vault that uses the Azure RBAC permission model, and nothing else. Key Vault Reader can read only metadata of the vault and its objects, such as names, attributes and tags, and can never read a secret's value. An application that needs a connection string from Key Vault therefore needs Key Vault Secrets User.
Why can a user with Key Vault Contributor not see secrets?
Key Vault Contributor is a control-plane role: it manages the vault resource through Azure Resource Manager, such as tags, networking and properties. Reading keys, secrets and certificates is a data-plane operation, and on a vault that uses Azure RBAC it requires a data role such as Key Vault Secrets User or Secrets Officer. Key Vault Contributor also cannot create role assignments, so it cannot grant itself one.
Can I change a key vault's soft-delete retention period after creating it?
No. The soft-delete retention period, between 7 and 90 days, can be set only when the vault is created, and the same interval applies to purge protection. To use a different retention period you create a new vault with the required value and move the keys, secrets and certificates into it.
What happens when a key vault is switched from access policies to Azure RBAC?
Every access policy on the vault stops granting access as soon as the permission model changes to Azure RBAC. Any application or user that relied on an access policy receives 403 Forbidden until an equivalent Key Vault role is assigned to it, so roles should be assigned before the switch. Vaults created with Key Vault API version 2026-02-01 or later use Azure RBAC by default.
Which private DNS zone does an Azure Key Vault private endpoint use?
An Azure Key Vault private endpoint uses the private DNS zone privatelink.vaultcore.azure.net. The zone must hold an A record for the vault and be linked to each virtual network whose clients should resolve the vault's name to the private IP address. On-premises clients need conditional forwarders for vault.azure.net and vaultcore.azure.net to a resolver that can see the zone, such as Azure DNS Private Resolver.
Is Azure DevOps a trusted Microsoft service for the Key Vault firewall?
No. Azure DevOps is not on the Key Vault trusted services list because customers run their own code on it, so the trusted-services bypass does not admit Microsoft-hosted pipeline agents. Pipelines can reach a firewalled vault from self-hosted agents in an allowed virtual network or through a private endpoint, or by allowing the hosted agents' published IP ranges, which are broad and shared.
Which Defender for Cloud plan scans for secrets in code repositories and ARM deployments?
Defender CSPM is the plan that includes agentless secrets scanning of code repositories and of cloud deployment resources such as ARM deployments and AWS CloudFormation stacks. Defender for Servers Plan 2 includes secrets scanning of machines only. Repository scanning also requires the Azure DevOps or GitHub environment to be connected to Defender for Cloud.
Can Key Vault automatically renew a certificate from any certificate authority?
No. Key Vault can fully renew certificates automatically only when they are issued by its integrated certificate authorities, DigiCert and GlobalSign, or when they are self-signed. Certificates from any other CA, including an internal enterprise CA, are renewed by creating a new certificate signing request in the vault, having the CA sign it and merging the signed certificate; an EmailContacts lifetime action can remind certificate contacts before expiry.
Source
This lesson covers the "Manage identity, access, and governance" domain of the official SC-500 exam guide. Vendors revise their guides — check the source for the current version.
- Microsoft SC-500 study guide — Microsoft Learn
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.