-
Notifications
You must be signed in to change notification settings - Fork 818
Description
Bicep version
Bicep CLI version 0.29.47 (132ade51bc)
Describe the bug
To reduce duplication, I attempted to dynamically build a parameter in a .bicepparam file using vars, [for]s, and array functions which appears to be valid according to documentation. However it resulted in error:
Failed to evaluate parameter "<foo>": Unhandled exception during evaluating template language function 'variables' is not handled. bicep(BCP338)
To Reproduce
deploy.bicep
@export()
type FleetConfig = {
namePrefix: string
sku: string
capacity: int
clusteringPolicy: ClusteringPolicy
}
param testMatrix FleetConfig[]
output testMatrixdeploy.bicepparams
using './deploy.bicep'
var matrix = [
{
namePrefix: 'e10impactx4'
sku: 'Enterprise_E10'
capacity: 4
}
{
namePrefix: 'e10impact'
sku: 'Enterprise_E10'
capacity: 2
}
{
namePrefix: 'e5impactx4'
sku: 'Enterprise_E5'
capacity: 4
}
{
namePrefix: 'e5impact'
sku: 'Enterprise_E5'
capacity: 2
}
]
var type1 = [for item in matrix: {
namePrefix: item.namePrefix
sku: item.sku
capacity: item.capacity
clusteringPolicy: 'EnterpriseCluster'
}]
var type2 = [for item in matrix: {
namePrefix: '${item.namePrefix}-ent'
sku: item.sku
capacity: item.capacity
clusteringPolicy: 'OSSCluster'
}]
param testMatrix = concat(type1, type2) // <- doesn't workAdditional context
Basically, I wanted to build a test matrix input where all items had the same properties except for clusteringPolicy. I tried restructuring the above lots of ways, but none of them worked 😢 In the end I had to manually copy/paste/update.
Note, though, that the following does work:
var matrix = [
{
namePrefix: 'e10impactx4'
sku: 'Enterprise_E10'
capacity: 4
}
{
namePrefix: 'e10impact'
sku: 'Enterprise_E10'
capacity: 2
}
{
namePrefix: 'e5impactx4'
sku: 'Enterprise_E5'
capacity: 4
}
{
namePrefix: 'e5impact'
sku: 'Enterprise_E5'
capacity: 2
}
]
param textMatrix = concat(matrix, matrix)So it doesn't seem to be a fundamental limitation of .bicepparam files. (The ability to concatenate arrays.) The system just doesn't like when I try to dynamically build the different sub-arrays with a [for] loop.
Metadata
Metadata
Assignees
Type
Projects
Status