03 / 13Governance and logging
Management groups and Azure Policy security hardening
Secure the management group hierarchy and tenant root, then enforce a baseline with Azure Policy: deny guardrails, MCSB and CIS initiatives, safe rollout and audits.
- Service
- Azure Policy
- Category
- Governance and logging
- Baseline
- 12 controls
- Updated
On this page
Management groups and Azure Policy are how one hardening standard reaches every subscription in a tenant. Management groups are scopes above subscriptions where role and policy assignments are set once and inherited; Azure Policy decides what may be deployed no matter who deploys it. Left at defaults, the hierarchy works against you: any user can create management groups, new subscriptions land directly under the Tenant Root Group, Global Administrators can elevate to User Access Administrator over everything, and policies only audit. The result is a tenant where Defender for Cloud recommendations come back as fast as they are fixed, and where an attacker with Owner deletes the policy assignment in the way. This page maps to the Microsoft cloud security benchmark controls GS-2, PA-1, PV-1, PV-2 and AM-2, and to the CIS Microsoft Azure Foundations Benchmark through its built-in initiative and external audit tools.
Baseline controls
CIS numbers refer to the CIS Microsoft Azure Foundations Benchmark v7.0.0.
| Control | Why | How to check | ID |
|---|---|---|---|
| Management group hierarchy | Inheritance only helps if scopes match how you govern | az account management-group show --name <tenant-id> --expand --recurse | MCSB GS-2 |
| Default group and creation rights | New subscriptions otherwise skip your guardrails | az rest GET on managementGroups/<tenant-id>/settings/default | CIS 5.8, 5.9 |
| Minimal access at the tenant root | Anything assigned at / or the root group covers every subscription | az role assignment list --scope "/" | MCSB PA-1 |
| Elevate access is rare and watched | A Global Administrator can grant themselves every subscription | Entra audit log, service Azure RBAC (Elevated Access) | MCSB PA-1 / CIS 5.3.3 |
| MCSB and CIS initiatives assigned | You cannot fix what you do not measure | Defender for Cloud > Regulatory compliance | MCSB PV-2 / CIS 8.1.13 |
| Deny guardrails starter set | Stops the most common misconfigurations from coming back | az policy assignment list --disable-scope-strict-match | MCSB PV-1 |
| Allowed locations and resource types | Keeps data and unreviewed services out | Policy compliance for Allowed locations | MCSB AM-2 |
| Safe rollout with DoNotEnforce | Enforcing blind breaks deployments | enforcementMode on each assignment | - |
| Exemptions that expire | Permanent exceptions become permanent holes | az policy exemption list | - |
| Remediation of existing resources | Deny only protects new and updated resources | az policy remediation list | MCSB PV-2 |
| Guardrails protected from tampering | Owner can delete an assignment and deploy anything | Alerts on policyAssignments/delete | CIS 6.1.2.1, 6.1.2.2 |
| Independent CIS audit | Policy cannot see Entra ID settings | prowler azure --compliance <cis framework> | MCSB PV-2 |
Build a management group hierarchy
Every tenant has one Tenant Root Group whose ID is the tenant ID. Under it you can build a tree up to six levels deep (not counting the root and the subscription level). Design it for policy and access, not for the org chart. A layout derived from the Azure landing zone reference works for most organizations:
Tenant Root Group
└── contoso
├── platform
│ ├── identity
│ ├── management
│ └── connectivity
├── landingzones
│ ├── corp
│ └── online
├── sandbox
└── decommissioned
Organization-wide assignments go on the intermediate contoso group, which keeps the root clean and leaves room for a second top-level group to test changes.
az account management-group create --name contoso --display-name "Contoso"
az account management-group create --name landingzones --parent contoso
az account management-group create --name corp --parent landingzones
az account management-group subscription add --name corp --subscription <sub-id>
Verify the tree and spot subscriptions still sitting directly under the root:
az account management-group show --name <tenant-id> --expand --recurse \
--query "children[?type=='/subscriptions'].{sub:displayName, id:name}" -o table
resourcecontainers
| where type =~ "microsoft.resources/subscriptions"
| extend parent = tostring(properties.managementGroupAncestorsChain[0].name)
| project subscription = name, subscriptionId, parent
| order by parent asc
Restrict who can move subscriptions between groups: moving one into sandbox takes it out of reach of your deny policies.
Default management group and group creation
Two hierarchy settings on the root management group matter for security:
- Default management group: by default a new subscription joins the Tenant Root Group, outside any guardrail you assigned lower down. Point the default at a management group with your baseline policies (for example
sandboxor a dedicatedquarantinegroup) so new subscriptions arrive governed. - Require authorization for group creation: by default any user in the tenant can create management groups. With this setting on, creating a child group needs
Microsoft.Management/managementGroups/writeon the root management group.
Portal: Management groups > Tenant Root Group > Settings, then Change default management group and the Require write permissions for creating new management groups toggle.
az rest --method PUT \
--url "https://management.azure.com/providers/Microsoft.Management/managementGroups/<tenant-id>/settings/default?api-version=2020-05-01" \
--body '{
"properties": {
"defaultManagementGroup": "/providers/Microsoft.Management/managementGroups/sandbox",
"requireAuthorizationForGroupCreation": true
}
}'
# Verify
az rest --method GET \
--url "https://management.azure.com/providers/Microsoft.Management/managementGroups/<tenant-id>/settings/default?api-version=2020-05-01"
Changing these settings needs Microsoft.Management/managementgroups/settings/write on the root group, which the built-in Hierarchy Settings Administrator role grants without any other access. Give that role to the platform team instead of root-level Owner.
Lock down the Tenant Root Group
Role assignments at the root management group, and at the root scope / above it, apply to every subscription in the tenant, including ones created next year. List them:
# Root scope "/" (where elevate access lands)
az role assignment list --scope "/" -o table
# Tenant Root Group
az role assignment list \
--scope /providers/Microsoft.Management/managementGroups/<tenant-id> \
--query "[].{who:principalName, type:principalType, role:roleDefinitionName, scope:scope}" -o table
Listing assignments at / needs read at that scope, which in practice means elevated access or a principal you granted Reader there on purpose.
Rules for the root:
- No user holds Owner, Contributor or User Access Administrator at the root permanently; platform admins get them as PIM eligible assignments at the intermediate group (see Azure RBAC).
- Read-only security tools may hold Reader or Security Reader at the root, each documented with an owner.
- A service principal with write at the root is the most valuable credential in the tenant: if unavoidable, use a managed identity or federated credential, never a client secret.
Control elevate access
A Global Administrator can set Microsoft Entra ID > Manage > Properties > Access management for Azure resources to Yes and receive User Access Administrator at root scope /. From there they can grant themselves Owner on any subscription. This is a documented recovery path, and also a well-known escalation from a compromised Global Administrator to all of Azure.
The same through the API:
az rest --method post --url "/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01"
Treat it as an emergency procedure:
-
Elevate only when a subscription has lost all its owners or for a one-off root-level change.
-
Remove the assignment as soon as the change is done. Deactivating the Global Administrator role in PIM does not remove it; set the toggle back to No or delete the assignment:
bashaz role assignment list --role "User Access Administrator" --scope "/" -o table az role assignment delete --assignee <upn-or-object-id> \ --role "User Access Administrator" --scope "/" -
Check for leftovers. The Properties page shows a banner with the number of users who still have elevated access and a Manage elevated access users link to remove them.
Elevation events appear in the Microsoft Entra audit log (service Azure RBAC (Elevated Access), in preview) and in the directory activity log (operation Microsoft.Authorization/elevateAccess/action). Alerting on them is covered under Logging and detection.
Assign MCSB and CIS initiatives
Effects, from gentle to strict
Every policy definition has an if condition and a then effect:
| Effect | What it does | Use it for |
|---|---|---|
Audit | Marks matching resources non-compliant | Measuring before enforcing |
AuditIfNotExists | Non-compliant if a related resource is missing | Diagnostic settings, extensions |
Deny | Rejects the create or update request | Hard guardrails |
DenyAction | Blocks a specific action, currently delete | Protecting critical resources |
Modify | Adds, changes or removes properties or tags on create, update and remediation | Fixing settings without blocking |
DeployIfNotExists | Deploys a template when a related resource is missing | Diagnostic settings, agents, private DNS |
Disabled | Does nothing | Switching a policy off inside an initiative |
Deny does not change existing resources. It reports them as non-compliant, and the next update to such a resource that does not fix the setting is rejected, which surprises teams. Plan remediation before you enforce.
The two baseline initiatives
- Microsoft cloud security benchmark: Defender for Cloud assigns it by default to every subscription it covers, and most Defender for Cloud recommendations come from it. A newer Microsoft cloud security benchmark v2 initiative is also available as a built-in; check which one your Defender for Cloud environment uses before assigning a second copy.
- CIS Microsoft Azure Foundations Benchmark: Azure Policy ships built-in regulatory compliance initiatives for CIS versions up to CIS Microsoft Azure Foundations Benchmark v2.0.0. Defender for Cloud offers newer versions as standards (CIS Azure Foundations v2.1.0 and (CIS) Microsoft Azure Foundations Benchmark v3.0 at the time of writing).
Assign them at your top management group. They audit; they do not block.
az policy set-definition list \
--query "[?contains(displayName, 'CIS Microsoft Azure Foundations')].{name:name, displayName:displayName}" \
-o table
az policy assignment create \
--name cis-azure-200 \
--display-name "CIS Microsoft Azure Foundations Benchmark v2.0.0" \
--policy-set-definition <initiative-name-guid> \
--scope /providers/Microsoft.Management/managementGroups/contoso
In Defender for Cloud, add a standard under Microsoft Defender for Cloud > Environment settings > (management group or subscription) > Security policies > Standards. Most standards other than MCSB need a paid Defender plan (Defender CSPM) on the scope. Results show in Defender for Cloud > Regulatory compliance, grouped by benchmark control, with a downloadable report.
Several CIS controls cannot be checked by Azure Policy because they live in Microsoft Entra ID (MFA, guest settings, app registration and consent, security defaults). They appear as manual or unavailable controls. Cover them with the external audit and the Entra ID page.
Deny guardrails starter set
Audits tell you what is wrong. These built-in policies, assigned with Deny at the landing zones management group, stop the most common mistakes from coming back. Names are exact built-in display names; most take an effect parameter.
| Built-in policy | Why | Detail |
|---|---|---|
| Storage accounts should prevent shared key access | Forces Entra authentication | Storage |
| Storage account public access should be disallowed | Blocks anonymous blob access | Storage |
| Storage accounts should disable public network access | Private endpoints only | Storage |
| Secure transfer to storage accounts should be enabled | HTTPS only | Storage |
| Key vaults should have deletion protection enabled | Purge protection everywhere | Key Vault |
| Azure Key Vault should use RBAC permission model | No legacy access policies | Key Vault |
| Network interfaces should not have public IPs | No direct internet exposure for VMs | Virtual Machines |
| Subnets should be private | No default outbound access | Virtual Network |
| Management ports should be closed on your virtual machines | Audits internet-exposed remote management ports; effects are AuditIfNotExists or Disabled only, so it reports but cannot deny | Virtual Network |
Group them in a custom initiative so they are assigned, exempted and versioned together:
az policy set-definition create \
--name security-guardrails \
--display-name "Security guardrails (deny)" \
--definitions @guardrails.json \
--params @guardrails-params.json \
--management-group contoso
Writing a custom definition
When no built-in definition fits, write one. This denies storage accounts whose minimum TLS version is below 1.2:
{
"mode": "Indexed",
"parameters": {
"effect": {
"type": "String",
"allowedValues": ["Audit", "Deny", "Disabled"],
"defaultValue": "Deny"
}
},
"policyRule": {
"if": {
"allOf": [
{ "field": "type", "equals": "Microsoft.Storage/storageAccounts" },
{
"anyOf": [
{ "field": "Microsoft.Storage/storageAccounts/minimumTlsVersion", "exists": "false" },
{ "field": "Microsoft.Storage/storageAccounts/minimumTlsVersion", "notEquals": "TLS1_2" }
]
}
]
},
"then": { "effect": "[parameters('effect')]" }
}
}
az policy definition create \
--name deny-storage-tls-below-12 \
--display-name "Storage accounts must require TLS 1.2" \
--rules @rule.json --params @params.json --mode Indexed \
--management-group contoso
Find the property aliases you need with:
az provider show --namespace Microsoft.Storage --expand "resourceTypes/aliases" \
--query "resourceTypes[?resourceType=='storageAccounts'].aliases[].name" -o tsv
Keep definitions in Git and deploy them from a pipeline.
Allowed locations and resource types
Two more guardrails belong on every landing zone:
- Allowed locations (and Allowed locations for resource groups): keeps data in approved regions, which also limits where an attacker can quietly deploy compute.
- Not allowed resource types or Allowed resource types: keeps classic resources, unreviewed preview services and expensive SKUs out of production. An allowlist is stricter and better for regulated landing zones; a denylist is easier to live with in sandboxes.
az policy assignment create \
--name allowed-locations \
--policy "e56962a6-4747-49cd-b67b-bf8b01975c4c" \
--params '{"listOfAllowedLocations":{"value":["westeurope","northeurope"]}}' \
--scope /providers/Microsoft.Management/managementGroups/contoso
The GUID is the built-in Allowed locations definition. Global resources (Front Door, Traffic Manager, some DNS resources) use the location global; add it to the list or they fail.
Roll out with DoNotEnforce
-
Assign the audit initiatives and wait for the first compliance scan (it starts shortly after assignment, then runs about every 24 hours). Trigger one on demand with
az policy state trigger-scan --resource-group <rg>or for the whole subscription without arguments. -
Assign deny policies with
--enforcement-mode DoNotEnforce. The assignment evaluates and reports but does not block. This is safer than setting the effect toAudittemporarily, because the configuration you test is the one you will enforce.bashaz policy assignment create \ --name deny-storage-public \ --policy <definition-id> \ --params '{"effect":{"value":"Deny"}}' \ --enforcement-mode DoNotEnforce \ --scope /providers/Microsoft.Management/managementGroups/landingzones -
Fix or exempt what it reports:
bashaz policy state list \ --management-group landingzones \ --filter "policyAssignmentName eq 'deny-storage-public' and complianceState eq 'NonCompliant'" \ --query "[].resourceId" -o tsv -
Add a non-compliance message so blocked users know what to do:
bashaz policy assignment non-compliance-message create \ --name deny-storage-public \ --scope /providers/Microsoft.Management/managementGroups/landingzones \ --message "Public network access must be disabled. Use a private endpoint, see the platform wiki." -
Switch to enforcement once the list is empty or exempted, and tell teams first:
bashaz policy assignment update --name deny-storage-public \ --scope /providers/Microsoft.Management/managementGroups/landingzones \ --enforcement-mode Default
For large estates, roll out by ring with resourceSelectors on the assignment (for example one region first), then widen it.
Exemptions that expire
Real environments need exceptions. Record them as policy exemptions, not by adding notScopes to the assignment: exemptions carry a category, a justification and an expiry date, and they show in compliance reports.
az policy exemption create \
--name legacy-sftp-public \
--policy-assignment /providers/Microsoft.Management/managementGroups/landingzones/providers/Microsoft.Authorization/policyAssignments/deny-storage-public \
--exemption-category Waiver \
--expires-on 2027-03-31T00:00:00Z \
--description "Partner SFTP until migration to private link, ticket SEC-142" \
--scope /subscriptions/<sub-id>/resourceGroups/rg-sftp
Use Mitigated when a compensating control exists and Waiver when the risk is accepted. Review the list monthly:
az policy exemption list --disable-scope-strict-match \
--query "[].{name:name, category:exemptionCategory, expires:expiresOn, scope:id}" -o table
Writing an exemption needs Microsoft.Authorization/policyExemptions/write on the scope and Microsoft.Authorization/policyAssignments/exempt/action on the assignment. Keep the second one with the security team so application owners cannot exempt themselves.
Remediate with Modify and DeployIfNotExists
Modify and DeployIfNotExists assignments use a managed identity with the roles listed in the definition's roleDefinitionIds. Create the assignment with an identity, grant it those roles, then launch remediation for existing resources:
az policy assignment create \
--name diag-to-law \
--policy-set-definition <diagnostic-initiative-id> \
--scope /providers/Microsoft.Management/managementGroups/contoso \
--mi-system-assigned --location westeurope \
--params '{"logAnalytics":{"value":"<workspace-resource-id>"}}'
principal=$(az policy assignment show --name diag-to-law \
--scope /providers/Microsoft.Management/managementGroups/contoso \
--query identity.principalId -o tsv)
az role assignment create \
--assignee-object-id "$principal" --assignee-principal-type ServicePrincipal \
--role "Monitoring Contributor" \
--scope /providers/Microsoft.Management/managementGroups/contoso
az policy remediation create \
--name diag-to-law-remediation \
--management-group contoso \
--policy-assignment /providers/Microsoft.Management/managementGroups/contoso/providers/Microsoft.Authorization/policyAssignments/diag-to-law
The remediation identity is itself privileged: give it only the roles the definition lists. Diagnostic settings initiatives are covered on the Azure Monitor page.
Protect the guardrails
An attacker with Owner on a management group can delete a policy assignment, deploy whatever they want, and put the assignment back. Mitigations:
- Assign guardrails at management groups where application teams have no write on
Microsoft.Authorization/policyAssignments/*orpolicyExemptions/*. Subscription Owner does not give write on the parent management group. - Manage policy as code so any manual change is visible as drift in the next pipeline run.
- Protect critical resources with
DenyAction(Do not allow deletion of resource types) and locks, described on the Azure RBAC page. - Alert on policy changes (next section). The built-in An activity log alert should exist for specific Policy operations checks that subscriptions have such alerts.
Audit against CIS with Defender for Cloud and Prowler
An independent scan shows how an auditor, or an attacker running the same open source tools, sees your tenant, including Entra ID settings that policy cannot check.
Defender for Cloud regulatory compliance
With the CIS standard added (see above), open Defender for Cloud > Regulatory compliance, select the CIS standard and download the report (PDF or CSV) as audit evidence. Controls shown as unavailable cannot be assessed automatically; those need the external scan or manual evidence. More on plans and secure score is on the Defender for Cloud page.
Read-only audit identity
Use a dedicated identity, not your admin account: a user-assigned managed identity on an audit container, or an app with a certificate or federated credential.
az role assignment create \
--assignee-object-id <audit-principal-id> --assignee-principal-type ServicePrincipal \
--role "Reader" \
--scope /providers/Microsoft.Management/managementGroups/<tenant-id>
Add Security Reader and Key Vault Reader, plus Microsoft Graph application permissions Directory.Read.All, Policy.Read.All and UserAuthenticationMethod.Read.All. Monitor its sign-ins: tenant-wide read is valuable reconnaissance.
Prowler
Prowler is an Apache 2.0 open source tool with Azure checks mapped to several CIS Microsoft Azure Foundations versions and to MCSB.
python3 -m venv ~/.venvs/prowler && . ~/.venvs/prowler/bin/activate
pip install prowler
az login --tenant <tenant-id>
prowler azure --list-compliance
prowler azure --az-cli-auth \
--compliance cis_3.0_azure \
--output-formats csv html json-ocsf \
--output-directory ./prowler-$(date +%F)
Use the framework identifier --list-compliance prints for your release (the pattern is cis_<version>_azure). Other authentication options are --sp-env-auth (service principal from AZURE_CLIENT_ID, AZURE_TENANT_ID and a secret) and --managed-identity-auth on an audit host. Each finding has a status (PASS, FAIL, MANUAL), a severity, the resource ID and a remediation hint.
ScoutSuite (NCC Group) gives a browsable offline snapshot (scout azure --cli --all-subscriptions), but its releases have slowed, so treat it as a second view only.
Triage
Group failures by check, not by resource: one check failing on 300 storage accounts is one policy plus one remediation task. Fix tenant findings once in Entra ID and subscription findings with the guardrails on this page, public exposure and Owner-level identities first. Record false positives in Prowler's mutelist with a reason, and rerun weekly to diff the FAIL set.
Logging and detection
Policy and hierarchy changes happen at management group scope, so they are recorded in the management group activity log, not in the subscriptions below. Review them in Monitor > Activity log with the management group selected, and route subscription activity logs to Log Analytics as described on the Azure Monitor page.
Operations to alert on:
| Operation | Why |
|---|---|
Microsoft.Authorization/policyAssignments/delete | Guardrail removed |
Microsoft.Authorization/policyAssignments/write with enforcementMode changed | Deny silently switched to report only |
Microsoft.Authorization/policyExemptions/write | New exception |
Microsoft.Authorization/policyDefinitions/write, policySetDefinitions/write | Rule logic changed |
Microsoft.Management/managementGroups/subscriptions/write | Subscription moved between groups |
Microsoft.Authorization/elevateAccess/action | Global Administrator took root access |
AzureActivity
| where OperationNameValue has_any ("MICROSOFT.AUTHORIZATION/POLICYASSIGNMENTS/DELETE",
"MICROSOFT.AUTHORIZATION/POLICYEXEMPTIONS/WRITE",
"MICROSOFT.AUTHORIZATION/POLICYASSIGNMENTS/WRITE")
| where ActivityStatusValue == "Success"
| project TimeGenerated, Caller, CallerIpAddress, OperationNameValue, _ResourceId
For elevate access, stream the Microsoft Entra audit log to the workspace (Entra diagnostic setting, category AuditLogs) and alert:
AuditLogs
| where LoggedByService == "Azure RBAC (Elevated Access)"
| project TimeGenerated, OperationName, InitiatedBy, Result
Microsoft Sentinel ships an Azure RBAC (Elevate Access) analytics rule template for the same event. Track compliance drift over time with Resource Graph on policyresources (type microsoft.policyinsights/policystates) or the Defender for Cloud compliance-over-time workbook.
Common mistakes
- Assigning everything at the Tenant Root Group on day one. A broken deny policy then blocks deployments in every subscription at once, with no group to test in.
- Leaving the default management group at the root. New subscriptions, including those created by attackers or shadow IT, start outside every guardrail.
- Forgetting to remove elevated access. The User Access Administrator assignment at
/survives PIM deactivation and stays until someone removes it. - Using
notScopesinstead of exemptions. Excluded scopes have no expiry, no justification and do not show as exceptions in compliance reports. - Enforcing
Denywithout remediation. Existing non-compliant resources then fail on their next unrelated update, and teams ask for the policy to be removed. - Over-privileged remediation identities. A
DeployIfNotExistsidentity with Owner on the top management group is a tenant-wide escalation path. - Trusting the dashboard alone. Policy-based compliance never shows Entra ID gaps such as missing MFA or permissive app consent; run the external scan.
References
- What are Azure management groups? (Microsoft Learn)
- Protect your resource hierarchy (Microsoft Learn)
- Elevate access to manage all Azure subscriptions and management groups (Microsoft Learn)
- What is Azure Policy? (Microsoft Learn)
- Azure Policy exemption structure (Microsoft Learn)
- Remediate non-compliant resources with Azure Policy (Microsoft Learn)
- Regulatory compliance in Defender for Cloud (Microsoft Learn)
- Microsoft cloud security benchmark overview (Microsoft Learn)
- CIS Microsoft Azure Foundations Benchmark (Center for Internet Security)
- Prowler (GitHub, Prowler)
- ScoutSuite (GitHub, NCC Group)
- Azure Policy samples and built-in definitions (GitHub, Microsoft)
Roll out Azure Policy guardrails safely
Secure the hierarchy
Set a default management group for new subscriptions, require authorization to create management groups and remove unneeded access at the tenant root.
Assign the audit initiatives
Assign the Microsoft cloud security benchmark and the CIS initiative at the top management group to measure the current state.
Assign deny policies in DoNotEnforce mode
Assign each deny policy with enforcement mode DoNotEnforce and review the non-compliant resources it reports.
Fix or exempt existing resources
Remediate non-compliant resources or record a time-limited exemption with a justification.
Switch to Default enforcement
Set the enforcement mode to Default so new non-compliant deployments are blocked, then confirm with an external CIS scan.
Filed under azure-policy, management-groups, cis-benchmark
Written by
Florian Amette, Cloud Security Engineer & EditorSecurity engineer writing practical hardening pages for Microsoft Azure tenants and subscriptions, aligned with the CIS Microsoft Azure Foundations Benchmark.