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
- Using location in a consistent way in your ARM template parameters
- Removing Log Analytics with the soft-delete option
- Using conditions in ARM templates when deploying infrastructure-as-code
- Monitor your Azure VM from your mobile device by scanning a QR code
- Switching shells using command line in Cloud Shell