Skip to content

Azure Policy (EPAC)

Azure Policy is how the platform states rules for every resource in the tenant, and checks them continuously: required tags, allowed configurations, required logging. All policy is managed as code with Enterprise Policy as Code (EPAC), deployed from the azure-governance-epac repository.

Status: in place, audit-only

Every policy assignment currently runs with enforcementMode: DoNotEnforce. Policies report non-compliance but block nothing and fix nothing. This applies even where an assignment's name or effect says "Deny" or "DeployIfNotExists". Moving selected guardrails to enforcement is planned, and tracked in ADR-0001.


How it is organised

EPAC (v11.5.1) keeps every policy artefact as JSONC in Definitions/:

Folder Contains
policyDefinitions/ Custom policy definitions
policySetDefinitions/ Custom initiatives, one per domain (psd-*)
policyAssignments/ Assignments, grouped by domain: backup, compute, general, key vault, monitoring, network, regulatory compliance, security, SQL, storage and tags
policyExemptions/ Time-limited exemptions
global-settings.jsonc The tenant, root scope and lifecycle settings

All assignments target mg-intermediate-root, so they apply to every management group and subscription beneath it. EPAC runs with strategy: full: it removes any policy assignment in its scope that is not in the repository. The one exception is Defender for Cloud's own automatic assignments (keepDfcSecurityAssignments: true).

The three-layer model (ADR-0001)

Layer What Allowed effects
Detective standards Microsoft Cloud Security Benchmark, ISO 27001, ENS Audit and AuditIfNotExists only. They are never raised to Deny.
Preventive guardrails Custom psd-* initiatives per domain Deny, DenyAction, Modify
Configuration remediation Defender for Cloud and diagnostic settings DeployIfNotExists

The layers are kept apart on purpose. A Microsoft-owned benchmark of about 240 policies is never switched to blocking. Anything that must block is added to the matching custom guardrail initiative instead.


How changes are deployed

The GitLab pipeline (shared ci-templates/epac-pipeline.yml) runs three stages:

  1. plan (Build-DeploymentPlans) compares Definitions/ with the live tenant and writes a plan. It runs on every MR and posts a summary comment, and again on main.
  2. deploy-policy (Deploy-PolicyPlan) creates or updates definitions, initiatives, assignments and exemptions. It runs on main only, behind a manual play button.
  3. docs (Build-PolicyDocumentation) regenerates the assignment documentation from the live state and commits it back to main.
flowchart LR
    MR["Merge request"] --> P1["plan<br/>sp-pla-tool-epac-plan-ro<br/>Reader"]
    P1 --> C["MR comment"]
    M["main"] --> P2["plan<br/>sp-pla-tool-epac-plan-ro"]
    P2 --> D["deploy-policy (manual)<br/>sp-pla-tool-epac-deploy-policy-rw<br/>Resource Policy Contributor"]
    D --> DOC["docs<br/>sp-pla-tool-epac-plan-ro"]

The identities

Two service principals, vended by azure-service-principals-platform (pla-tool-epac.tf). Both sign in with OIDC (no secrets), with issuer https://gitlab.com and audience api://AzureADTokenExchange, and both trust the EPAC GitLab project only.

Identity Used by Azure role Federated credential trusts
sp-pla-tool-epac-plan-ro plan, docs Reader at mg-intermediate-root Any branch of the project (a flexible credential that also checks the parent group)
sp-pla-tool-epac-deploy-policy-rw deploy-policy Resource Policy Contributor at mg-intermediate-root, plus Managed Identity Operator on id-policy-noperms-001 only main only

Neither has Graph permissions or a directory role.

Why there is no roles stage

Standard EPAC has a fourth stage, Deploy-RolesPlan. It grants roles to the identities that DeployIfNotExists and Modify assignments use to fix resources. It needs an identity with Role Based Access Control Administrator (or User Access Administrator) at mg-intermediate-root, which is Tier 0 by mechanism.

This platform doesn't need it:

  • Every assignment is DoNotEnforce, so nothing remediates and no assignment needs roles.
  • Assignments that must carry an identity use id-policy-noperms-001, a user-assigned identity with zero roles (created in azure-monitoring).
  • EPAC only grants roles to system-assigned identities, and none are used. So the roles plan is always empty.

So no CI identity can grant roles, and EPAC stays platform Tier 1. The MR plan comment warns if the roles plan is ever non-empty. If an assignment ever needs to remediate, give it a user-assigned identity whose roles are granted in Terraform, not a system-assigned one.

The former exception for this, EX-003, is closed.

For the hands-on steps, see Manage Azure Policy (EPAC).


From audit to enforcement

ADR-0001 sets the rule for making any control blocking:

  1. Ship as Audit first. Leave it for at least one plan cycle, so the number of non-compliant resources is visible.
  2. Fix or exempt what is non-compliant.
  3. Promote to Deny or Modify in a separate MR, and set that assignment's enforcementMode to Default.
  4. Handle exceptions with exemptions, never by weakening the effect.

For DeployIfNotExists assignments, enforcementMode: Default also makes new resources compliant automatically. Existing resources still need one remediation task.


Exemptions

An exemption is the only approved way to exclude something from a policy. The rules, from Definitions/policyExemptions/README.md:

Rule Detail
Expiry Mandatory, no more than 90 days away. Renewing needs a new MR with a new justification.
Scope As narrow as possible: a resource or resource group, not a subscription.
Members Exempt specific initiative members rather than a whole assignment.
Category Mitigated if a compensating control exists, Waiver if the risk is simply accepted
Approval A CODEOWNER for the exemptions folder approves. Self-approval is not allowed.
Review Monthly, against each exemption's ticket

There are no active exemptions today. Controls that can never apply by design, such as "more than one subscription owner", are disabled rather than exempted, in azure-mcsb-overrides. See Defender for Cloud Secure Score.