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
- Reading text files with PowerShell and Linux bash shell
- Integrating Microsoft Defender with Cloud App Security
- New from Microsoft: Azure Security Center onboarding guide
- Fixing Azure Key Vault when moving to a different tenant
- Restore Azure Key Vault using just two PowerShell cmdlets