A web job can be deployed with web deploy in Visual Studio to Azure very easily. Getting a web job packaged with VS Web Application is equally simple and straight forward.
To package WebJobTest console application to the deployment package created with WebJobApp web application can be done using VS publish.
Web job getting packaged to deployment package.
A TFS Build can be defined to build the package. More information on setting up a TFS build to create web deploy package refer the post “How to Deploy to Azure Websites with TFS build 2013 and VS Release Management 2013”.
Web deployment package created with TFS Build.
But the web deployment package created with TFS build does not contain the app_data folder and the jobs in it.
Instead it is getting created as a separate package in build drop.
Investigations done in WWW pointed to below useful suggestions but none worked with TFS build as explained in them.
This issue is discussed in this forum post with Visual Studio Online.
However when tried building with msbuild locally with deploy arguments successfully packaged the web jobs into the Web Application deployment package.
With that knowledge, as a workaround (It really works :)), set the TFS Build to build to output as configured. This will build the solution with TFS Build outputs in to the local folder of the build agent, which would allow the jobs to be packaged into the web deployment package.
The next problem is getting the built package to the output folder. For that the https://tfsbuildextensions.codeplex.com/SourceControl/latest#Scripts/GatherItemsForDrop.ps1can be modified and used. Modified script is below.
Check the above script to TFS and use it in the build definition.
WebJobApp package created in build drop.
Now the TFS Build successfully packaged the jobs to the WebJobApp deployment package.
A release management template as explained in “How to Deploy to Azure Websites with TFS build 2013 and VS Release Management 2013” can be created to deploy the WebJobApp to Azure including the web job.
A new website created in Azure.
Release template created.
Creation of above tool is explained in “How to Deploy to Azure Websites with TFS build 2013 and VS Release Management 2013”
Set deploy parameters from publish profile of the Azure web application.
A release triggered with the template using the TFS build.
Job deployed with Web Application.
Web Application and the job deployed.