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
- Fixing Azure Key Vault when moving to a different tenant
- Restore Azure Key Vault using just two PowerShell cmdlets
- This overlooked feature in Visual Studio Code can speed release time
- Enabling Front Door managed certificates in Azure: Status update
- How to quickly check the status of all your Azure services