Skip to main content

Improving Azure Secure Score with Defender

Read Defender for Cloud's Secure Score, find recommendations with the CLI, fix a public blob access finding, and see how the score responds.

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.

flowchart TD A[(Deployed resources)] --> B[Assessments
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:

  1. Secure Score is the single percentage for the subscription.
  2. Security controls are groups of related recommendations, such as "Restrict unauthorized network access", and each carries a maximum number of points.
  3. Recommendations are the individual, actionable findings, such as disallowing public access on one storage account.
Remember

The 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.

Bash
az provider register --namespace Microsoft.Security --wait
az security pricing list --query "[].[name, pricingTier]" --output table
How to Check Your Baseline Secure Score
Bash
az security secure-scores list \
--query "[].[displayName, score.current, score.max, score.percentage]" \
--output table

Note 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.

Bash
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 true
Security

--allow-blob-public-access true is 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.

Bash
az security assessment list \
--query "[?status.code=='Unhealthy'].[displayName, resourceDetails.id]" \
--output table
# Only the public access finding
az security assessment list \
--query "[?status.code=='Unhealthy' && contains(displayName, 'public access')].[displayName, resourceDetails.id]" \
--output table
How 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.

Bash
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 table
How to Fix the Misconfiguration

Disable anonymous blob access, then confirm the setting changed.

Bash
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: false
How 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.

Bash
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 table
How to Clean Up
Bash
az group delete --name $RG --yes --no-wait

Production Best Practices & Common Pitfalls

Common Mistake

Chasing 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.

Tip

Review recommendations regularly, not just at setup. New resources appear and configurations drift, so a recommendation that did not apply last month may apply today.

Security

Before 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 Deny effect 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

Explore More in Azure Monitoring, Identity, and Production Readiness

All 6 Topics

Frequently Asked Questions

Is Improving Azure Secure Score with Defender free to learn on DevOps Network?

Yes - this topic, like everything on DevOps Network, is 100% free with no paywall or sign-up gate.

What does the Improving Azure Secure Score with Defender topic cover?

Read Defender for Cloud's Secure Score, find recommendations with the CLI, fix a public blob access finding, and see how the score responds.

Found a mistake, an outdated step or a broken link?