Skip to content
Discussion options

You must be logged in to vote

@Alastair-Bailey filter() to the rescue! With filter() you can do custom filtering of arrays. In your case, you can filter SiteDetails based on SiteCode and retrieve that one item from the array.

In the Bicep below, you see how to filter the array and set a variable for each value from the object. The first() is used to get the first item from the array. This is because filter() returns an array.

targetScope = 'subscription'

@allowed([
  'UKCH'
  'SGSG'
  'USPT'
])
param SiteCode string = 'SGSG'

param DeploymentDate string = utcNow('y')

param SiteDetails array = [
  { Code: 'UKCH', VNETRange: '10.0.1.0/24', Region: 'EMEA', DataCenter: 'NE', Location: 'northeurope' }
  { Code: 'SGSG', V…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Alastair-Bailey
Comment options

Answer selected by Alastair-Bailey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants