Skip to content
Visual explainer 3h to learn 5 steps

Key Vault, Defender for Cloud and posture on Azure

Use Key Vault and Defender for Cloud to improve posture and triage one security alert.

By Invicly Tech, , in Microsoft Azure Cloud Engineering. About 13 minutes to read.

Topic 24 of 33

In short

Key Vault stores secrets, keys and certificates so apps fetch them at run time with a managed identity instead of keeping them in code. Microsoft Defender for Cloud checks your configuration against a security benchmark, shows a secure score with recommendations, and with paid plans raises alerts about attacks on running workloads. A SIEM such as Microsoft Sentinel sits above both and correlates signals from many sources.

Think of it like this: Key Vault is the safe, posture recommendations are the building inspector's report, and security alerts are the burglar alarm.

Explained simply

Security in Azure has two everyday jobs. The first is keeping secrets safe: passwords, API keys, encryption keys and certificates. The second is noticing weak settings and attacks early. Key Vault handles the first job. Microsoft Defender for Cloud helps with the second.

Key Vault is a locked store for secrets. Instead of putting a database password in your code or a config file, you put it in the vault. Your app signs in with its managed identity, an identity Azure creates and rotates for it, and reads the secret when it starts. No password ever sits in your repository.

Defender for Cloud looks at your resources and compares them with a list of good practices. It gives you a secure score and a list of recommendations, such as turning off public access on a storage account. This is called posture: how exposed you are. The basic posture features are free.

Paid Defender plans add alerts. These watch running workloads for signs of attack, such as unusual sign-ins to a server or someone downloading lots of blobs from a strange address. When an alert fires, someone has to triage it: decide if it is real, how far it spreads and what to do. Bigger teams also use a SIEM, a central system that joins alerts and logs from many places.

Press Play on a diagram to walk through it one step at a time.

LayersWhere each security tool sits
  1. 1
    SIEM (Microsoft Sentinel)

    Collects and correlates signals across clouds, identities and devices

  2. 2
    Workload protection alerts

    Paid Defender plans detect suspicious activity on servers, storage, containers

  3. 3
    Posture management

    Secure score and recommendations against the Microsoft cloud security benchmark

  4. 4
    Secrets and keys

    Key Vault with RBAC, soft delete and managed identity access

  5. 5
    Resources

    Container Apps, storage, databases, virtual machines

SequenceAn app reads a secret with its managed identity
Container app
Microsoft Entra ID
Key Vault
  1. 1Request token for vault.azure.net (managed identity)
    Container app to Microsoft Entra ID: Request token for vault.azure.net (managed identity)
  2. 2Access token for the app identity
    Microsoft Entra ID to Container app: Access token for the app identity
  3. 3GET secret DbPassword with bearer token
    Container app to Key Vault: GET secret DbPassword with bearer token
  4. 4RBAC check passed: secret value, access logged
    Key Vault to Container app: RBAC check passed: secret value, access logged

In depth

Key Vault in practice

A vault holds three kinds of objects. Secrets are any small strings, such as connection strings. Keys are encryption keys that never leave the vault; you ask the vault to encrypt, decrypt or sign. Certificates are TLS certificates with automatic renewal from supported issuers. Use the Azure RBAC permission model: give apps Key Vault Secrets User and give admins Key Vault Secrets Officer, scoped to one vault per app and environment. Soft delete is always on, so deleted objects can be recovered during the retention period (7 to 90 days, 90 by default). Purge protection stops anyone, even an admin, permanently deleting them early. Turn off public network access and use a private endpoint for production vaults. App Service and Container Apps can reference vault secrets directly so the app reads them as ordinary settings.

  • Standard tier: software-protected keys
  • Premium tier: HSM-protected keys
  • One vault per app per environment
  • Every access is logged once diagnostics are on

Secure score and recommendations

Defender for Cloud's free Foundational CSPM (cloud security posture management) assesses resources against the Microsoft cloud security benchmark. Each recommendation names affected resources, a severity, and remediation steps; some offer a one-click fix. Recommendations roll up into security controls, and the secure score is the share of the possible points you have earned. Treat the score as a trend, not a target. Prioritise recommendations on internet-exposed resources, identity (such as MFA for privileged accounts) and data stores holding sensitive data. Use exemptions, with a reason and expiry date, for accepted risks instead of ignoring them. The paid Defender CSPM plan adds attack path analysis, which shows chains of weaknesses an attacker could follow to reach something valuable.

  • Free: secure score, recommendations, benchmark
  • Paid Defender CSPM: attack paths, security explorer
  • Exempt with a reason and an expiry
  • Fix exposure first, polish later

Posture, workload alerts and a SIEM

These three ideas are often mixed up. Posture is about configuration: what could be attacked. Workload protection is about behaviour: Defender plans such as Defender for Servers, Storage, Containers, Key Vault or Databases watch activity and raise security alerts with a severity and MITRE ATT&CK tactic. A SIEM collects alerts and raw logs from Azure, Microsoft Entra ID, endpoints, firewalls and other clouds, then correlates them into incidents. Microsoft Sentinel is Microsoft's SIEM; it is built on a Log Analytics workspace and is moving to the Microsoft Defender portal; after 31 March 2027 it is no longer supported in the Azure portal. A small team with one Azure subscription can start with Defender for Cloud alerts emailed to them and add a SIEM when they have several sources and someone to watch it.

ComparePosture, alerts and SIEM side by side
Posture (CSPM)
  • Reads configuration
  • Output: recommendations, score
  • Free basics
  • Prevents incidents
Workload alerts (CWP)
  • Watches behaviour on resources
  • Output: security alerts
  • Paid per resource plan
  • Detects attacks in progress
SIEM (Sentinel)
  • Collects many sources
  • Output: correlated incidents
  • Billed by data ingested
  • Investigation and automation

Triage one alert, step by step

Treat every alert the same way so nothing is skipped. First, read it: resource, time, severity, tactic and the entities involved, such as an IP address or account. Second, validate: is there a benign explanation, like a planned scan or a new office IP? Check the activity log and sign-in logs. Third, scope: did the same IP or account touch other resources? Fourth, contain if it is real: disable or rotate the credential, block the IP, isolate the resource. Fifth, fix the root cause, often a posture recommendation you ignored. Finally, set the alert status and write down what you found, so the next responder benefits.

FlowAlert triage path
  1. 1
    Read

    Resource, severity, tactic, entities

  2. 2
    Validate

    Benign explanation? Check logs

  3. 3
    Scope

    Same IP or identity elsewhere?

  4. 4
    Contain

    Rotate keys, block, isolate

  5. 5
    Fix and record

    Close the gap, update status and notes

Learn it in 5 short steps

About 35m each. Track them with a timer in your plan.

  1. 1
    Store secrets and keys in Key Vault~35m
  2. 2
    Read secure score recommendations~35m
  3. 3
    Compare posture and workload alerts~35m
  4. 4
    Explain where a SIEM fits~35m
  5. 5
    Triage one alert~35m

Key points

  • Use the Azure RBAC permission model on Key Vault and grant apps the narrow Key Vault Secrets User role.
  • Soft delete is always on for Key Vault; turn on purge protection for production vaults.
  • Foundational CSPM (secure score and recommendations) is free; Defender CSPM and workload protection plans are paid.
  • Posture says what could go wrong; alerts say something may be going wrong now.
  • Triage means confirm, scope, contain, then fix the cause and record what you learned.

Key terms

Tap a card to flip it. 0/6 known

Examples

bash
az keyvault create -g rg-lab -n kv-contoso-lab01 -l westeurope \
  --enable-rbac-authorization true
az keyvault secret set --vault-name kv-contoso-lab01 \
  --name DbPassword --value "<placeholder-not-real>"
# let the app's managed identity read secrets, nothing more
az role assignment create --role "Key Vault Secrets User" \
  --assignee-object-id <app-principal-id> \
  --assignee-principal-type ServicePrincipal \
  --scope $(az keyvault show -n kv-contoso-lab01 --query id -o tsv)

Create a vault, store a placeholder secret and give one identity read-only access.

Moving a connection string out of app settings into Key Vault

The API stores its database password in a plain app setting that every Contributor can read. Step 1: create a vault with RBAC and store the password as a secret. Step 2: turn on the app's system-assigned managed identity. Step 3: give that identity Key Vault Secrets User on the vault. Step 4: replace the setting value with a Key Vault reference (App Service) or a Container Apps secret pointing at the vault URL with the identity. Step 5: restart and check the app connects, then remove the old value and rotate the password, since it was exposed before. Rollback is restoring the previous setting value.

bash
az webapp identity assign -g rg-lab -n app-contoso-api
# App Service Key Vault reference syntax as the setting value
az webapp config appsettings set -g rg-lab -n app-contoso-api --settings \
  DB_PASSWORD="@Microsoft.KeyVault(VaultName=kv-contoso-lab01;SecretName=DbPassword)"

Triaging a storage alert about unusual access

Defender for Storage raises a medium alert: access from an unusual location to a container in stcontosodocs. Step 1: read the entities: an IP from a country where you have no staff and a SAS token used for the requests. Step 2: validate: the activity log shows no planned work, and the StorageBlobLogs table shows 2,000 reads in 10 minutes. Step 3: scope: query other storage logs for the same IP; none found. Step 4: contain: rotate the storage key that signed the SAS, which invalidates it. Step 5: fix: switch the app to user delegation SAS with short expiry and set the alert to resolved with notes. If you do not have the paid plan, practise with Defender for Cloud sample alerts or a synthetic log table.

kusto
StorageBlobLogs
| where TimeGenerated > ago(24h)
| where CallerIpAddress startswith "203.0.113."
| summarize reads = countif(OperationName == "GetBlob"), firstSeen = min(TimeGenerated)
  by AccountName, AuthenticationType

Quick reference

  • App identity gets Key Vault Secrets User; humans who manage secrets get Key Vault Secrets Officer
  • Soft delete is always on in Key Vault; enable purge protection for production
  • Foundational CSPM is free: secure score, recommendations, Microsoft cloud security benchmark
  • Defender workload plans (Servers, Storage, Containers, Key Vault) are paid and raise alerts
  • Posture = what could happen; alert = what may be happening now
  • Microsoft Sentinel is the SIEM: correlates many sources into incidents
  • Triage: read, validate, scope, contain, fix, record

Common mistakes

  • Giving the app Key Vault Administrator or Contributor when it only needs to read secrets.
  • Chasing secure score points instead of fixing the recommendations that protect real exposure first.
  • Closing an alert as a false positive without writing down why, so the next person repeats the work.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1An app only needs to read one database password. Which role is the best fit?

Question 2

2Which statement about Key Vault soft delete is true?

Question 3

3A recommendation says a storage account allows public network access. What is this?

Question 4

4What does a SIEM add that Defender for Cloud alone does not?

Question 5

5During triage you confirm a leaked SAS token. What is the best containment step?

0/5 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Create a Key Vault with the RBAC model, give yourself Secrets Officer, store a placeholder secret and read it back.

  2. Exercise 2medium

    Open Defender for Cloud in a lab subscription, pick the three highest-severity recommendations and write one line each on the risk, the fix and whether you will fix, exempt or accept it.

  3. Exercise 3hard

    Write a triage note for a synthetic alert: 'Suspicious sign-in to vm-api01 from 198.51.100.23 at 02:10'. Include the queries or checks for each triage step and a containment and fix plan.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Is Key Vault expensive?
No for most apps. Standard vaults are billed per 10,000 operations and per certificate renewal, so a small app that reads secrets at start-up costs very little. Premium HSM-backed keys and Managed HSM cost more.
Should I use access policies or Azure RBAC on Key Vault?
Use Azure RBAC. It is Microsoft's recommended model, works with Privileged Identity Management and lets you scope access to a single secret. Access policies are the older model. Current Azure CLI versions create new vaults with RBAC by default; passing --enable-rbac-authorization true makes it explicit.
Do I need to pay for Defender for Cloud?
Not to start. Secure score and recommendations are free. Workload alerts and advanced posture features need paid plans, some of which offer a free trial period; check current pricing before enabling them.
Is Microsoft Sentinel the same as Defender for Cloud?
No. Defender for Cloud protects cloud and hybrid workloads. Sentinel is a SIEM that collects Defender for Cloud alerts plus many other sources and correlates them into incidents.

Go deeper

ShareXLinkedInWhatsApp