Deploying and Configuring Key Vault
This lesson explains what Key Vault protects, how to choose a tier, and which settings prevent the loss of keys and secrets.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish keys, secrets and certificates.
- Choose among Standard, Premium and Managed HSM.
- Explain soft delete and purge protection.
- Deploy a vault with protective settings.
What Key Vault protects
Applications depend on sensitive values: connection strings, API tokens, encryption keys and TLS certificates. When these values are scattered through configuration files and pipelines, nobody can say who has seen them, and rotating them is slow. Azure Key Vault centralizes them behind Microsoft Entra authentication, Azure authorization, network rules and audit logging.
A vault holds three types of object, and each answers a different need.
| Object | What it is | How it is used | Example |
|---|---|---|---|
| Secret | Any value of up to 25 KB, stored encrypted | An application retrieves the value | A database connection string |
| Key | An RSA or elliptic curve cryptographic key | Operations occur inside the vault, so the private key never leaves | A customer-managed key for Azure Storage encryption |
| Certificate | An X.509 certificate with its private key and policy | Key Vault can create and renew it, and services can use it | A TLS certificate for Azure Application Gateway |
The distinction between secrets and keys matters. An application reads a secret and then holds the value in memory. An application asks a key to perform an operation, such as sign or unwrap, and the key material stays protected.
Secret, key or certificate?
Choosing a tier and a design
Azure offers several options for key storage. Standard protects keys in software. Premium adds keys protected by hardware security modules (HSMs). Managed HSM is a separate, fully managed, single-tenant service, for cases in which an organization must have sole control of the security domain or must meet a higher validation level.
The recommended design is one vault per application per environment. A shared vault means that a person or workload with access to it can reach everyone's secrets, and that throttling by one workload affects all the others. Separate vaults also make it easy to apply different network rules, and to delete a project without affecting anything else. A vault name is globally unique, because it forms part of the DNS name VAULT.vault.azure.net.
Tier and design
Protecting against deletion
A deleted key can be a disaster: data encrypted with it becomes unreadable. Two settings work together to prevent this.
- Soft delete keeps a deleted vault or object in a recoverable state. It is on by default, cannot be disabled once enabled, and has a retention period of 7 to 90 days, with a default of 90. The period is set when the vault is created and cannot be changed afterwards.
- Purge protection prevents anyone, including an administrator, from permanently deleting a soft-deleted item before the retention period ends. It is not on by default, and it cannot be turned off once it is set.
Soft delete alone leaves a gap, because someone with the Key Vault Purge Operator role can purge a deleted object immediately. A malicious insider, or an attacker who holds such a role, could therefore destroy a key for ransom. Purge protection closes this gap, and services that use customer-managed keys, such as Azure Storage and Azure Disk Encryption, depend on it.
The following diagram compares a deleted key with and without purge protection.

Purge protection is permanent
Because purge protection cannot be reversed, a vault with this setting cannot be removed from your subscription until the retention period passes, and the same vault name cannot be reused during that time. Plan for this in test environments.
Soft delete numbers
Access configuration settings
The Access configuration page sets the permission model and allows selected Azure services to retrieve vault contents. The three resource access options are Azure Virtual Machines for deployment, which lets a VM retrieve certificates, Azure Resource Manager for template deployment, which lets a deployment retrieve secrets, and Azure Disk Encryption for volume encryption. Each is off by default, and each should be enabled only when needed.
Vaults created through control plane API version 2026-02-01 or later use Azure RBAC by default. Earlier API versions retire on 27 February 2027, so older deployment templates must be updated. Existing vaults keep their current model. The API change matters for automation: a template that assumes access policies will produce a vault that ignores them unless enableRbacAuthorization is set to false.
Access configuration
Deploying a vault with a command
The following Azure CLI command creates a vault with purge protection and a 90-day retention period. The values in capitals are placeholders.
az keyvault create --name VAULT --resource-group RG --location westeurope \
--sku standard --enable-purge-protection true --retention-days 90Enable diagnostic settings after creating a vault, because access events are not recorded by default. Sending AuditEvent logs to a Log Analytics workspace allows Microsoft Sentinel and other tools to analyse who accessed what.
Protecting a customer-managed key
A company stores a customer-managed key for Azure Storage in a key vault. A regulator requires that no individual, including a subscription owner, can permanently destroy the key within 60 days of its deletion. The vault was created with 30-day soft delete retention. What must you do?
Two facts decide the answer. Retention cannot be changed after a vault is created, so this vault can never offer 60 days. Soft delete alone also fails, because an authorized person can purge an object. The solution is a new vault created with retention of at least 60 days and purge protection enabled, followed by moving the key to it and updating the storage account's key reference. Moving a key between vaults uses backup and restore, within the same subscription and geography, or a new key can be created and data re-wrapped.
Enabling purge protection on the existing vault would stop purging, but only within its 30-day retention. A resource lock protects the vault resource, but it does not prevent the deletion of an object in the data plane.
Who can permanently delete a soft-deleted key before the retention period ends if purge protection is on?
Show answer
Nobody. Purge protection blocks purging, even by an administrator, until the retention period passes.
Exam Tips
Remember for the exam
- Soft delete retention is fixed at creation, from 7 to 90 days.
- Purge protection cannot be turned off.
- Use one vault per application per environment.
- Enable diagnostic settings, or access events are not logged.