Home > Blockchain >  Add variables and parameters to a bicep deploymentTemplate.json file
Add variables and parameters to a bicep deploymentTemplate.json file

Time:02-15

Looking at the documentation from a deploymentTemplate.json schema file from an arm template we can use variables ([variables('uniqueStorageName')]) and parameters ([parameters('resourceTags')]) inside it so that the template is generic and we can reuse values inside the template.

But the Bicep version seems to be different, looking at the documentation and after testing i don't find a way to do the same.

I know that in the Deployment CLI command we can overwritte the values in the parameters file

# Deploy 
az deployment group create \
  --name myStorageDeployment1 \
  --resource-group rg-bicep \
  --template-file main.bicep \
  --parameters @main.parameters.json \
  --parameters location='centralus'

But my question is instead, if the bicep version of the deploymentTemplate.json has this limits we see on the documenation or is there a way to do the same as the deploymentTemplate.json file used in arm templates?

CodePudding user response:

Bicep isn't different from ARM. It's a language specification that's a wrapper for ARM. All Bicep templates are compiled to ARM before sent to Azure for execution. If you can do something in ARM, then you can do it in Bicep too. There are no limitations there.

param myParameter1 string = 'my default value'

var myVariable1 = 'myValue'

You can also override the parameters the same way.

CodePudding user response:

Well you can't compare the bicep parameter.json to an ARM template .json file. You have to compare a .bicep script with it. https://docs.microsoft.com/en-us/azure/azure-resource-manager/bicep/compare-template-syntax

In bicep the parameter.json is only covering the parameters for the script that you want to set at runtime.

  • Related