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
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s