Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.2k stars 742 forks source link

Support to process parameter with non constant name #2536

Closed saurabh-mridul closed 3 years ago

saurabh-mridul commented 3 years ago

Bicep decompile is giving error while interpreting the variable having non constant name as below variableA = [parameters(concat('Ring', parameters('ringNumber'), 'ClientId'))]" its working with ARM templates as there are dedicated parameters being passed for specific values. this is to achieve logic for having switch statements in case application is having more than 2 rings.

alex-frankel commented 3 years ago

Can you share the full template?

saurabh-mridul commented 3 years ago

here is the template -

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {    
    "Ring0ClientId": {
      "type": "string",
      "defaultValue": "ABC"
    },
    "Ring1ClientId": {
      "type": "string",
      "defaultValue": "XYZ"
    },
    "Ring99ClientId": {
      "type": "string"
      "defaultValue": "MNP"
    }
  },
  "variables": {
    ringClientId = [parameters(concat('Ring', parameters('ringNumber'), 'ClientId'))]"
  },
  "resources": [ 

    ]
}
majastrz commented 3 years ago

Would you be able to work around this limitation by passing in a complex object or a complex array via a single parameter?

We do support indexing objects by the property name strings which themselves can come from expressions. Indexing arrays by an index that comes from an expression is also supported.

saurabh-mridul commented 3 years ago

surely, it's just a gap with bicep and if you all can address this... would be charm to be on par.