Prev Next

Java / Azure Key Vault Interview questions

Last updated

1. What is Azure Key Vault? 2. How do secrets, keys and certificates differ in Key Vault? 3. What are the Standard and Premium tiers of Key Vault? 4. What are the naming rules for a Key Vault? 5. How do you create a Key Vault with Azure CLI? 6. What is a secret in Azure Key Vault? 7. What is the maximum size of a secret in Key Vault? 8. What is a key in Azure Key Vault? 9. Which key types and sizes does Key Vault support? 10. What is a certificate in Azure Key Vault? 11. What is the Key Vault pricing model? 12. What is the difference between versioned and versionless identifiers in Key Vault? 13. What are secret attributes like nbf and exp used for? 14. What is soft delete in Azure Key Vault? 15. What is purge protection in Key Vault? 16. How do you recover a deleted secret in Key Vault? 17. What is the difference between the management plane and data plane in Key Vault? 18. What is the difference between Key Vault access policies and Azure RBAC? 19. What are the built-in Azure RBAC roles for Key Vault? 20. What is a managed identity and why use it with Key Vault? 21. How do you read a secret using the.NET SDK? 22. How does DefaultAzureCredential authenticate to Key Vault? 23. What is Azure Key Vault Managed HSM? 24. What is the difference between Key Vault and Managed HSM? 25. How do you restrict network access to a Key Vault? 26. What is a private endpoint for Key Vault? 27. What does Allow trusted Microsoft services do in the Key Vault firewall? 28. How do you enable logging and monitoring for Key Vault? 29. How do you get alerted when a Key Vault secret is about to expire? 30. How do App Service Key Vault references work? 31. How does AKS retrieve Key Vault secrets? 32. How do you rotate a Key Vault secret without downtime? 33. How does automatic key rotation work in Key Vault? 34. How do certificate lifetime actions and auto-renewal work? 35. What is envelope encryption and how does Key Vault support it? 36. What are customer-managed keys and where are they used? 37. How does Azure Storage encryption with a Key Vault key work? 38. How does SQL Transparent Data Encryption with a Key Vault key work? 39. What is BYOK and how do you import a key into Key Vault? 40. What happens when a customer-managed key in Key Vault is disabled or deleted? 41. How do Key Vault backup and restore work? 42. How does Key Vault provide high availability? 43. What is Key Vault throttling and how do you handle 429 errors? 44. How do you troubleshoot a 403 Forbidden error from Key Vault? 45. How do you get a certificate with its private key out of Key Vault? 46. When should you use separate Key Vaults per environment? 47. What is the difference between Key Vault and Azure App Configuration? 48. How do you deploy a Key Vault using Bicep? 49. What are the enabledForDeployment, enabledForTemplateDeployment and enabledForDiskEncryption flags? 50. How do you use Key Vault in Azure Pipelines or GitHub Actions?

1. What is Azure Key Vault?

Azure Key Vault is a managed Azure service for storing and controlling access to secrets, cryptographic keys and TLS certificates. Applications call it over HTTPS instead of keeping connection strings, passwords or private keys in code, config files or pipelines.

Microsoft runs the infrastructure, patching and HSM hardware. You decide who can read what, every caller is authenticated through Microsoft Entra ID, and requests can be logged for audit.

Typical uses are database passwords, API keys, encryption keys for storage and databases, and certificates for web endpoints.

Take quiz
Which three kinds of objects does Key Vault manage?
Secrets, keys and certificates
Virtual machines, disks and NICs
Blobs, queues and tables
Users, groups and subscriptions
Which service authenticates callers to Key Vault?
Azure Monitor
Azure DNS
Azure Front Door
Microsoft Entra ID

2. How do secrets, keys and certificates differ in Key Vault?

All three live in the same vault, but they behave differently when you read them.

Object What it holds What you get back Typical use
Secret Any string up to 25 KB The stored value itself Passwords, connection strings, API keys
Key RSA or EC key pair (or AES on Managed HSM) Results of operations, not the private key Sign, verify, encrypt, wrap, unwrap
Certificate X.509 certificate plus a lifecycle policy Public cert; a linked key and secret are created too TLS, client auth, auto-renewal

The key point is that an application never needs to hold a key's private material. It asks Key Vault to do the cryptographic work.

Take quiz
An app must sign data without ever seeing the private key. Which object fits?
A vault tag
A managed identity
A key
A secret
What does reading a Key Vault secret return?
The stored value itself
A pointer that needs a second call to resolve
Only a hash of the value
An encrypted blob that only an HSM can open

3. What are the Standard and Premium tiers of Key Vault?

Both tiers store secrets, keys and certificates with the same APIs. The difference is how keys are protected.

Standard Premium
Key protection Software-protected Software or HSM-protected
Key types RSA, EC RSA, EC, plus RSA-HSM and EC-HSM
Secrets and certificates Supported Supported (same behaviour)
Cost Lower per-operation price Higher price for HSM-backed keys

Choose Premium when a compliance rule says keys must be generated and used inside hardware. For everything else Standard is enough.

Take quiz
What does Premium add over Standard?
Secrets larger than 25 KB
Support for managed identities
Soft delete
HSM-protected keys
How are keys protected in a Standard vault?
Only on the client machine
Inside a customer-owned dedicated HSM
Inside Microsoft Entra ID
In software

4. What are the naming rules for a Key Vault?

A vault name must be globally unique because it becomes part of the public DNS name <name>.vault.azure.net.

  • 3 to 24 characters long
  • Only letters, digits and hyphens
  • Must start with a letter and end with a letter or digit
  • No two hyphens in a row

Names of soft-deleted vaults stay reserved until the vault is purged or the retention period ends, so you cannot reuse the name straight after deleting.

Take quiz
Which name is valid for a new vault?
contoso-kv-prod
contoso_kv_prod
contoso--kv
-contoso-kv
Why must a vault name be unique worldwide?
It becomes the name of the default encryption key
Entra ID needs it for tenant lookup
It forms the public DNS name name.vault.azure.net
It is used as the subscription ID

5. How do you create a Key Vault with Azure CLI?

Create a resource group first, then the vault. For new vaults, turn on RBAC authorization and purge protection from day one.

az group create --name rg-demo --location eastus

az keyvault create \
  --name contoso-kv-01 \
  --resource-group rg-demo \
  --location eastus \
  --enable-rbac-authorization true \
  --enable-purge-protection true

az keyvault secret set --vault-name contoso-kv-01 --name DbPassword --value &quot;S3cr3t!&quot;

Creating the vault does not give you data access automatically. Assign a role such as Key Vault Secrets Officer before running the last command.

Take quiz
Which flag makes a new vault use Azure RBAC for data access?
--sku premium
--public-network-access Disabled
--enable-soft-delete false
--enable-rbac-authorization true
Which command stores a new secret?
az keyvault secret set
az keyvault certificate create
az keyvault secret purge
az keyvault key import

6. What is a secret in Azure Key Vault?

A secret is any small piece of text you want to keep out of source control: a password, token, connection string or even a base64 certificate. Key Vault stores it encrypted and returns the same value to authorised callers.

Every set creates a new version. The identifier looks like this:

https://contoso-kv-01.vault.azure.net/secrets/DbPassword/3f9a1c...  (specific version)
https://contoso-kv-01.vault.azure.net/secrets/DbPassword            (latest)

Each secret can also carry a content type, tags, an activation date, an expiry date and an enabled flag.

Take quiz
What happens when you set a secret that already exists?
The command fails with a conflict error
The old value is overwritten with no history
The vault is recreated
A new version is created and becomes current
Which part of a secret identifier can you omit to always get the latest value?
The version segment
The vault name
The /secrets/ path segment
The https scheme

7. What is the maximum size of a secret in Key Vault?

A single secret can hold up to 25 KB of data. That is plenty for passwords, tokens and connection strings, but not for files.

If you need to protect something bigger, such as a large config file, encrypt it yourself, keep the ciphertext in Blob Storage, and store only the encryption key (or a key reference) in Key Vault. Splitting a big payload across many secrets is possible but makes versioning and rotation messy.

Take quiz
What is the maximum size of one secret?
10 MB
256 bytes
25 KB
1 MB
Where should a 5 MB config file go?
Encrypted in Blob Storage, with the key kept in Key Vault
In the secret's tags field
Directly in one secret
In the vault name

8. What is a key in Azure Key Vault?

A key is a cryptographic key managed by the vault. Unlike a secret, you normally cannot read its private part. You send data to the vault and it returns the result.

  • Encrypt / decrypt small payloads
  • Sign / verify hashes or tokens
  • Wrap / unwrap other keys (used for envelope encryption)

Keys can be created in the vault or imported, and can be software-protected or HSM-protected on Premium. Services such as Storage, SQL and disk encryption use Key Vault keys as customer-managed keys.

Take quiz
Which operation lets you protect another encryption key with a vault key?
Backup and purge
List and tag
Wrap and unwrap
Rotate and disable
Can an app normally download the private part of a vault key?
Yes, if it is in the same resource group
Yes, using the get key operation
Yes, but only on weekdays
No, it asks the vault to perform operations

9. Which key types and sizes does Key Vault support?

Type Sizes / curves Where
RSA 2048, 3072, 4096 bit Standard and Premium (software)
RSA-HSM 2048, 3072, 4096 bit Premium and Managed HSM
EC P-256, P-384, P-521, P-256K Standard and Premium (software)
EC-HSM P-256, P-384, P-521, P-256K Premium and Managed HSM
oct-HSM 128, 192, 256 bit AES Managed HSM only

RSA 2048 is the usual minimum for new work. Use EC when you need smaller signatures and faster operations.

Take quiz
Which key type is available only on Managed HSM?
RSA 4096
oct-HSM (symmetric AES)
RSA 2048
EC P-256
Which RSA key size is not offered by Key Vault?
4096-bit
3072-bit
1024-bit
2048-bit

10. What is a certificate in Azure Key Vault?

A Key Vault certificate is an X.509 certificate plus a policy that describes how it is created, exported and renewed.

When you create one, the vault actually produces three linked objects: the certificate itself, an addressable key and an addressable secret that holds the full certificate with its private key (PKCS#12 or PEM).

The policy can name an issuer (self-signed, DigiCert, GlobalSign or a non-integrated CA), key type and size, subject and SANs, and lifetime actions such as auto-renew.

Take quiz
Which three objects does a Key Vault certificate produce?
Certificate, addressable key and addressable secret
Certificate, backup and log entry
Certificate, role assignment and tag
Certificate, private endpoint and DNS record
What does the certificate policy control?
Which VNet the vault joins
Issuer, key settings, subject and renewal behaviour
How many replicas the vault has
Which users are in the tenant

11. What is the Key Vault pricing model?

Key Vault is billed on usage, not on the number of secrets you store. The main meters are:

  • Operations: charged per block of 10,000 transactions (secret reads, key operations, and so on)
  • Certificates: a charge per renewal request
  • HSM-protected keys on Premium: a monthly charge per key, plus operations
  • Managed HSM: hourly charge per pool

Rates change and differ by region, so check the Azure pricing page or calculator. In practice, caching secrets in the app keeps both cost and throttling low.

Take quiz
What is the main basis for Standard Key Vault billing?
Number of operations performed
Number of users in the tenant
Length of the vault name
Number of resource groups
Which design choice most directly lowers operation charges?
Reading the secret on every request
Disabling soft delete
Caching secrets in the application
Creating a new vault per request

12. What is the difference between versioned and versionless identifiers in Key Vault?

A versioned identifier ends with a version ID and always points to one immutable value. A versionless identifier omits it and resolves to whatever version is currently latest and enabled.

Identifier Example Behaviour
Versioned /secrets/DbPassword/3f9a1c... Never changes, rotation is ignored
Versionless /secrets/DbPassword Follows rotation to the newest version

Use versionless for anything that should pick up rotation automatically, such as App Service references or storage encryption keys. Use versioned only when you must pin an exact value.

Take quiz
Which identifier automatically follows a rotated secret?
The versioned one
The one ending in .pfx
The one with the vault tag
The versionless one
When would you pin a versioned identifier?
When the vault has no network rules
When a consumer must keep using one exact value
When using Azure CLI only
When you want rotation to be automatic

13. What are secret attributes like nbf and exp used for?

Each secret version carries metadata: enabled, nbf (not before), exp (expiry), created and updated times, plus a content type and tags.

enabled set to false switches that version off. The nbf and exp dates are mainly informational: the vault does not rotate or delete the secret for you. They exist so you can raise alerts and so consumers know a value is meant to be retired.

az keyvault secret set --vault-name contoso-kv-01 --name ApiKey --value abc123 --expires 2027-03-31T00:00:00Z

Take quiz
What does exp mainly provide for a secret?
Automatic rotation to a new value
Automatic move to another vault
An informational expiry date you can alert on
Automatic deletion of the secret
Which attribute turns a secret version off without deleting it?
content type set to none
tags cleared
nbf set to today
enabled set to false

14. What is soft delete in Azure Key Vault?

Soft delete keeps a deleted vault or vault object (secret, key, certificate) recoverable for a retention period instead of removing it immediately. It is always on for vaults and cannot be turned off.

You pick a retention of 7 to 90 days at creation, default 90. During that window the item is in a deleted state: you can list it, recover it, or purge it (unless purge protection is on).

One side effect: while a vault is soft-deleted its name stays reserved, so you cannot create a new vault with the same name.

Take quiz
What is the allowed soft-delete retention range?
0 to 1 day
30 to 365 days
1 to 7 days
7 to 90 days
What happens to a deleted vault's name during retention?
It is renamed with a random suffix
It is handed to another tenant
It stays reserved
It is released immediately

15. What is purge protection in Key Vault?

Purge protection blocks permanent deletion of soft-deleted vaults and objects until the retention period ends. Even an owner cannot purge early.

Once enabled it cannot be disabled. That is the point: an attacker or a careless admin cannot wipe keys and then purge them to make the data unrecoverable.

It is mandatory when you use a Key Vault key as a customer-managed key for services like Storage or SQL, because losing the key would mean losing the data.

Take quiz
Can purge protection be turned off after it is enabled?
Yes, by deleting the vault tags
Yes, after 24 hours
No
Yes, by any Contributor
Why do CMK scenarios require purge protection?
It speeds up wrap and unwrap
Losing the key would make the encrypted data unrecoverable
It lowers the operation price
It lets the key leave the vault

16. How do you recover a deleted secret in Key Vault?

If soft delete retention has not expired, list the deleted items and recover the one you need. You need the right permission, such as Key Vault Secrets Officer.

az keyvault secret list-deleted --vault-name contoso-kv-01
az keyvault secret recover --vault-name contoso-kv-01 --name DbPassword

# whole vault
az keyvault recover --name contoso-kv-01

Recovery restores the object with all its versions. If purge protection was on, you simply wait; nothing can remove it before retention ends.

Take quiz
Which command lists secrets waiting for recovery?
az keyvault secret list-versions
az keyvault secret list-deleted
az keyvault secret backup
az keyvault secret show-deleted-vault
What does recovery restore?
The secret with all its versions
Only the latest version
Only the metadata
Only the access policy

17. What is the difference between the management plane and data plane in Key Vault?

Key Vault exposes two separate surfaces, each with its own authorization.

Management plane Data plane
Endpoint management.azure.com (Azure Resource Manager) <vault>.vault.azure.net
What it does Create, delete, configure vaults, firewall, RBAC Read and write secrets, keys, certificates
Auth Azure RBAC on the resource Azure RBAC data roles or access policies
Token audience https://management.azure.com https://vault.azure.net

A person with the plain Contributor role can manage the vault but has no data access under the RBAC model. This split is a main reason to prefer RBAC over access policies.

Take quiz
Which endpoint serves secret reads?
management.azure.com
portal.azure.com
The vault's own vault.azure.net URL
login.microsoftonline.com
Under RBAC, what can a plain Contributor do with secrets?
Purge every secret
Read every secret
Rotate every key
Nothing, until given a data-plane role

18. What is the difference between Key Vault access policies and Azure RBAC?

Both control data-plane access, but they work very differently. Access policies are the original per-vault model; Azure RBAC is the recommended model that uses the same role system as the rest of Azure.

Access policies Azure RBAC
Scope Whole vault only Management group, subscription, resource group, vault, or a single secret/key/cert
Permissions Lists like get, list, set, wrapKey Built-in roles such as Secrets User
Who can grant Anyone with Contributor on the vault Only Owner / User Access Administrator
Limits Up to 1,024 policies per vault Role assignment quotas per subscription
Tools Vault-specific Azure Policy, PIM, conditional access, activity log

Both models cannot be active at once. Setting enableRbacAuthorization to true makes the vault ignore its access policies, which is a common cause of sudden 403 errors after migration.

Take quiz
Which model lets you assign access to a single secret?
Network ACLs
Azure RBAC
Vault tags
Access policies
What happens to access policies when RBAC authorization is enabled?
They become read-only roles
They apply only to keys
They are ignored
They are merged with roles

19. What are the built-in Azure RBAC roles for Key Vault?

Microsoft ships separate data-plane roles so you can give an app just the access it needs.

Role What it allows
Key Vault Administrator All data-plane operations on keys, secrets, certificates
Key Vault Secrets Officer Manage secrets (set, delete, purge), not role assignments
Key Vault Secrets User Read secret values only
Key Vault Crypto Officer Manage keys
Key Vault Crypto User Perform crypto operations with keys (sign, wrap, decrypt)
Key Vault Certificates Officer Manage certificates
Key Vault Reader Read metadata, not secret values
Key Vault Crypto Service Encryption User get, wrap, unwrap for services using CMK

A running app that only reads a password should get Secrets User, scoped to the vault or the specific secret.

Take quiz
Which role is right for an app that only reads secret values?
Key Vault Secrets User
Key Vault Certificates Officer
Key Vault Crypto Officer
Key Vault Administrator
What does Key Vault Reader expose?
Only backup files
All secret values
Metadata but not secret values
Only private keys

20. What is a managed identity and why use it with Key Vault?

A managed identity is an Entra ID identity that Azure creates and rotates for a resource (VM, App Service, Function, AKS pod). The app gets tokens without any stored credential, which solves the classic chicken-and-egg problem: you need a secret to fetch secrets.

sequenceDiagram
    participant App as App Service
    participant ID as Entra ID / identity endpoint
    participant KV as Key Vault
    App->>ID: Request token for vault.azure.net
    ID-->>App: Access token (managed identity)
    App->>KV: GET secret + Bearer token
    KV-->>App: Secret value

System-assigned identities live and die with the resource. User-assigned identities are separate objects you can share across resources. Grant the identity a role like Secrets User on the vault.

Take quiz
What problem do managed identities solve for Key Vault clients?
They disable the vault firewall
They remove the need for a vault
They make secrets larger
They remove the need to store a credential to reach the vault
Which identity type can be reused across several resources?
User-assigned
Guest user
Service endpoint
System-assigned

21. How do you read a secret using the.NET SDK?

Use Azure.Security.KeyVault.Secrets with Azure.Identity. The credential finds the identity automatically, so no password appears in code.

using Azure.Identity;
using Azure.Security.KeyVault.Secrets;

var client = new SecretClient(
    new Uri(&quot;https://contoso-kv-01.vault.azure.net/&quot;),
    new DefaultAzureCredential());

KeyVaultSecret secret = await client.GetSecretAsync(&quot;DbPassword&quot;);
string value = secret.Value;

Create the client once and reuse it, and cache the value for a sensible time. The identity running the code needs at least the Secrets User role.

Take quiz
Which class supplies credentials without hard-coded passwords?
VaultKeyReader
DefaultAzureCredential
SecretPasswordProvider
BlobSasCredential
Why create SecretClient once and reuse it?
The vault allows only one client
It avoids repeated setup and extra calls
It encrypts the secret twice
It disables throttling

22. How does DefaultAzureCredential authenticate to Key Vault?

DefaultAzureCredential tries several credential sources in order and uses the first that works. That lets the same code run on a laptop and in Azure.

  1. Environment variables (service principal)
  2. Workload identity (AKS)
  3. Managed identity (Azure-hosted)
  4. Developer sign-ins: Visual Studio, VS Code, Azure CLI, Azure PowerShell, azd

In Azure, the managed identity step succeeds. On a developer machine, the az login account is used. Because this chain can pick an unexpected credential, many teams use ManagedIdentityCredential directly in production for predictability.

Take quiz
On a developer laptop, which credential does DefaultAzureCredential commonly end up using?
The vault's access key
The machine's BIOS password
The signed-in Azure CLI or IDE account
The subscription ID
Why might production code use ManagedIdentityCredential directly?
It is the only one that supports HTTPS
It bypasses RBAC
To avoid an unexpected credential being picked from the chain
It skips token expiry

23. What is Azure Key Vault Managed HSM?

Managed HSM is a fully managed, single-tenant pool of FIPS 140 Level 3 validated hardware security modules. You get dedicated HSMs, and only you control the keys.

  • Stores keys only (no secrets or certificates)
  • Uses its own local RBAC for the data plane, no access policies
  • Initial admins are set at creation, then you download a security domain to activate it
  • Always has soft delete and purge protection

The security domain is the root of trust used to recover the HSM. Lose it and you cannot restore the pool, so store it safely, split under a quorum such as 3 of 5 keys.

Take quiz
What can a Managed HSM store?
Keys only
Secrets only
Blobs and queues
Secrets and certificates only
What do you need to protect to be able to recover a Managed HSM?
The resource group name
The subscription ID
The security domain
The TLS certificate of the portal

24. What is the difference between Key Vault and Managed HSM?

Key Vault (Standard/Premium) Managed HSM
Tenancy Multi-tenant service Single-tenant, dedicated HSMs
Stores Secrets, keys, certificates Keys only
Key protection Software or HSM (Premium) Always HSM, FIPS 140 Level 3
Access control RBAC or access policies Local RBAC (plus Azure RBAC for management)
Billing Per operation / per HSM key Hourly per HSM pool
Choose when General app secrets and standard CMK Strict compliance and full key control

Many teams use both: a normal vault for app secrets and a Managed HSM for the root encryption keys of regulated data.

Take quiz
Which one is single-tenant?
Standard Key Vault
Azure App Configuration
Premium Key Vault
Managed HSM
Where do you keep database passwords in a mixed design?
In the security domain
In the HSM firmware
In a normal Key Vault
In Managed HSM as secrets

25. How do you restrict network access to a Key Vault?

By default a vault is reachable over the public endpoint, protected only by authentication. You can tighten that in layers:

  1. Firewall: set default action to Deny and allow specific IP ranges.
  2. Virtual network rules: allow subnets that use the Microsoft.KeyVault service endpoint.
  3. Private endpoint: give the vault a private IP in your VNet, then disable public network access.
  4. Trusted services bypass: let selected Azure services through even when the firewall denies.
az keyvault update --name contoso-kv-01 --default-action Deny
az keyvault network-rule add --name contoso-kv-01 --ip-address 203.0.113.10/32

Network rules add to identity checks, they do not replace them.

Take quiz
Which setting blocks all non-listed networks at the vault firewall?
Default action set to Deny
Soft delete retention of 7 days
Default action set to Allow
Purge protection on
Do network rules replace RBAC?
Yes, but only for keys
Only for certificates
Yes, the firewall replaces RBAC
No, both apply together

26. What is a private endpoint for Key Vault?

A private endpoint is a network interface in your VNet with a private IP that maps to your vault through Azure Private Link. Traffic stays on the Microsoft backbone and never uses the public endpoint.

flowchart LR
    A["App in VNet"] --> B["Private DNS zone privatelink.vaultcore.azure.net"]
    B --> C["Private endpoint 10.0.1.5"]
    C --> D[(Key Vault)]

You must create a private DNS zone so that contoso-kv-01.vault.azure.net resolves to the private IP. If DNS still returns the public address and public access is disabled, calls fail with 403.

Take quiz
What does a private endpoint give the vault inside your VNet?
A second vault name
A new Entra tenant
A private IP address
A public static IP
What commonly breaks after you add a private endpoint?
The vault losing its secrets
RBAC roles disappearing
DNS still resolving to the public address
Key versions resetting

27. What does Allow trusted Microsoft services do in the Key Vault firewall?

It sets the bypass option to AzureServices. Even when the firewall denies public traffic, certain first-party Azure services are allowed through, for example Azure Backup, Azure Disk Encryption, Azure Storage and SQL when using customer-managed keys.

The service must still be authorized with a role or policy. The bypass only skips the network check.

networkAcls: {
  defaultAction: &#x27;Deny&#x27;
  bypass: &#x27;AzureServices&#x27;
}

Not every Azure service is trusted this way. Generic compute like a normal VM or App Service needs a VNet rule, private endpoint or IP rule.

Take quiz
What does the trusted services bypass skip?
The key size limit
The soft delete rule
The network firewall check
The identity check
Does a regular VM get through the firewall because of the bypass?
Yes, but only for keys
Yes, always
No, it needs its own network rule
Yes, only in Premium

28. How do you enable logging and monitoring for Key Vault?

Add a diagnostic setting on the vault and send the AuditEvent log category to Log Analytics, a storage account or Event Hubs. Each data-plane request is recorded with caller identity, operation, IP and result code.

AzureDiagnostics
| where ResourceProvider == &quot;MICROSOFT.KEYVAULT&quot;
| where OperationName == &quot;SecretGet&quot;
| summarize count() by CallerIPAddress, identity_claim_appid_g, ResultSignature

Metrics such as ServiceApiHit, ServiceApiLatency and Availability help spot throttling and outages. Alert rules on 403/429 results catch misconfiguration early.

Take quiz
Which log category records data-plane requests?
AuditEvent
VMGuestHealth
CostAnalysis
FlowLogs
Which signal helps notice throttling?
The number of resource groups
The vault tag count
A spike in 429 results or ServiceApiHit
The vault creation date

29. How do you get alerted when a Key Vault secret is about to expire?

Key Vault publishes events to Azure Event Grid. The relevant ones are SecretNearExpiry (fires about 30 days before expiry), SecretExpired and SecretNewVersionCreated. Similar events exist for keys and certificates.

flowchart LR
    KV["Key Vault"] --> EG["Event Grid"]
    EG --> F["Azure Function / Logic App"]
    F --> N["Email, Teams or rotate secret"]

Subscribe a Function or Logic App to the event, then notify the owner or run a rotation. This only works for secrets that have an expiry date set.

Take quiz
Roughly how early does SecretNearExpiry fire?
One year after expiry
Only at creation
One minute before expiry
About 30 days before expiry
What must a secret have for expiry events to be useful?
An expiry date
A Premium vault
A tag called alert
A private endpoint

30. How do App Service Key Vault references work?

A Key Vault reference lets an App Service or Function app setting point at a secret instead of containing it. The platform resolves it at runtime using the app's managed identity, so your code just reads an ordinary environment variable.

@Microsoft.KeyVault(SecretUri=https://contoso-kv-01.vault.azure.net/secrets/DbPassword/)
@Microsoft.KeyVault(VaultName=contoso-kv-01;SecretName=DbPassword)

Requirements: a managed identity on the app with Secrets User on the vault, and network path to the vault. Without a version, the value is refreshed periodically (roughly daily), so a new secret version appears without redeploying. If resolution fails, the setting shows the error in the portal.

Take quiz
What does the app code see when using a Key Vault reference?
A normal app setting holding the resolved value
The vault's access key
A link it must call itself
An encrypted file
What permission does the app identity need?
Secrets User on the vault
Reader on the resource group only
Owner on the subscription
Network Contributor

31. How does AKS retrieve Key Vault secrets?

The Azure Key Vault provider for Secrets Store CSI Driver mounts secrets into pods as files. You describe what to fetch in a SecretProviderClass, and the pod authenticates with workload identity (recommended) or a managed identity.

sequenceDiagram
    participant Pod
    participant CSI as Secrets Store CSI driver
    participant KV as Key Vault
    Pod->>CSI: Mount volume (SecretProviderClass)
    CSI->>KV: Get secret using workload identity
    KV-->>CSI: Secret value
    CSI-->>Pod: File at /mnt/secrets

Optionally the driver can also sync the value into a Kubernetes Secret. Enable the add-on with az aks enable-addons --addons azure-keyvault-secrets-provider.

Take quiz
How are secrets delivered to the pod?
Copied into the container image at build
Mounted as files through a CSI volume
Pushed into the node BIOS
Sent by email
Which object describes which Key Vault items to fetch?
PodDisruptionBudget
SecretProviderClass
StorageClass
IngressRoute

32. How do you rotate a Key Vault secret without downtime?

The safe approach is to make both the old and new values valid for a while, then retire the old one.

  1. Create the new credential in the target system (a second password or key).
  2. Set it as a new version of the secret in Key Vault.
  3. Consumers using a versionless reference pick up the new version as they refresh.
  4. After all clients have switched, disable or revoke the old credential and old version.

Services with two interchangeable credentials, such as storage account keys, make this easy. Automate it with an Event Grid trigger on SecretNearExpiry and an Azure Function. Apps should also retry once by re-reading the secret when authentication fails.

Take quiz
What is the first step in a zero-downtime rotation?
Rename the vault
Delete the old secret first
Disable the vault
Create the new credential while the old one still works
Why use a versionless reference during rotation?
It forces the old value to stay
It encrypts the secret again
It stops all rotation
Clients pick up the new version without redeploying

33. How does automatic key rotation work in Key Vault?

You attach a rotation policy to a key. It defines when to create a new key version and when to send a notification, based on time after creation or time before expiry.

az keyvault key rotation-policy update --vault-name contoso-kv-01 --name data-kek --value policy.json
az keyvault key rotate --vault-name contoso-kv-01 --name data-kek

Rotation creates a new version, it does not delete the old one, so existing ciphertext can still be decrypted. Services using a versionless key URI, like Storage CMK, switch to the new version automatically. Event Grid fires KeyNewVersionCreated.

Take quiz
What does key rotation create?
A new subscription
A new vault
A new key version
A deleted key
Why can old data still be decrypted after rotation?
Rotation exports the key to Blob
Data is re-encrypted instantly
Old key versions remain available
The vault ignores versions

34. How do certificate lifetime actions and auto-renewal work?

A certificate policy can contain lifetime actions: at a set percentage of lifetime (default 80%) or a number of days before expiry, the vault either AutoRenews or emails the contacts.

Issuer Auto-renew?
Self-signed Yes, vault re-issues itself
Integrated CA (DigiCert, GlobalSign) Yes, vault requests a new cert from the CA
Non-integrated CA No, you get a notification and complete the CSR manually

Renewal creates a new certificate version. Consumers using a versionless certificate URI get the new one, but services that cache the certificate must reload it.

Take quiz
Which issuer type can NOT be auto-renewed by the vault alone?
DigiCert integration
GlobalSign integration
A non-integrated CA
Self-signed
What does renewal create?
A new tenant
A new resource group
A new certificate version
A new vault

35. What is envelope encryption and how does Key Vault support it?

Envelope encryption uses two layers of keys. A fast data encryption key (DEK) encrypts the data. A key encryption key (KEK) kept in Key Vault encrypts, or wraps, the DEK.

flowchart LR
    A["Generate DEK locally"] --> B["Encrypt data with DEK"]
    A --> C["Wrap DEK with KEK in Key Vault"]
    B --> D["Store ciphertext"]
    C --> E["Store wrapped DEK next to data"]

To read the data, the app sends the wrapped DEK to Key Vault's unwrapKey operation, gets the DEK back and decrypts locally. Only small DEKs travel to the vault, so you avoid RSA size limits and heavy traffic. The KEK itself never leaves the vault.

Take quiz
What does the Key Vault key protect in envelope encryption?
The data encryption key (it wraps the DEK)
The TLS handshake
The user's password hash
The whole disk image directly
Which operation recovers the DEK?
backupKey
purgeKey
unwrapKey
listKeys

36. What are customer-managed keys and where are they used?

Customer-managed keys (CMK) let you own the root key that protects a service's data at rest, instead of relying on Microsoft-managed keys. The key lives in your Key Vault or Managed HSM, and the service uses it to wrap its own data keys.

  • Azure Storage (blobs, files)
  • Azure SQL and Managed Instance (TDE)
  • Managed disks via Disk Encryption Sets
  • Cosmos DB, Azure Data Factory, Azure Monitor and many others

Benefits: control of rotation, ability to revoke access to data by disabling the key, and audit of every use. The cost is operational: if you lose or disable the key, the data becomes unreadable.

Take quiz
What is a main benefit of CMK?
Faster network speed
No need for RBAC
You control rotation and can revoke access to the data
Free storage
Which risk comes with CMK?
Tenants merge
Vault names change
Data becomes public
Losing or disabling the key makes data unreadable

37. How does Azure Storage encryption with a Key Vault key work?

Storage always encrypts data at rest. With CMK, the account's data keys are wrapped by your vault key instead of a Microsoft-managed key.

  1. Give the storage account a managed identity.
  2. Grant that identity Key Vault Crypto Service Encryption User on the vault (or get, wrapKey, unwrapKey policies).
  3. Make sure the vault has soft delete and purge protection.
  4. Point the account at the key URI, ideally versionless.

With a versionless URI, storage checks for new versions (around daily) and starts using them automatically. With a pinned version you must update the setting manually after each rotation.

Take quiz
Which role does the storage account identity need?
Key Vault Crypto Service Encryption User
Storage Account Contributor
Key Vault Reader
Key Vault Secrets User
What does a versionless key URI give you?
No encryption
Public access to blobs
A permanently pinned key
Automatic use of newly rotated key versions

38. How does SQL Transparent Data Encryption with a Key Vault key work?

Azure SQL encrypts database files with a database encryption key (DEK). In BYOK TDE the DEK is protected by a TDE protector, an asymmetric RSA key that lives in your Key Vault.

  • The SQL server needs an identity with get, wrapKey and unwrapKey (or the Crypto Service Encryption User role).
  • The vault must have soft delete and purge protection.
  • The server unwraps the DEK at startup and when it needs it.

If the server cannot reach or use the key, the databases become inaccessible after a short while. That is why you monitor key health and keep backups of the key.

Take quiz
What is the TDE protector in BYOK?
A password in Entra ID
A secret holding the connection string
An asymmetric key in Key Vault that protects the DEK
A firewall rule
What happens if SQL permanently loses access to the TDE protector?
They move to another region
They switch to plain text
The databases become inaccessible
They are copied to Blob

39. What is BYOK and how do you import a key into Key Vault?

BYOK (bring your own key) means you generate the key in your own on-premises HSM and transfer it to Key Vault without it ever appearing in clear text. It needs a Premium vault (or Managed HSM) for HSM-protected keys.

  1. Create a key exchange key (KEK) in the vault with import-only operations.
  2. Download the KEK public key.
  3. Use your HSM vendor's tool to wrap your key into a BYOK package for that KEK.
  4. Upload the package and import.
az keyvault key create --vault-name contoso-kv-01 --name kek --kty RSA-HSM --ops import --protection hsm
az keyvault key import --vault-name contoso-kv-01 --name imported --byok-file package.byok

Software keys can also be imported from a PEM file when no HSM transfer is needed.

Take quiz
Why is a KEK created before importing an HSM key?
To rename the vault
To expire secrets
To protect the key in transit to the vault
To enable the firewall
Which tier is needed for HSM-protected imported keys?
Free tier
Premium or Managed HSM
Standard only
Basic tier

40. What happens when a customer-managed key in Key Vault is disabled or deleted?

Services that depend on it lose the ability to unwrap their data keys, so the data becomes inaccessible. Reads and writes start failing, usually within minutes up to an hour depending on the service and caching.

Action Result Recoverable?
Disable key Service cannot use it Yes, re-enable
Delete key Soft-deleted, service loses access Yes, within retention
Purge key Permanently removed No, unless backup exists

Fix by re-enabling or recovering the key, and the service resumes. Purge protection prevents the unrecoverable case, and a key backup is the last line of defence.

Take quiz
Which action is NOT recoverable without a backup?
Purging the key
Rotating the key
Disabling the key
Soft-deleting the key
What is the effect of disabling a CMK?
The data is deleted
Encryption is removed silently
The key moves to another vault
The service cannot unwrap data keys

41. How do Key Vault backup and restore work?

You back up individual secrets, keys or certificates. The result is an opaque, encrypted blob that only Key Vault can restore.

az keyvault secret backup --vault-name contoso-kv-01 --name DbPassword --file dbpassword.bak
az keyvault secret restore --vault-name contoso-kv-01 --file dbpassword.bak

  • Restore must go to a vault in the same subscription and the same Azure geography.
  • All versions of the object are included.
  • There is no one-click whole-vault backup for standard vaults; script it per object. Managed HSM does support full backups.

Store backup files securely, since they are encrypted for the vault but still sensitive.

Take quiz
What do you back up in a standard Key Vault?
The whole vault in one click
Individual secrets, keys or certificates
Only the resource group
Only the DNS name
Where can a backup be restored?
Same subscription and same Azure geography
Any tenant worldwide
Only the same vault name in another cloud
Any storage account

42. How does Key Vault provide high availability?

Key Vault keeps your data replicated inside the region, across availability zones where the region has them, so a single datacenter failure does not take it down.

It is also replicated to the paired region. If the whole primary region fails, requests are routed to the paired region, where the vault is read-only (get, list, crypto operations work; creating or changing items does not) until the primary recovers.

Design apps to cache secrets at startup so a short outage or read-only period does not stop them. For stricter needs, keep separate vaults per region and replicate secrets yourself.

Take quiz
What is the state of a vault during failover to the paired region?
Read-only
Encrypted with a new key
Fully writable
Deleted
Which app behaviour helps during a regional failover?
Creating the vault at runtime
Caching secrets at startup
Disabling RBAC
Reading the secret on every request

43. What is Key Vault throttling and how do you handle 429 errors?

Each vault has request-rate limits per operation type and region. When an app exceeds them, Key Vault returns HTTP 429 Too Many Requests. Limits are per vault, so many apps sharing one vault can starve each other.

  1. Cache secrets in memory instead of reading per request.
  2. Use exponential backoff and honour the Retry-After header (SDKs already do basic retries).
  3. Reuse clients and avoid chatty listing calls.
  4. Split workloads across vaults, for example per app or environment.
  5. For Key Vault key operations in hot paths, use envelope encryption and unwrap the DEK once.

Track ServiceApiResult and 429 counts in Azure Monitor to see problems early.

Take quiz
Which status code signals Key Vault throttling?
429
200
301
404
What is the most effective first fix for frequent 429s?
Increase the secret size
Disable logging
Delete old versions
Cache secrets in the application

44. How do you troubleshoot a 403 Forbidden error from Key Vault?

A 403 means the caller was identified but not allowed. Work through the usual causes in order:

  1. Firewall: is the caller's IP or subnet allowed, and does DNS resolve to the private endpoint?
  2. Permission model: if RBAC is on, access policies are ignored. Check the role assignment instead.
  3. Right role and scope: Contributor gives no data access. Add Secrets User or similar.
  4. Propagation: new role assignments can take several minutes.
  5. Wrong identity: the app may be running as a different identity than you think.
AzureDiagnostics
| where ResourceProvider == &quot;MICROSOFT.KEYVAULT&quot; and httpStatusCode_d == 403
| project TimeGenerated, OperationName, CallerIPAddress, identity_claim_appid_g, ResultDescription

The audit log shows the exact caller and reason, which usually points straight at the cause.

Take quiz
A vault has RBAC enabled and an old access policy for the app. What happens?
The app gets 404
The access policy is ignored and the app gets 403
The vault switches back to policies
The policy still grants access
Where do you find the exact caller identity for a 403?
The vault's tags
The AuditEvent logs
The DNS zone
The resource lock

45. How do you get a certificate with its private key out of Key Vault?

Read the certificate's addressable secret, not the certificate object. The secret contains the full certificate and private key in PKCS#12 (or PEM, depending on policy).

az keyvault secret download --vault-name contoso-kv-01 --name my-cert --file my-cert.pfx --encoding base64

This only works if the certificate policy marks the key as exportable. A non-exportable certificate keeps the private key inside the vault, which is safer. Use az keyvault certificate download when you only need the public part.

The caller needs permission to read secrets (Secrets User or Certificate-specific roles), so treat that access carefully.

Take quiz
Which Key Vault object holds the certificate's private key for download?
The addressable secret
The access policy
The resource lock
The vault tag
What must the policy say to allow private-key export?
The vault is Premium only
The key is disabled
The certificate is self-signed only
The key is exportable

46. When should you use separate Key Vaults per environment?

Almost always. Microsoft's guidance is one vault per application, per environment, per region.

  • Blast radius: a leaked dev identity cannot touch production secrets.
  • Access control: roles are assigned at vault scope, so separate vaults make least privilege simple.
  • Throttling: limits are per vault, so a noisy dev workload cannot starve prod.
  • Network rules: prod can be private-only while dev is relaxed.

A single shared vault is acceptable for tiny systems, but it mixes access boundaries and quickly becomes hard to audit. Use a naming convention like kv-app-prod-eus to keep things tidy.

Take quiz
What is the recommended vault granularity?
Per application, per environment, per region
One vault per user
One vault per secret
One vault per tenant forever
Why do separate vaults help with throttling?
Limits apply only to keys
Limits are applied per secret value
Limits are applied per vault
Limits are removed in dev

47. What is the difference between Key Vault and Azure App Configuration?

Key Vault App Configuration
Purpose Protect secrets, keys, certificates Store app settings and feature flags
Data type Sensitive Non-sensitive config
Crypto operations Yes (sign, wrap, encrypt) No
Extras HSM, rotation, certificates Labels, feature flags, snapshots

They work together: App Configuration can hold a Key Vault reference. The app reads the setting, sees the reference, and fetches the actual secret from Key Vault using its identity. That keeps ordinary settings and secrets in the right place.

Take quiz
Where do feature flags belong?
A TLS certificate
Azure App Configuration
A Managed HSM
Key Vault keys
What does an App Configuration Key Vault reference store?
The user's password
The vault's private key
The full secret value
A pointer to a secret, not the secret value

48. How do you deploy a Key Vault using Bicep?

Declare a Microsoft.KeyVault/vaults resource and set the security properties explicitly.

resource kv &#x27;Microsoft.KeyVault/vaults@2023-07-01&#x27; = {
  name: &#x27;kv-orders-prod-eus&#x27;
  location: resourceGroup().location
  properties: {
    tenantId: subscription().tenantId
    sku: { family: &#x27;A&#x27;, name: &#x27;standard&#x27; }
    enableRbacAuthorization: true
    enableSoftDelete: true
    softDeleteRetentionInDays: 90
    enablePurgeProtection: true
    publicNetworkAccess: &#x27;Disabled&#x27;
  }
}

Then add Microsoft.Authorization/roleAssignments resources to grant roles to identities. Keep secrets out of the template: set them from a pipeline step or reference existing ones.

Take quiz
Which property switches the vault to Azure RBAC?
softDeleteRbac
rbacMode
enableRbacAuthorization
enableSecretsPolicy
Which resource type grants a managed identity a role on the vault?
Microsoft.Web/sites
Microsoft.Network/routeTables
Microsoft.Storage/blobServices
Microsoft.Authorization/roleAssignments

49. What are the enabledForDeployment, enabledForTemplateDeployment and enabledForDiskEncryption flags?

These vault properties allow specific Azure services to pull material from the vault, independently of normal user access.

Flag Allows
enabledForDeployment Azure VMs to retrieve certificates stored as secrets during VM creation
enabledForTemplateDeployment Azure Resource Manager to read secrets while deploying a template
enabledForDiskEncryption Azure Disk Encryption to get secrets and unwrap keys

Leave them off unless you need that scenario. Each flag widens who can touch the vault, so enable only the ones your workflow uses.

Take quiz
Which flag lets ARM read secrets during template deployment?
enabledForDiskEncryption
enablePurgeProtection
enabledForTemplateDeployment
enabledForDeployment
What is the safe default for these flags?
Always on
Set by the tenant admin automatically
Off unless the scenario needs them
Always on in prod

50. How do you use Key Vault in Azure Pipelines or GitHub Actions?

Azure Pipelines: use the AzureKeyVault@2 task with an Azure service connection. It downloads chosen secrets and exposes them as masked pipeline variables. A variable group linked to Key Vault does the same.

- task: AzureKeyVault@2
  inputs:
    azureSubscription: &#x27;my-service-connection&#x27;
    KeyVaultName: &#x27;contoso-kv-01&#x27;
    SecretsFilter: &#x27;DbPassword,ApiKey&#x27;

GitHub Actions: sign in with azure/login using OIDC federation (no stored password), then call az keyvault secret show and mask the output. Grant the pipeline identity only Secrets User, scoped to the vault it needs.

Take quiz
Which task fetches secrets in Azure Pipelines?
SecretDownload@3
AzureKeyVault@2
KeyVaultCopy@1
BlobFetch@1
What is the preferred way for GitHub Actions to authenticate to Azure?
An anonymous token
OIDC federation with azure/login
A public SSH key
A shared admin password in the repo
«
»

Comments & Discussions