We have a main.bicep
file which takes in multiple parameters from azure devops pipeline. The values of the parameters change according the environment where we are deploying.
We call this file from azure-pipelines.yml
file as az deployment group validate --template-file main.bicep --parameters main.bicepparam
. Since this file takes multiple parameters, I don’t want to pass --parameters key=value
multiple times. I don’t want to hard-code the values in the .bicepparam
file as the value can change according to the environment.
Is there a better way to do it? I thought of creating a .bicepparam file for each environment but that involves duplication of parameters in all the files
2
Answers
Answering my solution here since we didnt want to use multiple
--parameter
option.We are using the
readEnvironmentVariable
function in.bicepparam
file and the values are set in azure pipelines. So that we can directly read them from.bicepparam
file and we dont need to pass multiple--parameter
option.You may use AzureResourceManagerTemplateDeployment@3 task. Additionally, it is explained here: Deploy Bicep files – Use Azure Resource Manager Template Deployment task. Use csmFile for your bicep file, csmParametersFile for
main.bicepparam
, and overrideParameters to assign new values for your parameters in the following format: