Overview and What You Will Learn
Microsoft Defender for Cloud scans your deployed Azure resources against security best practices and turns the result into a Secure Score plus a prioritized list of recommendations. In this lab, you will confirm Defender for Cloud is active, read your baseline score, create a storage account with a deliberate misconfiguration, find the recommendation it triggers, fix it, and watch the score respond.
Why This Matters in Production
Secure Score replaces the assumption that "nothing has gone wrong yet" with a concrete list of what to fix first. A platform team at a company like Zerodha might believe its subscription is reasonably safe without ever checking whether basic protections, such as blocking public blob access or encrypting disks, are enabled on every resource. Defender for Cloud makes those gaps visible and ranks them by their effect on your real security posture.
Core Principles
Defender for Cloud runs assessments against each resource and groups the unhealthy ones into recommendations. Recommendations roll up into security controls, and the points from each control add up to your Secure Score, shown as a percentage of the maximum available.
against benchmark] B --> C[Unhealthy findings] C --> D[Recommendations
grouped by control] D --> E([Secure Score]) classDef res fill:#475569,color:#FFFFFF classDef step fill:#326CE5,color:#FFFFFF classDef bad fill:#F97316,color:#FFFFFF classDef out fill:#10B981,color:#FFFFFF class A res class B,D step class C bad class E out
You read the results at three levels, from broad to specific:
- Secure Score is the single percentage for the subscription.
- Security controls are groups of related recommendations, such as "Restrict unauthorized network access", and each carries a maximum number of points.
- Recommendations are the individual, actionable findings, such as disallowing public access on one storage account.
RememberThe foundational Cloud Security Posture Management (CSPM) plan, which provides Secure Score and basic recommendations, is free. Defender CSPM and the workload plans, such as Defender for Servers or Storage, are paid and add deeper analysis and active threat protection.
Detailed Step-by-Step Practical Lab
How to Confirm Defender for Cloud Is Enabled
Register the resource provider, then list the Defender plans on your subscription. The CloudPosture plan on the Free tier is the foundational plan that produces Secure Score. You need at least Security Reader to view results and Security Admin or Owner to change settings.
az provider register --namespace Microsoft.Security --wait az security pricing list --query "[].[name, pricingTier]" --output tableHow to Check Your Baseline Secure Score
az security secure-scores list \ --query "[].[displayName, score.current, score.max, score.percentage]" \ --output tableNote the current points and the percentage, because you will compare against them at the end. A brand-new subscription may show no score until the first assessment finishes.
How to Create a Deliberate Misconfiguration
Allowing public access to blobs is a common real-world finding. Storage account names are globally unique, so change the suffix if yours is taken.
export RG="rg-defender-lab-mumbai"export SA="stdefenderlabrahul2026" az group create --name $RG --location centralindia az storage account create \ --name $SA \ --resource-group $RG \ --location centralindia \ --sku Standard_LRS \ --allow-blob-public-access trueSecurity
--allow-blob-public-access trueis a deliberate weakness for this lab only. It makes the account capable of serving anonymous blob reads, so do not upload real data to it.
How to List Unhealthy Recommendations with the CLI
Assessments are evaluated on Defender's schedule, so the new finding can take from several minutes to a few hours to appear. If nothing matches yet, check again later or look under Recommendations in the Portal.
az security assessment list \ --query "[?status.code=='Unhealthy'].[displayName, resourceDetails.id]" \ --output table # Only the public access findingaz security assessment list \ --query "[?status.code=='Unhealthy' && contains(displayName, 'public access')].[displayName, resourceDetails.id]" \ --output tableHow to Prioritize Recommendations by Severity
Fix high-severity findings first, even when a low-severity fix is quicker. Severity lives in the assessment metadata, which Azure Resource Graph exposes in one query.
az extension add --name resource-graph az graph query -q "securityresources | where type == 'microsoft.security/assessments' | extend status = tostring(properties.status.code), severity = tostring(properties.metadata.severity), title = tostring(properties.displayName) | where status == 'Unhealthy' | project title, severity" \ --query "data[]" --output tableHow to Fix the Misconfiguration
Disable anonymous blob access, then confirm the setting changed.
az storage account update \ --name $SA \ --resource-group $RG \ --allow-blob-public-access false az storage account show \ --name $SA \ --resource-group $RG \ --query "allowBlobPublicAccess" --output tsv# Expected: falseHow to Re-Check the Score
Recommendation status updates when Defender re-evaluates the resource, and the Secure Score itself can lag by up to a day. Re-run the checks after some time has passed.
az security assessment list \ --query "[?contains(displayName, 'public access')].[displayName, status.code]" \ --output table az security secure-scores list \ --query "[].[displayName, score.current, score.max, score.percentage]" \ --output tableHow to Clean Up
az group delete --name $RG --yes --no-waitProduction Best Practices & Common Pitfalls
Common MistakeChasing Secure Score as a number to maximize instead of reading the recommendations behind it. A slightly lower score with every high-severity finding resolved is a stronger position than a higher score hiding one serious unresolved issue among many minor ones.
TipReview recommendations regularly, not just at setup. New resources appear and configurations drift, so a recommendation that did not apply last month may apply today.
SecurityBefore disabling public blob access in a real environment, confirm nothing depends on anonymous reads, such as a static website or public downloads. Turning it off breaks those consumers immediately.
- Exempt, do not ignore, recommendations that do not apply. Defender for Cloud lets you create an exemption with a documented reason, so the decision is recorded and the item stops lowering the score.
- Prevent the finding instead of repairing it. An Azure Policy with the
Denyeffect can block creation of storage accounts that allow public blob access in the first place. - Know which plan you are on. The free foundational plan gives posture visibility only, while the paid workload plans add real-time threat detection.
- Use Quick fix where it is offered. Many recommendations in the Portal include a Fix button that applies the change for you, which is faster and more consistent than editing resources by hand.
Quick Reference & Troubleshooting Commands
| Command | Description |
|---|---|
az security secure-scores list |
Check the current Secure Score |
az security pricing list |
Show which Defender plans are on |
az security assessment list |
List assessments and their health status |
az graph query -q "securityresources ..." |
Query assessments with severity |
az storage account update --allow-blob-public-access false |
Fix the public blob access finding |
az provider register --namespace Microsoft.Security |
Fix missing Defender data from an unregistered provider |