Rob Bowman
Rob Bowman

Reputation: 8741

Reference object variable in Bicep template

I'm currently trying to manually convert an existing ARM template to bicep because the automated decompile method fails.

The existing template contains the following variables:

"environmentSize": {
        "dev": "small",
        "msdn": "small",
        "int": "small",
        "act": "large",
        "prod": "large"
    },
    "size": "[variables('environmentSize')[parameters('environment')]]",

What would be the equivalent with Bicep?

I've tried the following but it's clearly wrong as I get a red squiggly below the $:

var environmentSize = {
  dev:'small'
  msdn:'small'
  int:'small'
  act:'large'
  prod:'large'
}
var size = environmentSize.${environment}

Upvotes: 0

Views: 1424

Answers (1)

Thomas
Thomas

Reputation: 29736

Using brackets notation should work.

param environment string = 'dev'

var environmentSize = {
  dev:'small'
  msdn:'small'
  int:'small'
  act:'large'
  prod:'large'
}

output size string = environmentSize[environment]

Upvotes: 2

Related Questions