Closed dmgonch closed 1 year ago
Description of the issue
Here is the bicep that reproduces the issue:
param location string = resourceGroup().location var things = { THE_ONLY_THING: 'the_one' } var tasks = [ { name: 'process-thing' parameters: union( length(things) != 1 ? { Things1Name: '!!! UNEXPECTED_NAME !!!' Things1Value: '!!! UNEXPECTED_VALUE !!!' } : {}, length(things) == 1 ? { Things1Name: items(things)[0].key Things1Value: items(things)[0].value } : {} ) } ] resource taskDeployment 'Microsoft.Resources/deployments@2020-10-01' = { name: 'name' location: location properties: { mode: 'Incremental' parameters: { tasks: tasks thingsCount: length(things) } } }
To Reproduce
Steps to reproduce the issue:
bicep build bug.bicep; powershell -noprofile Export-AzRuleTemplateData -TemplateFile bug.json -OutputPath bug1-export.json
Expected behaviour
Expected the following parameters to be generated:
{ "mode": "Incremental", "parameters": { "tasks": [ { "name": "process-thing", "parameters": { "Things1Name": "THE_ONLY_THING", "Things1Value": "the_one" } } ], "thingsCount": 1 } }
Error output Instead the following JSON is generated:
{ "mode": "Incremental", "parameters": { "tasks": [ { "name": "process-thing", "parameters": { "Things1Name": "!!! UNEXPECTED_NAME !!!", "Things1Value": "!!! UNEXPECTED_VALUE !!!" } } ], "thingsCount": 12 } }
Module in use and version:
Captured output from $PSVersionTable:
$PSVersionTable
Name Value ---- ----- PSVersion 5.1.22621.963 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.22621.963 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
Additional context The workaround appears to be to use
length(items(things))
@dmgonch Thanks for the repro.
Description of the issue
Here is the bicep that reproduces the issue:
To Reproduce
Steps to reproduce the issue:
Expected behaviour
Expected the following parameters to be generated:
Error output Instead the following JSON is generated:
Module in use and version:
Captured output from
$PSVersionTable
:Additional context The workaround appears to be to use