DEV Community

Cover image for Test Your ARM Templates
Gerade Geldenhuys
Gerade Geldenhuys

Posted on

Test Your ARM Templates

In my previous post, I talked about best practices for ARM templates. Now I want to share with you a neat little tool that we can use for testing these templates.

What is the ARM template test toolkit?

The ARM template test toolkit is a tool we can use to test our deployment templates and ensure that we are developing templates that adhere to best practices. If our templates do not follow these recommended best practices this tool will give us warnings with the suggested changes for us to make.

This tool comes a set of default tests you can find here. Remember, these tests are recommendations, meaning you can pick and choose which tests you want to run.

Installing the Test Toolkit

I am assuming the ttk is still in preview, which is why it hasn’t been added to the PowerShell gallery as of today. Don't stress it though, it takes less that 2 minutes to get it up and running. First, you need to download this zip file. Once it has been extracted, navigate to the 'arm-ttk' folder in PowerShell.

We need to manually add the test toolkit PowerShell Module to our current session, which we do by running the following command:

Import-Module .\arm-ttk.psd1

This command will add the test toolkit module which we can then go ahead and use to test our deployment templates.

Extract the zip file to the PowerShell modules folder (%ProgramFiles%\WindowsPowerShell\Modules). This way, you don’t have to import the test toolkit module as we are doing above. We can then just call the test command from anywhere because this path is already as part of the ‘PSModulePath’.

Test Template

To test a template, we use the Test-AzTemplate command and provide it with the path to our template. This command will all the default test cases against our template. Below is an example of what the results would look like. The results in green are tests that passed and the ones in red failed.

Test Results

That’s it. Now we can ensure that our templates follow recommended best practices.

Continuous Integration

We could even add a step to our build pipeline on Azure DevOps to ensure our templates remain in a good state. All you need to do is add the extension, which you can find here, and add the task to your build.


This is a great tool especially for beginners starting to ARM templates. It will guide you in the right direction because I remember when I first started developing ARM I felt so overwhelmed by everything and if whether my templates are correct or not until I did a deployment and went through all the errors.

I hope this helps you and happy deployment - just not Fridays, please. :-)

Top comments (0)