Which typed ARM expression helpers ship in v1¶
Context and Problem Statement¶
Policy values often use ARM template expressions: [parameters('x')], [resourceGroup().tags['owner']], [field('location')], [concat(...)], [requestContext().apiVersion]. Typed helpers allow validation (for example that a parameter exists) and keep authors away from quoting mistakes. Each helper is also surface area to maintain and something the decompiler must recognise. Which helpers ship in v1 beyond Param, Tag, ResourceGroupTag and Arm?
Decision Drivers¶
- Cover the most common expressions with validation.
- Keep the v1 surface small.
Armcovers everything else. - Let real data from the planned ALZ coverage report drive what gets added.
Considered Options¶
- Only
Param,Tag,ResourceGroupTagandArm. Decide on more from ALZ coverage data. - Also add
FieldValue,ResourceGroupLocation,SubscriptionIdandConcatnow - A general typed expression builder (
Fn concat (...))
Decision Outcome¶
Chosen option: "Only Param, Tag, ResourceGroupTag and Arm, then decide from ALZ coverage data".
Param Nameemits[parameters('<jsonName>')]. The parameter must exist (ADR-0021).Param Name -Lengthemits[length(parameters('<jsonName>'))], the number of members of a list, as when a value count is compared with the length of its list (ADR-0032). It replaces the most commonArmin count comparisons, and checks whatArmcan't: the parameter must exist, and be anArray,StringorObject, whichlength()takes (BYL3130).- A length is a whole number. As a value it is used with
-Beand the comparisons; tested itself, as inParam Name -Length | Must -BeGreaterThan 0, it also takes-BeIn. Other operators are BYL3130. It can't be the list ofCount -Value(BYL1047). Tag nameis a field reference to the tag,tags['name']. It can be piped intoMustand intoModifyoperations (ADR-0024).Tag (Param TagName)emits the field[concat('tags[', parameters('tagName'), ']')], as Azure's built-in tag policies do.- A tag name containing
',[or]is a compile error (BYL1023), because it can't be written safely insidetags['...']. - A parameter that holds a tag name must be declared, and must be of type
String(BYL3034). Tagis a compile error insideEach, because fields there refer to the array element.Tagis shorthand forField "tags['name']", so the two compile to the same output.ResourceGroupTag nameis a value:[resourceGroup().tags['name']].ResourceGroupTag (Param TagName)emits[resourceGroup().tags[parameters('tagName')]].- It can be used wherever a value is expected (
Must -Be (ResourceGroupTag CostCenter), aModifyoperation's value), and piped intoMustas a value condition (ADR-0025). - The same name rule as
Tagapplies. Arm '[...]'is passed through exactly as written. The compiler checks only that the value starts with[and ends with], and that it isn't[[(an escaped literal). Anyparameters('x')names referenced inside are checked against the declared parameters on a best-effort basis, as a warning.- The planned coverage report will count which
Armpatterns appear most often in ALZ policies. Helpers for the top patterns are proposed in a follow-up ADR.
Consequences¶
- Good, because the surface stays minimal and choices are driven by evidence.
- Bad, because common expressions such as
[field('location')]needArmin v1.
Confirmation¶
Unit tests cover each helper with a literal name and with Param, the name rule, and the equivalence of Tag x and Field "tags['x']". The tag inheritance golden test uses both Tag and ResourceGroupTag with a parameter.
Pros and Cons of the Options¶
Minimal set, data-driven later¶
- Good, because nothing speculative gets added.
- Bad, because v1 policies will use
Armmore.
Larger set now¶
- Good, because it is more ergonomic immediately.
- Bad, because every helper has to be kept compatible across language versions, even if few people use it.
General expression builder¶
- Good, because it covers everything.
- Bad, because it amounts to reimplementing ARM expression syntax in PowerShell, with little benefit over
Arm.