Adding Azure Webjobs to your automated TeamCity deployment (CI)

For a ASP.NET MVC5 project running on Azure we deploy to Azure Websites from our automated builds with TeamCity. It is really awesome to have everything up and running and integrated with our Git repository.
With every pull request the TeamCity builds will execute automatically and on merge it will deploy to our OTAP Azure Website instances and rebuild the testdatabases to do some UI testing.

In other words, I am really happy with everything running automated in the cloud.

Today we added an Azure WebJob to the project to do some background processing. And that broke our automated deployments :-(

I kept getting this error on our Build Agents:

F:\TeamCity\buildAgent\work\66ddeb0d083850a\packages\Microsoft.Web.WebJobs.Publish.1.0.3\tools\webjobs.wap.targets(166,7): error MSB4036: The "GetFileSkips" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\MSBuild\12.0\bin" directory.

I could just build & publish from Visual Studio 2013.... weird..

Of course I went to Google that and found some nice clues to start with:
http://chriskirby.net/deploy-your-webjob-projects-with-your-azure-website-using-continuous-delivery/
http://azure.microsoft.com/blog/2014/08/18/enabling-command-line-or-continuous-delivery-of-azure-webjobs/

After following the advice on these posts, I added the webjobs.props file to both Web and WebJob projects. Followed our process of doing a pull-request and merging it so it would start our deployment.
No luck...

I updated the Microsoft.Web.WebJobs.Publish NuGet package (1.0.3), still no luck...

I then added some arguments to the MSBuild process:

/p:_DestinationType=AzureWebSite 
/p:VisualStudioVersion=12.0

Again... no luck (still the same error :-$)

I ran MSBuild from my development machine with the same commandline arguments.... That worked...

Then I tried some other things like (re)installing the latest version of MSBuild on my build agent, copying the MSBuild files from c:\Program Files (x86)\MSBuild\12.0 to my build agent. I event installed Visual Studio 2013 (4) on my build agent.
All of this didn't solve my problem... Still the same error...

Then I figured out there was one thing different from my machine and the build agent. So I installed the Azure SDK on the build agent.
And: Hooray!! that worked.

Hopefully this post is helping some of you if you run into similar problems with deploying your WebJobs from your TeamCity builds.

Ronald Harmsen

I'm a software developer. When I'm not developing software I'm training & coaching other developers, speaking on a conference or fiddling with some technical stuff.

Arnhem, The Netherlands

Subscribe to Ronald to the cloud

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!