Skip to content

Bicep: parsing error with lambda functions #7311

@svwie

Description

@svwie

Describe the issue
Using bicep lambda functions will cause parsing error. Seems like => is causing this.

Microsoft documentation: Lambda functions for Bicep

These functions are crucial in Bicep to generate and manipulate array output due to ARM limitations with for each loops when referencing resource output. Without lambda functions we need to implement workarounds with submodules for array manipulation which is rather unpleasant.

Example Value (as of MS documentation)

var dogs = [
  {
    name: 'Evie'
    age: 5
    interests: ['Ball', 'Frisbee']
  }
  {
    name: 'Casper'
    age: 3
    interests: ['Other dogs']
  }
  {
    name: 'Indy'
    age: 2
    interests: ['Butter']
  }
  {
    name: 'Kira'
    age: 8
    interests: ['Rubs']
  }
]

output dogNames array = map(dogs, dog => dog.name)
output sayHi array = map(dogs, dog => 'Hello ${dog.name}!')
output mapArray array = map(range(0, length(dogs)), i => {
  i: i
  dog: dogs[i].name
  greeting: 'Ahoy, ${dogs[i].name}!'
})
output mapArrayIndex array = map(dogs, (x, i) => { index: i, val: x.name})

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions