When working with multiple environments in Azure DevOps pipelines, one of the approaches is to have a parameter file for each environment. The code itself will be the same, and we tweak the ending result by changing the parameters file that matches the environment. In the image depicted below, we have our security.json, which is the ARM template with the code, and we have the parameters file named security.prod.json, where the prod string is the one that defines the environment.
When creating your Azure DevOps pipelines, if we label our stages correctly with the environment name, we can leverage it when defining the template parameters section. When we copy and paste stages, it will always work, as long as we change the stage name to match the string on our parameter files.
To reference the stage name, use $(Release.EnvironmentName).
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