Bicep includes a decision-making operator combination isTrue ? thenValue : elseValue
which is called the conditional operator or ternary operator. It is the short form of the if-else
conditions.
Syntax
param initValue bool = true
output outValue string = initValue ? 'true value' : 'false value'
Nested Ternary Operator and meaning of life
Nested ternary operators are possible by including a conditional expression as a second statement.
param x int = 1
param y int = 2
var result = x > y ? 'x is greater than y' : x < y ? 'x is less than y' : x == y ? 'x is equal to y' : '42';
output result string = result
Above snippet would output ‘x is less than y’.
See also
MS docs on Bicep conditional expressions