Migrating the ARM if() Expression to a Bicep Ternary Conditional Operator
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 you run?
Community Votes
68% of anonymous learners picked answer D. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
Bicep expresses conditionals with the ternary conditional operator, so the migration is a variable assignment of isComplete ? '1a' : '2a'. The Bicep if keyword is only for conditionally deploying a resource, not for producing a value, and iif remains an ARM-only function.
An ARM template contains the expression if(parameters('isComplete'), '1a', '2a') and must be migrated to Bicep. Bicep is not a direct translation of the ARM template language, so the conditional construct has to be rewritten using Bicep's own operator rather than carried over as a function call.
Carrying the ARM function form across as iif(), which is an ARM template function with no Bicep equivalent, or writing if(isComplete, '1a', '2a'), which is neither valid Bicep value syntax nor a valid conditional-resource declaration.
Community Discussion (9 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
Bicep is not a syntactic superset of the ARM template language, so an ARM conditional cannot be copied across. The ARM expression if(parameters('isComplete'), '1a', '2a') returns a value, and in Bicep a value-producing conditional is written with the ternary conditional operator, so the migration is isComplete? '1a': '2a'. The option in the question is missing its colon, which several commenters identified as an OCR or export defect rather than a substantive disagreement. The vote was 68 for D, with 16 for C and 16 for A. Yameo, the highest-liked commenter, ruled out C and endorsed D while noting the missing colon, and Gooldmember, Christian_garcia_martin, and Dankho all reached the same conclusion, with Dankho phrasing it as all the other options being wrong.Why the Other Options Are Wrong
The expression iif(isComplete, '1a', '2a') (A) is the ARM template function form, and iif is an ARM capability rather than a Bicep function, so it does not exist in the target language. maqsoodshah selected A but the reasoning is self-defeating, since the same comment concedes that the conditional operator form is the correct Bicep syntax and recommends adding the colon to the ternary. The expression if(isComplete, '1a', '2a') (B) uses the if keyword as though it were a function returning a value, which is not valid Bicep. The form if('isComplete') '1a' else '2a' (C) mixes an if statement with an else clause that Bicep does not have, and 8fc2e85 dismissed D on syntax grounds while proposing exactly the ternary form that D represents. schwagalla supplied the authoritative clarification, noting that in Bicep if is only used with a resource to conditionally deploy it and cannot assign a string to a variable.Community Comment Notes
The community was decisive at 68 votes for D, and the discussion focused on a single defect rather than the concept. Yameo, with seven likes, stated that C is incorrect and D is the only possibility but the colon is missing. schwagalla linked the Bicep functions documentation and explained why there is no if function with an else block in Bicep, that if is only for conditionally deploying a resource, which is the fact that eliminates both A and B. Four separate commenters independently noticed the missing colon, and Gooldmember phrased it as D being correct if you imagine the colon added. The only dissent, 8fc2e85, argued against D on syntax grounds while proposing the same ternary operator with the colon, so the dissent actually confirms the intended answer.Official Reference
Related Analysis
Practice All AZ-400 Questions
Access 100 questions with complete answers and detailed explanations.
View Full AZ-400 Practice Test →