Home › Studies › SC-500 › Identity & Governance › Policy & Compliance

Azure Policy & Compliance

Azure Policy effects · assignments and initiatives · remediation · exemptions · resource locks · Defender for Cloud standards and recommendations · infrastructure as code

By the tools4free.dev team · Last reviewed November 13, 2026

Practice questions for this topic →

Azure Policy definitions and effects

A policy definition holds the rule and a single effect. Several definitions are grouped into an initiative (also called a policySet). Policy ensures resource state is compliant with the rules without concern for who made the change or who has permission to make it. Azure RBAC manages what users can do at different scopes.

EffectWhat it doesWatch for
audit / auditIfNotExistsReports non-compliance; changes nothing.Microsoft recommends starting with these before an enforcement effect.
denyBlocks the create or update.Evaluated before audit to prevent double logging.
modifyAdds, updates or removes properties or tags on a subscription or resource during create or update.Needs a managed identity to remediate. Only tags can be removed. It does not change existing resources during an evaluation cycle; it marks them non-compliant.
deployIfNotExistsRuns a template deployment when the related resource is missing or its existenceCondition is not true.Needs a managed identity to remediate. Existing resources are marked non-compliant but not changed. Default evaluation delay is PT10M.
disabledTurns the policy rule off.Checked first, before the rule is evaluated.

Order of evaluation: disabled, then append and modify, then deny, audit, manual, auditIfNotExists, and denyAction last.

Assignments, initiatives, remediation and exemptions

Assignment settingUse it to
notScopes (excluded scopes)Leave a child container or resource out of evaluation. An excluded resource is different from an exempted resource.
enforcementMode = DoNotEnforceEvaluate without enforcing the effect and without Activity log entries. Manual remediation is still possible. Default enforces the effect.
overridesChange the effect of a definition (kind policyEffect) without editing the definition. Up to 10 overrides per assignment, up to 50 policyDefinitionReferenceId values per override.
resourceSelectorsRoll out gradually by resource location, resource type or whether the resource has a location. Up to 10 per assignment.

Remediation

  1. Make sure the definition lists roleDefinitionIds (full role IDs, not role names). Built-ins already have them; custom definitions need them added under details.
  2. Give the assignment a managed identity: system-assigned or user-assigned. One assignment can have only one identity, which can hold several roles.
  3. Grant the identity the roles. The portal does this for you; CLI, PowerShell and SDK assignments need manual role assignments or the remediation deployment fails.
  4. Create a remediation task. One deployIfNotExists or modify policy is remediated per task.

The assignment identity deploys or modifies resources, but it is not used to evaluate the policy rule. If roleDefinitionIds change later, the new permissions must be granted by hand, even in the portal. Contributor can trigger remediation but cannot create or update definitions and assignments; User Access Administrator is needed to grant the identity its permissions.

Exemptions

CategoryMeaning
MitigatedThe policy intent is met another way.
WaiverNon-compliance is temporarily accepted. Also used to exempt a resource from some definitions of an initiative.

Resource locks

A lock protects a subscription, resource group or resource from accidental deletion or modification and overrides any user permissions. Locks apply to everyone, unlike RBAC.

Portal nameCLI / PowerShell nameEffect
DeleteCanNotDeleteAuthorized users can read and modify, but not delete.
Read-onlyReadOnlyAuthorized users can read only. Similar to the Reader role.

Defender for Cloud: security standards and regulatory compliance

Defender for Cloud: recommendations and security controls

Setting on a recommendationResult
AuditTurns the recommendation on.
DisabledTurns it off (and all its subrecommendations).
DenyPrevents deployment of resources that do not comply with MCSB.
EnforceUses the DeployIfNotExist effect to remediate non-compliant resources automatically on creation. Set only from the recommendation details page.

Security controls by using infrastructure as code

CLI and PowerShell

TaskAzure CLIPowerShell
Create a delete lock on a resource groupaz lock create --name LockGroup --lock-type CanNotDelete --resource-group exampleresourcegroupNew-AzResourceLock -LockName LockGroup -LockLevel CanNotDelete -ResourceGroupName exampleresourcegroup
Create a policy remediation taskaz policy remediation create --name myRemediation --policy-assignment '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments/{myAssignmentId}'-
Get the role ID for roleDefinitionIdsaz role definition list --name "Contributor"-
Preview a Bicep deploymentaz deployment group what-if-
Let a key vault serve template deploymentsaz keyvault update --name ExampleVault --enabled-for-template-deployment trueSet-AzKeyVaultAccessPolicy -VaultName ExampleVault -EnabledForTemplateDeployment

Exam Tips

Tick each tip once you can answer it without looking.

“Block new resources outside approved regions, for everyone including admins” → Azure Policy with a deny effect (built-in Allowed Locations), assigned at a management group or subscription. Trap: RBAC controls who can act, not what a resource looks like; a lock does not check properties. Even with permission to create, Policy still blocks a non-compliant create or update.

“A deployIfNotExists or modify policy is assigned, but existing resources are still non-compliant and unchanged” → Create a remediation task; evaluation only marks existing resources non-compliant. Trap: Assuming the effect fixes old resources: it acts on create or update. One policy per remediation task.

“Remediation task fails after the assignment was made with CLI, PowerShell or an SDK” → The assignment's managed identity lacks the roles in roleDefinitionIds; grant them manually (only the portal grants them for you). Trap: Giving the roles to the person running the task. The identity deploys, and edits to roleDefinitionIds after assignment also need manual grants.

“Roll out a new deny policy and first see what it would affect” → Start with audit/auditIfNotExists, or assign with enforcementMode DoNotEnforce. Trap: DoNotEnforce skips the effect and Activity log entries but still lets you remediate manually. Do not start with an enforcement effect.

“One resource group must be left out of a subscription-level assignment” → Set notScopes on the assignment (exclusion); use an exemption when the resource must still be tracked, with a waiver or mitigated category and an expiry. Trap: An exclusion is not an exemption. You cannot allow what a parent assignment denies by adding a looser assignment below it: Policy is an explicit deny system.

“Change the effect of one policy inside an initiative without editing the definition” → An overrides entry of kind policyEffect on the assignment. Trap: Editing the shared definition affects every assignment, because assignments always use the latest definition.

“Who can create a policy exemption?” → policyExemptions/write plus the exempt/Action verb on the target assignment (Resource Policy Contributor and Security Admin have read and write). Trap: Contributor can trigger remediation but cannot create or update definitions and assignments.

“Enforce a required tag and fix existing resources too” → modify with mode indexed (needs a managed identity and a remediation task). Trap: Microsoft recommends modify over append for tags: it has more operation types and can remediate existing resources. append is for when you cannot create a managed identity. For a tag policy on a resource group, mode indexed is not required.

“A resource group holds a VM; nobody can start or restart it” → A ReadOnly lock on the resource group: starting a VM is a POST request, which the lock blocks. Trap: Looking for an RBAC or Policy cause. Also a read-only lock on a storage account blocks listing its keys.

“A delete lock is on a storage account, yet a blob was deleted” → Locks cover the control plane only; data plane operations are not blocked. Trap: Believing a lock protects blob, queue, table or file data.

“Who can create a lock, and where?” → Owner or User Access Administrator (Microsoft.Authorization/locks/*); subscription, resource group or resource, not a management group. Trap: Putting a lock on a management group is not possible.

“Add a regulatory standard in Defender for Cloud” → Regulatory compliance, then Manage compliance policies, choose the highest scope, Security policies, toggle On. Needs Owner or Policy Contributor. Standards are Azure Policy initiatives. Trap: Using the Defender portal: it shows status but standards are assigned in the Azure portal experience.

“A compliance control is greyed out, or an assigned standard is missing from the dashboard” → Greyed: cannot be assessed automatically (attest manually). Missing: the subscription has no relevant resources for that standard. Trap: Treating grey as failing; or assuming the assignment failed.

“Stop new non-compliant deployments from a Defender for Cloud recommendation” → Set the recommendation to Deny; Enforce auto-remediates with DeployIfNotExist on creation. Trap: Deny and Enforce only cover a subset of Azure recommendations; Enforce is set from the recommendation details page.

“Accept the risk on a recommendation without lowering the secure score” → A mitigated exemption counts the resource as healthy; a waiver excludes it from the score. Needs Owner or Security Admin, MCSB assigned, and up to 24 hours. Trap: Custom recommendations cannot be exempted. An Azure Policy API exemption must be repeated per initiative.

“Keep secrets out of Bicep deployments” → @secure() parameters, no secret outputs, getSecret from Key Vault with enabledForTemplateDeployment, or managed identities. Trap: Outputs are written to deployment history and readable by anyone with access to the deployment.

“Preview a Bicep deployment without changing anything” → az deployment group what-if (also subscription, management group, tenant). Trap: What-if predicts changes; it makes none. Linter checks the file itself for rule violations.

Sources

Checked against Microsoft Learn on November 13, 2026.

← Azure Key VaultRBAC & Backup Security →