Test Azure deployments in your VSTS Release Pipeline

pesterWhen deploying Azure Resources you want to know if all resources are deployed as expected. To check if the resources are correctly deployed you can open the portal and visually inspect the deployed recourses or you can also run some powershell to validate the resources. Why not automate these checks and add them to your deployment pipeline. To validate the resources, I extended the Pester Build Task to connect to Azure. A test that checks the deployment of a VM can look like:

Describe "Check deployment" {
    It "has deployed TestVM" {
        Get-AzurermVM | Where-Object { $_.Name -eq "TestVM" }  | Should Not Be $null
    }
    It "TestVM is Size A1" {
        Get-AzurermVM | Where-Object { $_.Name -eq "TestVM" } | Where-Object { $_.HardwareProfile.VmSize -eq "Standard_A1" } | Should Not Be $null
    }
}

Besides adding tests when you check a resource after deployment, go Test Driven Development for the infrastructure deployments. Make the tests before you run your deployment pipeline to check if what is deploy is the same as you expect.

pesterazure
Configure your Pester Azure connection to run tests from a deployment pipeline

One thought on “Test Azure deployments in your VSTS Release Pipeline”

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.