Lesson 4 of 5 Governance Solutions

Enforcing Standards with Azure Policy Effects

This lesson explains policy definitions, assignments and effects.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe definitions, initiatives and assignments.
  • Choose a policy effect for a requirement.
  • Distinguish Azure Policy, RBAC, resource locks and deployment stacks.

How Azure Policy works

Azure Policy evaluates resources against rules at the time of deployment and on a regular cycle afterwards. A policy definition describes a condition and an effect. An initiative groups definitions so that they can be assigned and tracked as one unit. An assignment applies a definition or initiative at a scope, with optional exclusions, and exemptions can cover specific resources with a reason and expiry date.

Azure Policy controls the properties of resources, not the people who deploy them. RBAC can say that a user may create storage accounts; Azure Policy can say that a storage account must disable public access, whoever creates it.

Policy effects

The effect is what happens when a resource matches a rule. Selecting the right effect is a frequent exam task.

  • Deny rejects a request that would create a non-compliant resource.
  • Audit allows the request but records the resource as non-compliant.
  • Modify adds, changes or removes properties or tags on a resource at request time, and can remediate existing resources.
  • Append adds fields to a resource at creation, in simpler cases.
  • DeployIfNotExists deploys a related resource if it is missing, such as a diagnostic setting. It needs a managed identity to act, and remediation tasks cover existing resources.
  • AuditIfNotExists reports when a related resource is missing, without creating it.
  • DenyAction blocks specific actions, such as deletion, on matching resources.

A policy is not retroactive with a deny effect. Existing resources that break a new rule stay in place and are reported as non-compliant, and remediation is limited to the modify and deployIfNotExists effects.

The following diagram matches each security requirement to an Azure Policy effect.

Matching each security requirement to an Azure Policy effect. New storage accounts must never allow public blob access, so deny applies. SQL audit logging must be created on new and existing servers, so deployIfNotExists applies with a remediation task. A report of VMs without backup, with no automatic change, is auditIfNotExists.
The scenario is illustrative.
Match the pairs

Policy effects

Exam skills 1.3.2

Match each Azure Policy effect with what it does.

Log in to try this activity Interactive activities are free with an account.

Separating similar controls

Governance scenarios often offer several tools that all seem to help. The following comparison shows how they differ.

Azure Policy
Question answeredWhat may a resource look like?
Scope of effectProperties of resources
Typical useAllowed regions, required settings
Choose when Enforce configuration standards
Azure RBAC
Question answeredWho may act?
Scope of effectPrincipals and operations
Typical useLeast-privilege access
Choose when Control access
Resource locks
Question answeredCan this be changed or deleted?
Scope of effectA resource and its children
Typical useProtect a critical resource
Choose when Prevent accidental deletion
Deployment stacks
Question answeredWhich resources are managed together?
Scope of effectThe resources in the stack
Typical useDeploy and protect a set of resources
Choose when Lifecycle and drift protection
Sort into groups

Policy, RBAC, lock or stack?

Exam skills 1.3.2

Choose the governance tool that answers each requirement.

Log in to try this activity Interactive activities are free with an account.

Rolling out policy safely

A policy with a deny effect can break deployment pipelines if it is introduced suddenly. A safe rollout uses enforcement mode set to disabled, or an audit effect, to learn what would be affected, and then enforces the rule after teams have addressed the findings. Microsoft also supports safe deployment practices, in which assignments move in rings, from a small scope to a larger one.

Assignments can also be managed as code, and many organizations use the Enterprise Policy as Code approach or the built-in landing zone policies. Exemptions should be recorded and given an expiry date, since permanent exclusions gradually weaken governance.

Put in order

A safe policy rollout

Exam skills 1.3.2

Arrange the steps of introducing a deny policy safely.

Log in to try this activity Interactive activities are free with an account.
Worked example

Choosing the effect

A security team requires the following. New storage accounts must never permit public blob access. Every Azure SQL server, existing or new, must send audit logs to a central workspace. A report must show which virtual machines lack a backup, with no automatic change. Which effect suits each requirement?

New storage accounts must never be non-compliant, so deny applies. SQL audit logging requires a related resource to be created on new and existing servers, so deployIfNotExists applies, with a remediation task for existing servers and a managed identity on the assignment.

The backup report needs no change, and concerns a related resource, so auditIfNotExists applies. Using deny for backups would block virtual machine creation rather than report on gaps, and a plain audit effect on the virtual machine could not examine whether the related protection item exists.

Check yourself

A new deny policy is assigned. What happens to existing non-compliant resources?

Show answer

They remain in place and are reported as non-compliant. Deny affects new requests, and only modify and deployIfNotExists can remediate.

Exam Tips

Remember for the exam

  • An initiative groups definitions; an assignment applies them at a scope.
  • Deny blocks; audit reports; modify changes; deployIfNotExists creates related resources.
  • Only modify and deployIfNotExists can remediate existing resources.
  • Introduce deny policies through audit or disabled enforcement first.