3.3 Keys, Secrets, Certificates & Defender for Key Vault
Key Takeaways
- Keys are cryptographic material for encrypt/sign/wrap; secrets are opaque values (passwords, connection strings); certificates bundle keys with X.509 metadata and policy-driven lifecycle.
- Objects are versioned; rotation creates a new version—prefer versionless URIs for automatic pickup while retaining old versions until consumers finish re-wrap or cutover.
- Soft-delete applies to keys, secrets, and certificates; recovery restores them, and purge is a privileged second step blocked by purge protection during retention.
- Defender for Key Vault raises anomalous access alerts; Defender CSPM secret scanning finds exposed credentials in code, configs, and server disks so you can move them into Key Vault.
- Prefer Key Vault over App Service application settings for secrets that need centralized ACL, rotation, auditing, and network isolation.
Keys vs Secrets vs Certificates
| Object | What it is | Common operations | Choose when |
|---|---|---|---|
| Key | Cryptographic key (RSA, EC; HSM variants on Premium/Managed HSM) | create, import, sign, verify, encrypt, decrypt, wrap, unwrap, rotate | CMK for Storage/SQL/disks, app-level crypto, signing |
| Secret | Arbitrary octet sequence (up to 25 KB), exposed as string to clients | set, get, list, delete, recover, backup | Connection strings, API tokens, passwords, shared keys |
| Certificate | Managed X.509 cert with policy, optional auto-renewal via issuer | create, import, renew, get (includes key/secret material as policy allows) | TLS for apps, gateways, mutual TLS |
Design rule: If the value is a password-like credential the app only needs to read, store a secret. If Azure or your app must perform crypto without exporting private key material, use a key. If you need a public cert + private key lifecycle for TLS, use a certificate (which may create related key/secret objects under the covers).
Secrets support optional contentType, nbf/exp, and enabled attributes. Note that get can still retrieve not-yet-valid or expired secrets for recovery/testing—expiration is informational for operational hygiene, not a hard crypto boundary.
Versioning
Every set/create/rotate produces a new version under a stable object name:
- Versioned URI:
https://contoso.vault.azure.net/secrets/DbConn/<version-guid>— pins exact material - Versionless URI:
https://contoso.vault.azure.net/secrets/DbConn— resolves to the current version
Best practice for rotation-friendly apps: Configure consumers with versionless identifiers so they pick up new versions after rotation. Persist versioned identifiers with ciphertext when decrypting historical data (CMK wrap patterns), so unwrap still uses the key version that wrapped the DEK.
You can disable an old version without deleting it, list versions, and recover soft-deleted versions according to retention rules.
Rotation
Cryptographic keys
Key Vault supports rotation policies per key:
- Auto-rotate a given time after create (for example every 18 months)
- Or auto-rotate a given time before expiry (requires expiry on policy and key)
- Near-expiry Event Grid notifications for manual or custom automation
- On-demand Rotate now
Rotation creates new key material as a new version. For Azure CMK integrations, services re-wrap data encryption keys; they do not necessarily re-encrypt all customer data immediately. Keep prior key versions enabled until re-wrap completes. Microsoft guidance commonly cites rotating encryption keys at least about every two years; many policies use shorter intervals.
Permissions: manage rotation with Key Vault Crypto Officer (RBAC) or access-policy rotate / set rotation policy permissions.
Secrets and certificates
Secrets do not use the same built-in crypto rotation policy object; you set a new secret version (manual, pipeline, or Event Grid–driven automation) and update consumers. Certificates use certificate policy for lifetime, issuer, and auto-renewal—prefer Key Vault–managed renewal over shipping PFX files in repos.
Soft-Delete Recovery of Objects
Deleting a key, secret, or certificate with soft-delete enabled:
- Object becomes inaccessible for normal get/crypto use
- Remains listable via deleted items APIs for the retention window
- Recover restores it to active use
- Purge permanently destroys it (blocked while purge protection is active until retention ends)
- Name remains reserved while soft-deleted—you cannot create a conflicting new object with the same name
Exam scenario: An operator accidentally deletes secrets/PaymentApiKey. Correct response is recover the soft-deleted secret (with recover permission), not immediately create a new secret of the same name (may fail while deleted object exists) or rotate every dependent system without checking deleted items first.
If the entire vault was soft-deleted, recover the vault first, then re-create RBAC assignments and event subscriptions that were lost.
Microsoft Defender for Key Vault
Defender for Key Vault is a Defender for Cloud workload protection plan that detects unusual and potentially harmful access to vaults—anomalous callers, suspicious patterns, possible credential misuse.
| Feature | Detail |
|---|---|
| Alerts surface | Vault Security blade, Defender for Cloud alerts, workload protections |
| Alert content | Object ID, UPN or IP when available; accessed secret/key details |
| Response themes | Identify source → constrain network/RBAC → measure which objects were touched → rotate/disable affected secrets and keys |
Response playbook (exam-aligned):
- Do not dismiss an alert only because you recognize the app name—verify with the owner; stolen identity is the threat model.
- If source IP is unexpected: enable/tighten firewall, private endpoints, remove broad access.
- If principal is unauthorized: remove role assignments or access policies; reduce Entra privileges.
- Review diagnostic logs for the caller IP / appId / OID around the alert time.
- Rotate every secret/key/certificate that was accessed; disable old versions; audit downstream apps.
Defender CSPM Secret Scanning
Separately from runtime anomaly detection, Defender Cloud Security Posture Management (CSPM) and related Defender capabilities scan for exposed secrets so you can eliminate them at the source:
| Surface | What scanning finds | Remediation direction |
|---|---|---|
| Code repositories (DevOps security / code scanning) | Tokens, passwords, keys committed to GitHub, Azure DevOps, GitLab | Revoke credential, rewrite history as needed, store in Key Vault, block via pipeline secret scanning |
| Cloud deployments / IaC | Secrets embedded in templates, pipelines, deployment configs | Parameterize with Key Vault references; use managed identity |
| Servers / VMs (with appropriate Defender plans) | Secrets on disk snapshots (connection strings, keys in config files) | Remove plaintext, move to Key Vault, harden residual access |
SC-500 skill language: Scan for secrets by using Defender CSPM and Implement Defender for Key Vault. Treat them as complementary:
- CSPM scanning → find secrets that should never have left Key Vault (or never been created as plaintext)
- Defender for Key Vault → detect abuse of vaults that already hold the crown jewels
Exam Scenarios: Key Vault vs App Settings
| Requirement | Prefer Key Vault | App settings / config alone may suffice |
|---|---|---|
| Central ACL per secret with Entra RBAC | Yes | Weak—app settings inherit broad site contributor access |
| Hardware-backed keys / non-export CMK | Keys in Premium/Managed HSM | Not available in app settings |
| Full AuditEvent logging of each secret get | Yes with diagnostics | Limited platform logs; not a secrets inventory |
| Network isolation of secret store | Firewall + private endpoint | App settings live with the app resource |
| Rotation without redeploying code | Versionless URI + new version | Requires app restart/config change for each value |
| Non-sensitive feature flags | Optional | Simple app settings are fine |
Classic exam stem: “Developers stored SQL passwords in App Service application settings and checked a backup into source control. Leadership wants centralized control, rotation, and detection of odd access.”
Answer path: Move secrets to Key Vault; use managed identity + Secrets User; enable diagnostics; enable Defender for Key Vault; use CSPM/DevOps secret scanning to catch regressions; purge secrets from git and rotate everything exposed.
Another stem: “Storage account uses CMK. Security wants assurance keys cannot be purged by a compromised admin for 90 days.”
Answer: Soft-delete + purge protection on the vault holding the CMK; restrict Purge Operator; monitor with Defender for Key Vault.
Operational Checklist
- Classify data: secret vs key vs certificate
- Enforce RBAC data roles + managed identity
- Versionless URIs for apps; versioned IDs for ciphertext metadata
- Rotation policies for CMKs; automated secret set for credentials
- Soft-delete recover drills; purge protection for encryption vaults
- Diagnostics → Log Analytics/Sentinel
- Defender for Key Vault on; CSPM secret scanning on code and cloud
- Prefer Key Vault over plaintext app settings for credentials
SC-500 Exam Traps (Objects & Defender)
- Certificate ≠ secret: TLS lifecycle needs certificate objects/policies.
- Rotation ≠ delete-and-recreate under a new name when versioning exists.
- Recover before recreating same-named objects.
- Defender for Key Vault ≠ CSPM secret scanning—one is anomalous vault access, the other is finding leaked credentials.
- App settings are not a substitute for Key Vault when the scenario stresses audit, RBAC, rotation, or CMK.
An application must unwrap data encryption keys using a customer-managed key that must not leave an HSM boundary. Which Key Vault object and tier pairing is appropriate?
A key rotation policy creates a new key version for a Storage CMK. What should administrators ensure during the transition?
Defender for Key Vault alerts on anomalous SecretGet calls from an unfamiliar IP. After confirming the access was unauthorized, what is the best immediate data-protection action for the secrets that were read?
Which capability is primarily provided by Defender CSPM secret scanning rather than by Defender for Key Vault?