When planning your infrastructure-as-code (IaC) process, we have a variety of ways to deploy several environments from a single source code. Some people will use different “parameters.json files,” others will use pipeline variables, and there are plenty of ways to get the work done. In this article, I will show the combination of parameters and variables in the ARM template. The interesting portion of this method is that I’m going to receive a single parameter called environment, and based on the parameter, I will use a specific variable. Look at the code below, where I introduced the environment and the v_DEV_sample.
When referencing the variable we can use [variables(concat('v_',parameters('environment'),'_Sample'))] and that allows us to construct the variable using a parameter file. Let’s imagine that I had a variable for UAT called v_UAT_sample. As long as I pass the right environment, I will get a different value.
In that case, I was deploying a web app, and just for fun, I created a new application setting and used that variable that we defined during execution time -- and the result is the proper value for the DEV environment.
More Quick Tips articles
- How to delete a sprint when using Azure DevOps
- IaaS VM ‘cheat sheets’ available in Azure Portal
- Finding Azure locations with PowerShell
- Check if Azure Key Vault certificate uses exportable private keys
- Managing access to your Azure invoices