Running a basic smoke test after a deploying a website using Powershell

The problem:

You have automated a deployment of an ASP.NET website to Azure (App Service), using Visual Studio Team Services (VSTS). Deployment went fine (no errors) but when you try to access the website you get an runtime error such as the following:


You must be thinking that I should run some smoke tests after the deployment to detect problems like this one, and you’re absolutely right. But, believe me or not, there are still a lot of companies that have no unit tests or just a few – let alone integration/smoke tests!  Believe me, I’ve been there 🙂

In that case, there are quick and easy ways to run some sort of smoke tests. For example, you can configure a Powershell task as follows:

In short, Invoke-WebRequest sends an HTTP request to a web page (defined in the $(HomePage) variable). If the page returns a 500 error the Powershell task and consequently the deployment will fail:


Deployment log:


That’s it! As a final note, the task configured above contains inline script, which should be avoided (I did it for demonstration purposes only). All source code, scripts,configuration, etc should be under source control.