


Now, run the test script and you will see the result like this: It looks simple because I use it for Logic App deployment, but if you deploy an Azure VM or App Service instance, or something else, it would be more complex and there would be more behaviours to test. In order to validate ARM template in Azure CLI, here’s the command:Īs you can see, the $output variable stores the validation result converted into a JSON object, then check whether the deployment behaviour is expected or not. In addition to that, Azure CLI can also run on PowerShell! So, this time, we’re using Azure CLI for ARM template testing. On the other hand, Azure CLI returns an error object, even if there is an error, which we can gracefully handle errors. This is somewhat true, but as you know, PowerShell is not as good as error handling. So, it’s easy to think we can use PowerShell for testing, with this cmdlet Test-AzureRmResourceGroupDeployment. Pester is a PowerShell-based test framework. The code sample can be found at Testing ARM Templates Azure CLI
#Pester testing how to
In this post, I’m going to show how to test ARM templates in the build pipeline.

This post, Test Azure deployments in your VSTS Release Pipeline, talks about after resource deployment in the release pipeline, but not in the build pipeline. To be honest, it’s not that intuitive for this, especially as we need to run test before the resource deployment. However, I was actually asked many times how I did it on Visual Studio Team Service (VSTS). At the end of the post, I also briefly mentioned how we can integrate this testing into our CI/CD pipeline. In my previous post, Testing ARM Templates with Pester #1 – PowerShell, I showed how to test behaviours ARM template deployment without actual deployment.
