skip to Main Content

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


  1. Chosen as BEST ANSWER

    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.


  2. 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:

    overrideParameters: -parameter_name1 value1 -parameter_name2 $(value2_from_pipeline_variables)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search