Request: Allow multiple objects within loops
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
I have an array of domains for which I'm setting up routing rules in Application Gateway so requests to those domains will go to the appropriate backends.
This is easily done with something like:
```
param domains array = [
'example.com'
'thisthat.com'
]
resource AppGateway 'Microsoft.Network/applicationGateways@2021-05-01' = {
name: 'AppGw01'
//...
properties: {
httpListeners: [for (endpoint, index) in domains: {
name: domain
properties: {
//...
}
}
}
}
```
Unfortunately, in App Gateways, you cannot create an HTTP Listener for both an HTTPS and an HTTP endpoint - it must be one or the other and this is where my request would come in handy. Today I'm limited to looping through the domains list a single time and specifying a single object within the loop for each element.
But in the case of both HTTP Listeners and Request Routing Rules, it would be awfully useful to be able to set multiple elements at a time each loop, for example, something like:
```
httpListeners: [ for (endpoint, index} in domains:
{
name: '${domain}-https'
properties: {}
}
{
name: '${domain}-http'
properties: {}
}]
```
This way, I can loop through the elements once without difference from today, but I can also create more than just a single element for each in my array. Otherwise, today I can do nothing but change how I structure the array to pass in values and that can be quite inconvenient.
Thanks for the consideration!
Contributor guide
Research direction
Start by tracing Bicep's array-comprehension and loop syntax, then compare the requested HTTP and HTTPS listener examples with the current language behavior. Define how one loop iteration can produce multiple objects, including validation and diagnostics, and add coverage showing that both listener objects are emitted for each domain.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- cloud
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100