Building Azure webjobs in VSTS

Creating continous deployment in VSTS for a console app to run as an Azure webjob is something I do too seldom so I always tend to forget this crucial information to build it correctly.

If you just add a console app in your solution and run msbuild like this it will not package a zip file for you:

msbuild SampleAgent.sln /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=”d:\repos\SampleAgent\bin\SampleAgent.zip” /p:Configuration=Release

The crucial part is to rembember to add Microsoft.Web.WebJobs.Publish from nuget on your console app project and then you need to do a fake “publish as a webjob” so that VS creates a publish settings.json in properties for you. When you retry the MSBuild it should now create a zip that can be published as an artifact in VSTS and deployed on Azure.

VSTS build solution