AZ-400 · Question #561
You have an Azure Resource Manager (ARM) template that contains the following expression. [if(parameters('isComplete'), '1a', '2a')] You need to migrate the template to Bicep. Which expression should
The correct answer is D. isComplete ? '1a' '2a'. Explanation Option D is correct because Bicep uses a ternary operator syntax (condition ? trueValue : falseValue) for conditional expressions, so isComplete ? '1a' : '2a' is the proper Bicep equivalent of the ARM template if() function - note that the answer shown omits the colon
Question
Options
- Aiif(isComplete, '1a', '2a')
- Bif(isComplete, '1a', '2a')
- Cif('isComplete') '1a' else '2a'
- DisComplete ? '1a' '2a'
How the community answered
(21 responses)- B5% (1)
- C5% (1)
- D90% (19)
Explanation
Explanation
Option D is correct because Bicep uses a ternary operator syntax (condition ? trueValue : falseValue) for conditional expressions, so isComplete ? '1a' : '2a' is the proper Bicep equivalent of the ARM template if() function - note that the answer shown omits the colon, but the ternary format is the intended pattern. Option A is wrong because iif() is not a valid function in either ARM or Bicep. Option B is incorrect because while if() exists in ARM templates as a function, Bicep does not use function-style if() for inline conditional expressions. Option C is wrong because Bicep does not use an if(...) ... else ... block syntax for inline expressions - that style belongs to imperative languages like C# or JavaScript.
Memory Tip: Think of Bicep as a more developer-friendly language - it borrows the ternary operator (?) familiar from languages like JavaScript and C#, replacing ARM's verbose if(condition, trueVal, falseVal) function syntax. If you see a conditional in Bicep, reach for the ? symbol.
Topics
Community Discussion
No community discussion yet for this question.