Task 01: Enable Defender for Cloud
DOCUMENT CATEGORY: Runbook
SCOPE: The free level of Microsoft Defender for Cloud
PURPOSE: Show the Azure Local security settings and recommendations in the Azure portal
MASTER REFERENCE: Microsoft Learn - Manage system security with Microsoft Defender for Cloud
Status: Active
This task turns on the two free items of Microsoft Defender for Cloud that Azure Local uses. Nothing in this task costs money.
What this task turns on
| Item | Cost | What it gives you |
|---|---|---|
| Foundational CSPM | Free | The basic Defender for Cloud plan. It gives security recommendations for Azure Local and your other Azure and Arc resources. |
| Microsoft cloud security benchmark | Free | A policy initiative assigned to the subscription. The Azure Local security settings show in the Azure portal only when it is applied. |
The guide and the toolkit turn on no paid Defender plan: no Defender for Servers, Storage, Key Vault, Resource Manager, DNS or Defender CSPM, and no agent auto-provisioning. Microsoft Sentinel is not set up either.
Microsoft's page lists Defender for Servers as a further step. It adds security alerts for individual machines and Azure Local VMs, and it is billed per server. Whether to buy it is your decision, made outside this guide. If you want it, follow Enable the Defender for Servers plan.
Prerequisites
- The Azure Local instance is deployed, registered and connected to Azure.
- Owner or Contributor on the subscription of the instance, to turn on Foundational CSPM.
- Resource Policy Contributor (or Owner) on the subscription, to assign the initiative.
Variables from infrastructure.yml
| Key | What it is | Example |
|---|---|---|
azure.subscription_id | Subscription of the instance | 00000000-0000-0000-0000-000000000000 |
security.defender_for_cloud.enabled | false skips this task | true |
security.defender_for_cloud.apply_cloud_security_benchmark | false leaves the initiative unassigned | true |
security.defender_for_cloud.security_contact_email | Address for Defender for Cloud notifications. Set only when the subscription has no security contact; an existing one is never replaced. Free | security@improbability.cloud |
security.defender_for_cloud.alert_notifications | Defender for Cloud sends security_contact_email the security alerts (default true). Read by the Terraform security module; since schema 5.6.28 | true |
security.defender_for_cloud.alerts_to_admins | Defender for Cloud sends the security alerts to the subscription owners too (default true). Read by the Terraform security module; since schema 5.6.28 | true |
The older registry entries security.defender.def_alert_notifications and def_alerts_to_admins are deprecated: use the two keys above.
Procedure
- Azure Portal
- Toolkit Script
- Azure CLI
Step 1: Turn on Foundational CSPM
- In the Azure portal, search for and select Microsoft Defender for Cloud.
- Follow Enable Defender for Cloud on your Azure subscription. Turn on no plan other than Foundational CSPM; any offer to upgrade starts paid plans.
- Under Management, select Environment settings, select the subscription and check that Foundational CSPM is the only plan that is on.
Step 2: Apply the Microsoft cloud security benchmark
- Under Management, select Environment settings and select the subscription.
- Select Security policies.
- For Microsoft cloud security benchmark, set Status to On.
- Wait at least one hour for the first evaluation.
PowerShell
When to use: Run the task with the script below, from the place its help names (a management workstation, or the node itself).
Script
| Script | What it does |
|---|---|
scripts/deploy/05-operational-foundations/phase-04-security-governance/task-01-enable-defender-for-cloud/powershell/Enable-DefenderForCloud.ps1 | Turns on the free level of Microsoft Defender for Cloud that Azure Local needs. Supports -WhatIf. |
Requires: PowerShell 7; modules Az.Accounts, Az.Resources.
Run
./Enable-DefenderForCloud.ps1 -InfrastructureFile ./infrastructure.yml -WhatIf
./Enable-DefenderForCloud.ps1 -InfrastructureFile ./infrastructure.yml
Azure CLI
When to use: Run the task from a host that has the Azure CLI and not the Az PowerShell modules. The script is PowerShell 7 that calls
az; it readsinfrastructure.ymland carries no values of its own.
Script
| Script | What it does |
|---|---|
scripts/deploy/05-operational-foundations/phase-04-security-governance/task-01-enable-defender-for-cloud/azurecli/Enable-DefenderForCloud.azcli.ps1 | Turns on the free level of Microsoft Defender for Cloud that Azure Local needs, with the Azure CLI, from infrastructure.yml. Supports -WhatIf. |
Requires: PowerShell 7 and the Azure CLI, signed in with az login --tenant <azure.tenant_id>.
Free tier only: it registers the Microsoft.Security provider, assigns the Microsoft cloud security benchmark initiative to the subscription, and, when security.defender_for_cloud.security_contact_email holds an address and the subscription has no contact yet, sets that security contact (an Azure CLI preview command). It never turns on a paid plan, changes a pricing tier or turns on agent auto-provisioning, and it never replaces an assignment it did not create (exit code 2).
Run
./Enable-DefenderForCloud.azcli.ps1 -InfrastructureFile ./infrastructure.yml -WhatIf
./Enable-DefenderForCloud.azcli.ps1 -InfrastructureFile ./infrastructure.yml
Validation
$subscriptionId = "<your-subscription-id>"
$benchmarkId = "/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"
# Foundational CSPM: the provider is registered
(Get-AzResourceProvider -ProviderNamespace Microsoft.Security | Select-Object -First 1).RegistrationState
# The initiative is assigned
Get-AzPolicyAssignment -Scope "/subscriptions/$subscriptionId" | Where-Object {
$id = if ($_.PSObject.Properties['PolicyDefinitionId']) { $_.PolicyDefinitionId } else { $_.Properties.PolicyDefinitionId }
$id -eq $benchmarkId
} | Select-Object Name
Expected Output
Registered
Name
----
SecurityCenterBuiltIn
After the first evaluation, open the Azure Local instance in the portal and select Security (preview) > Microsoft Defender for Cloud. The recommendations for the instance are listed there.
Recommendations you can ignore for Azure Local
Microsoft lists recommendations that do not apply to the storage account, the Key Vault and the machines of an Azure Local instance, for example private link, shared key access and a vulnerability assessment solution on the machines. See Security recommendation exclusions before you act on a recommendation.
Troubleshooting
| Issue | Cause | Resolution |
|---|---|---|
| The security settings do not show on the instance | The Microsoft cloud security benchmark is not assigned | Do Step 2, then wait at least one hour |
| Defender for Cloud shows no data for the subscription | Microsoft.Security is not registered | Register-AzResourceProvider -ProviderNamespace Microsoft.Security, then wait a few minutes |
| No recommendations after the assignment | The first evaluation is not complete | Wait up to 24 hours |
The toolkit script stops on SecurityCenterBuiltIn | An assignment of that name points at another definition | Remove or rename that assignment, or set apply_cloud_security_benchmark to false and assign the initiative yourself |
Next Steps
Proceed to Task 02: Apply Azure Policy Initiatives.
Navigation
| Previous | Up | Next |
|---|---|---|
| ← Phase 02: Monitoring & Observability | Phase 04: Security & Governance | Task 02: Azure Policy → |
Version Control
| Version | Date | Author | Changes |
|---|---|---|---|
| 2.0.0 | 2026-11-12 | Azure Local Cloud | The task turns on only the free level Azure Local needs; paid plans removed |
| 1.0.0 | 2025-03-25 | Azure Local Cloud | Initial release |