Effects supported in language version 1.0, and how they are validated¶
Context and Problem Statement¶
The effect produces the policy rule's then block. Which effects are valid in language version 1.0, how are they written, and what does the compiler check?
Considered Options¶
Audit,DenyandDisabledwithEffect, and each effect that needs adetailsblock through its own keywordEffectfor every effect, with a details hashtable- Only the effects without details
Decision Outcome¶
Chosen option: "Audit, Deny and Disabled with Effect, and each effect that needs a details block through its own keyword", because each detail can then be validated, and the keyword reads as what the policy does.
| Effect | Written as | ADR |
|---|---|---|
Audit, Deny, Disabled |
Effect Deny, or Effect (Param Effect) |
this ADR |
Modify |
Modify -Role ... { operations } |
ADR-0024 |
DenyAction |
DenyAction Delete |
this ADR |
Manual |
Manual |
this ADR |
Append |
Append { Add operations } |
ADR-0029 |
AuditIfNotExists, DeployIfNotExists |
AuditIfNotExists ... { }, DeployIfNotExists ... { } |
ADR-0030, ADR-0031 |
Effect Denyemits a literal effect.Effect (Param Effect)emits[parameters('effect')].- Effect names are case-insensitive in the DSL and emitted in canonical casing (
Audit,Deny,Disabled). Effectwith the name of an effect that has its own keyword, such asEffect Modify, is a compile error that points to the keyword.- A policy has exactly one of
Effect,Modify,Append,DenyAction,Manual,AuditIfNotExistsandDeployIfNotExists. None is a compile error (BYL1006), and so is a second one (BYL1026). - Each keyword sets its own effect, and takes
-Effect (Param Effect)to make it a parameter instead. - When the effect is a parameter, the compiler checks that:
- the parameter exists and is of type
String, AllowedValuesis set and contains only effects the rule supports:Audit,DenyandDisabledwithEffect; for a keyword, its own effect,Disabled, and any other values its ADR lists,Default, if set, is one ofAllowedValues.
The effects whose details need a design of their own have their own ADRs, as the table shows. DenyAction and Manual have small details blocks, so they are described here. They were in ADR-0028 until 2026-11-29, when that ADR was folded into this one, since its decision was this one's.
DenyAction¶
denyAction blocks an action, currently only deletion, on matching resources.
DenyAction Delete -CascadeBehavior Deny
- The action is positional and required. Learn: "The only supported action today is
DELETE." It is emitted as"actionNames": ["delete"]. Other actions are a compile error. -CascadeBehavior DenyorAllowemits"cascadeBehaviors": { "resourceGroup": "deny" }(or"allow"). It's omitted when not set, and Azure's default isdeny. Learn: it is "only supported in policy definitions with mode set toindexed", so using it with any otherModeis a compile error.- The effect is emitted as
DenyAction. - Warning: a
Resourcetype that DenyAction never applies to. Learn listsMicrosoft.Authorization/policyAssignments,Microsoft.Authorization/denyAssignments,Microsoft.Blueprint/blueprintAssignments,Microsoft.Resources/deploymentStacks,Microsoft.Resources/subscriptionsandMicrosoft.Authorization/locks.
Manual¶
manual lets owners attest compliance by hand, and is used by regulatory compliance initiatives.
Manual -DefaultState Unknown
-DefaultStateisUnknown,CompliantorNonCompliant. It is emitted as"defaultState": "Unknown","Compliant"or"Non-compliant", the spellings Learn uses. Without it, there is nodetailsblock, and Azure's default isUnknown.- The effect is emitted as
Manual.
DenyAction and Manual¶
-Effect (Param Effect)makes the effect a parameter. Its allowed values may be the keyword's effect andDisabled, and nothing else. A literal effect gets a generated EPAC effect parameter with those two values (ADR-0023).- Both effects apply to every resource that matches
ResourceandWhen: those are the resources that can't be deleted, or whose compliance is attested. So they are usually written withWhenand noRequire, and BYL3041 ("no Require block") isn't reported for them. - Front-end diagnostics:
- BYL1033: an action other than
Delete, or none. - BYL1034: an invalid
-CascadeBehavior. - BYL1035: an invalid
-DefaultState. - As for
Modify, BYL1030 is a literal-Effect, and BYL1026 is a second effect keyword. - Validation diagnostics:
- BYL3072: an effect parameter that allows a value other than the keyword's effect and
Disabled. - BYL3073:
-CascadeBehaviorwithoutMode = 'Indexed'. - BYL3074, a warning: a
Resourcetype DenyAction never applies to.
Consequences¶
- Good, because every effect the compiler accepts is fully validated.
- Bad, because each effect with details adds a keyword. They are named after the effects, so they're easy to find.
Confirmation¶
Unit tests cover each valid effect, each rejected effect and each parameter check. For DenyAction and Manual, they also cover each option, each error and warning, and the generated effect parameter. Golden tests cover both keywords in EPAC and plain JSON.
Pros and Cons of the Options¶
A keyword per effect with details¶
- Good, because each detail is typed and checked.
- Bad, because each new Azure effect needs a new keyword.
Effect with a details hashtable¶
- Good, because there is one keyword.
- Bad, because the details aren't validated.
Only the effects without details¶
- Good, because there is little to build.
- Bad, because 82 of the 149 custom definitions in the Azure Landing Zones Library couldn't be written.