Using conditions in ARM templates when deploying infrastructure-as-code

One of my customers asked for a switch to deploy certain Azure resources based on the environment, and the procedure that we are going over on this blog post will explain in detail how to perform this task. It is a useful trick to keep up your sleeve when deploying your infrastructure-as-code (IaC) with ARM templates. First, in the parameters.json (parameters file), we are going to create a parameter called DeployLogAnalytics, and we can set the value to true or false.

In the Azure template file, we are going to define the parameter to create the link with the parameters file. Although I said true or false are possible values, I defined it as a string type, meaning that any value is possible.

The trick is when deploying the desired resource. I like to use the first line to create the condition. We are defining that this resource between {} will be deployed only if the value of DeployLogAnalytics is true. If it is anything else, the resource will not be deployed.

By adding a single line and using a couple of functions, we were able to create some dynamic in the infrastructure-as-code deployment using ARM templates.

Anderson Patricio

Anderson Patricio is a Canadian MVP in Cloud and Datacenter Management, and Office Server and Services, besides of the Microsoft Award he also holds a Solutions Master (MCSM) in Exchange, CISSP and several other certifications. Anderson contributes to the Microsoft Community with articles, tutorials, blog posts, twitter, forums and book reviews. He is a regular contributor here at,, and Anderson (Portuguese).

Published by
Anderson Patricio

Recent Posts

Incident management startups to help you put out the fires

Incident management used to be about debugging code, but in an always-on world the stakes…

3 days ago

Ask Our Readers: Best resources for a Windows expert to learn Linux

Our esteemed Windows expert asks his readers for advice on the best way of coming…

3 days ago

Azure DevOps service connections: How to set them up and use them

Want to make managing RBAC permissions at the subscription/management group level a breeze? Start using…

4 days ago

Update alert: Google patches zero-day Chrome vulnerability

Google has patched a dangerous zero-day vulnerability in its Chrome browser. But now it’s up…

4 days ago

4 startups out to simplify enterprise document management

The document management software market is booming as companies continue their massive migration toward remote…

4 days ago

GDPR two years later: Many successes, but challenges remain

It’s been 2½ years since the GDPR went into effect. While most businesses have adapted…

5 days ago