Skip to content

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
Published on 15 min read
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.

ControlWhyHow to checkID
Management group hierarchyInheritance only helps if scopes match how you governaz account management-group show --name <tenant-id> --expand --recurseMCSB GS-2
Default group and creation rightsNew subscriptions otherwise skip your guardrailsaz rest GET on managementGroups/<tenant-id>/settings/defaultCIS 5.8, 5.9
Minimal access at the tenant rootAnything assigned at / or the root group covers every subscriptionaz role assignment list --scope "/"MCSB PA-1
Elevate access is rare and watchedA Global Administrator can grant themselves every subscriptionEntra audit log, service Azure RBAC (Elevated Access)MCSB PA-1 / CIS 5.3.3
MCSB and CIS initiatives assignedYou cannot fix what you do not measureDefender for Cloud > Regulatory complianceMCSB PV-2 / CIS 8.1.13
Deny guardrails starter setStops the most common misconfigurations from coming backaz policy assignment list --disable-scope-strict-matchMCSB PV-1
Allowed locations and resource typesKeeps data and unreviewed services outPolicy compliance for Allowed locationsMCSB AM-2
Safe rollout with DoNotEnforceEnforcing blind breaks deploymentsenforcementMode on each assignment-
Exemptions that expirePermanent exceptions become permanent holesaz policy exemption list-
Remediation of existing resourcesDeny only protects new and updated resourcesaz policy remediation listMCSB PV-2
Guardrails protected from tamperingOwner can delete an assignment and deploy anythingAlerts on policyAssignments/deleteCIS 6.1.2.1, 6.1.2.2
Independent CIS auditPolicy cannot see Entra ID settingsprowler 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:

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

bash
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:

bash
az account management-group show --name <tenant-id> --expand --recurse \
  --query "children[?type=='/subscriptions'].{sub:displayName, id:name}" -o table
KQL
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 sandbox or a dedicated quarantine group) 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/write on 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.

bash
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:

bash
# 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:

bash
az rest --method post --url "/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01"

Treat it as an emergency procedure:

  1. Elevate only when a subscription has lost all its owners or for a one-off root-level change.

  2. 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:

    bash
    az role assignment list --role "User Access Administrator" --scope "/" -o table
    az role assignment delete --assignee <upn-or-object-id> \
      --role "User Access Administrator" --scope "/"
    
  3. 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:

EffectWhat it doesUse it for
AuditMarks matching resources non-compliantMeasuring before enforcing
AuditIfNotExistsNon-compliant if a related resource is missingDiagnostic settings, extensions
DenyRejects the create or update requestHard guardrails
DenyActionBlocks a specific action, currently deleteProtecting critical resources
ModifyAdds, changes or removes properties or tags on create, update and remediationFixing settings without blocking
DeployIfNotExistsDeploys a template when a related resource is missingDiagnostic settings, agents, private DNS
DisabledDoes nothingSwitching 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.

bash
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 policyWhyDetail
Storage accounts should prevent shared key accessForces Entra authenticationStorage
Storage account public access should be disallowedBlocks anonymous blob accessStorage
Storage accounts should disable public network accessPrivate endpoints onlyStorage
Secure transfer to storage accounts should be enabledHTTPS onlyStorage
Key vaults should have deletion protection enabledPurge protection everywhereKey Vault
Azure Key Vault should use RBAC permission modelNo legacy access policiesKey Vault
Network interfaces should not have public IPsNo direct internet exposure for VMsVirtual Machines
Subnets should be privateNo default outbound accessVirtual Network
Management ports should be closed on your virtual machinesAudits internet-exposed remote management ports; effects are AuditIfNotExists or Disabled only, so it reports but cannot denyVirtual Network

Group them in a custom initiative so they are assigned, exempted and versioned together:

bash
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:

JSON
{
  "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')]" }
  }
}
bash
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:

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

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

  2. Assign deny policies with --enforcement-mode DoNotEnforce. The assignment evaluates and reports but does not block. This is safer than setting the effect to Audit temporarily, because the configuration you test is the one you will enforce.

    bash
    az policy assignment create \
      --name deny-storage-public \
      --policy <definition-id> \
      --params '{"effect":{"value":"Deny"}}' \
      --enforcement-mode DoNotEnforce \
      --scope /providers/Microsoft.Management/managementGroups/landingzones
    
  3. Fix or exempt what it reports:

    bash
    az policy state list \
      --management-group landingzones \
      --filter "policyAssignmentName eq 'deny-storage-public' and complianceState eq 'NonCompliant'" \
      --query "[].resourceId" -o tsv
    
  4. Add a non-compliance message so blocked users know what to do:

    bash
    az 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."
    
  5. Switch to enforcement once the list is empty or exempted, and tell teams first:

    bash
    az 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.

bash
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:

bash
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:

bash
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/* or policyExemptions/*. 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.

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

bash
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:

OperationWhy
Microsoft.Authorization/policyAssignments/deleteGuardrail removed
Microsoft.Authorization/policyAssignments/write with enforcementMode changedDeny silently switched to report only
Microsoft.Authorization/policyExemptions/writeNew exception
Microsoft.Authorization/policyDefinitions/write, policySetDefinitions/writeRule logic changed
Microsoft.Management/managementGroups/subscriptions/writeSubscription moved between groups
Microsoft.Authorization/elevateAccess/actionGlobal Administrator took root access
KQL
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:

KQL
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 notScopes instead of exemptions. Excluded scopes have no expiry, no justification and do not show as exceptions in compliance reports.
  • Enforcing Deny without 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 DeployIfNotExists identity 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

Roll out Azure Policy guardrails safely

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

  2. Assign the audit initiatives

    Assign the Microsoft cloud security benchmark and the CIS initiative at the top management group to measure the current state.

  3. Assign deny policies in DoNotEnforce mode

    Assign each deny policy with enforcement mode DoNotEnforce and review the non-compliant resources it reports.

  4. Fix or exempt existing resources

    Remediate non-compliant resources or record a time-limited exemption with a justification.

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

, Cloud Security Engineer & Editor

Security engineer writing practical hardening pages for Microsoft Azure tenants and subscriptions, aligned with the CIS Microsoft Azure Foundations Benchmark.

Related services

  1. App ServiceHarden Azure App Service: HTTPS and TLS, basic auth and FTP off, access restrictions, private endpoints, Key Vault references, logging and dangling DNS.
  2. Azure FunctionsHarden Azure Functions: access keys and Entra auth, master key exposure, identity-based storage, network isolation, Flex Consumption, CORS and logging.
  3. Virtual MachinesHarden Azure VMs: Trusted Launch, no public IPs, JIT and Bastion access, Entra ID login, encryption at host, Update Manager patching and Defender for Servers.