Raw conditions¶
For a condition Bylaw's keywords can't express, Condition takes one Azure Policy condition as it would appear in policy JSON, as a hashtable or as JSON text:
When {
Condition @{ value = '[requestContext().apiVersion]'; greaterOrEquals = '2020-01-01' }
}
Require 'No rule allows SSH from anywhere' {
Condition -Violation @{
count = @{
field = 'securityRules[*]'
where = @{ allOf = @(
@{ field = 'securityRules[*].sourceAddressPrefix'; equals = '*' }
@{ field = 'securityRules[*].destinationPortRange'; equals = '22' }
) }
}
greater = 0
}
}
- In
WhenandCount -Where, it is emitted as written, like everything else there. - In
RequireandEach, statements describe the compliant state and are inverted, which Bylaw can't do correctly for raw JSON. So say which form you wrote:-Violationis the condition that finds a non-compliant resource, emitted as written;-Compliantis the compliant state, emitted asnot(...). - Field names resolve like
Field: a short name against theResourcetype, or relative to the element insideEach. A full alias, a path with[*](as policy JSON writes it inside acount'swhere), or an ARM expression is used as written. Unknown aliases are still an error. - Values can be
ParamandArm, so parameters are still declared and checked. Use a[ordered]hashtable, or JSON text, where the order of a literal object's keys matters. - In
AuditIfNotExistsandDeployIfNotExists,Requiredescribes the related resource's compliant state, which Azure's existence condition is, so the forms swap:-Compliantis emitted as written, and-Violationasnot(...). - Nothing else is checked. Bylaw adds no missing-field handling to a raw condition, and can't tell whether it means what its
Requiresays. Prefer Bylaw's own keywords wherever they can express the condition.