Azure / Azure/bicep

Non top-level variable loops are blocked by the Bicep compiler

Open
#2,901 0 comments 0 reactions 1 assignee Claimed by @majastrz View on GitHub
bug
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Bicep version**
Latest

**Describe the bug**
Non top-level variable loops are blocked by the Bicep compiler.

**To Reproduce**
Steps to reproduce the behavior:
```bicep
param itemCount int = 5
var topLevelObject = {
  sampleProperty: 'sampleValue'
  disks: [for j in range(0, itemCount): {
    name: 'myDataDisk${(j + 1)}'
    diskSizeGB: '1'
    diskIndex: j
  }]
}
```

**Additional context**
Original JSON that worked:
```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"itemCount": {
"type": "int",
"defaultValue": 5
}
},
"variables": {
"topLevelObject": {
"sampleProperty": "sampleValue",
"copy": [
{
"name": "disks",
"count": "[parameters('itemCount')]",
"input": {
"name": "[concat('myDataDisk', copyIndex('disks', 1))]",
"diskSizeGB": "1",
"diskIndex": "[copyIndex('disks')]"
}
}
]
}
},
"resources": [],
"outputs": {
"objectResult": {
"type": "object",
"value": "[variables('topLevelObject')]"
}
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.