Condition¶
SYNOPSIS¶
A raw Azure Policy condition, for what Bylaw's keywords can't express (ADR-0040).
SYNTAX¶
Condition [-Value] <Object> [-Violation] [-Compliant] [<CommonParameters>]
DESCRIPTION¶
Condition takes one policy condition, as a hashtable or JSON text, in the shape of policy JSON: a field or value condition, a count, or allOf, anyOf or not. Field names are resolved like Field: a short name against the Resource type, or relative to the element inside Each. A full alias, a [*] field or an ARM expression is used as written. Values can be Param or Arm.
In When and Count -Where, the condition is emitted as written. In Require and Each, statements describe the compliant state and are inverted, which Bylaw can't do correctly for a raw condition, so say which form it is: -Violation for the condition that finds a non-compliant resource, emitted as written, or -Compliant for the compliant state, emitted as not(...). Neither adds missing-field checks. Prefer Bylaw's own keywords where they can express the condition: they handle missing fields for you.
USED IN¶
When, Require, Each, AnyOf, AllOf, Count -Where
EXAMPLES¶
Example 1¶
When {
Condition @{ value = "[requestContext().apiVersion]"; less = '2021-01-01' }
}
Example 2¶
Require 'Diagnostic logs are enabled' {
Condition -Violation @{
count = @{ field = 'logs[*]'; where = @{ field = 'logs[*].enabled'; equals = 'false' } }
greater = 0
}
}
Example 3¶
Require 'The SKU is allowed' {
Condition -Compliant '{ "field": "Microsoft.Compute/virtualMachines/sku.name", "in": ["Standard_D2s_v5", "Standard_D4s_v5"] }'
}
PARAMETERS¶
-Value¶
The condition: a hashtable, an [ordered] hashtable, or JSON text.
Type: Object
Required: true
Position: 1
Accept pipeline input: false
-Violation¶
In Require and Each: the condition finds a non-compliant resource, and is emitted as written.
Type: SwitchParameter
Required: false
Position: named
Accept pipeline input: false
-Compliant¶
In Require and Each: the condition is the compliant state, and is emitted as not(...).
Type: SwitchParameter
Required: false
Position: named
Accept pipeline input: false