Deploying and Schedule Azure WebJobs from VSTS to Azure Web App (With bonus CRON Scheduling)

WebAPI apps with WebJobs schedules are currently the intuitive way to work with Web Apps.
In this article, I am going to show you how to deploy a WebApp along with Web Jobs, and as an added bonus, use Azure’s internal CRON Scheduler to schedule the WebJobs. Sweet! Let’s get started.

We already have this blog that shows how to publish a Web App from VSTS. We’ll expand on that.

Add a New Azure WebJob Project

Create a new Azure WebJob Project, File->Add->New Project


You could set up the schedule for this,


This creates a webjob-publish-settings.json file



"$schema": "",

"webJobName": "WebJob",

"startTime": null,

"endTime": null,

"jobRecurrenceFrequency": null,

"interval": null,

"runMode": "OnDemand"


This will use Azure Scheduler Services to schedule the job.


Going back to our build definition from this, let’s add another task for Azure Web App Deployment for the WebJob,
Modify the MSBuild Arguments as follows, removing, [/p:PackageAsSingleFile=true].

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.stagingDirectory)"

So, in the artifact drop, we will get 2 WebDeploy Packages, one for the Web App and the other for Web Job.

We should be good to go, let’s queue a build.



Post build, you’ll notice that separate zip files are created,


Let’s check our Web App on Azure Portal,


Simple as that, the WebJob automatically is placed under the appropriate place, automatically.


BONUS! (Using CRON Scheduler)

If you’re familiar with the CRON Scheduler, or want more flexibility in scheduling, Azure has an internal CRON Scheduler, that can be used,

Note: This technique is available to Web Apps running in Basic, Standard or Premium mode, and requires the Always On setting to be enabled on the app.

For this to work, simply create a file called Settings.job


For instance, to trigger the WebJob every 15 minutes, your settings.job would have:


"schedule": "0 */15 * * * *"



Now as part of the build this file must also be packaged to the Web Deploy package of the Web Job.
To do that, ensure this file is copied to the Build Output Directory.


There you go! You now have a custom scheduled WebJob using CRON Expression as well.


Content: Manigandan B
Review: Venkat NA


Comments (15)
  1. Martin Power says:

    I have the same setup as you in this example where my build definition contains a webApp and a webJob. If the deployment order has the webAPp first and the webjob second, it seems some bin files get deployed and overriden from the webjob deployment, causing an error when browsing the webapp.

    1. If you feel that the files are being overridden, please check the Set DoNotDeleteFlag. That should stop removing files.

      1. neha says:

        I am facing same issue ..If deployment order has the webapp first and webjob second bin files from webjob package is getting deployed which is causing error when browsing web app.. I have already checked DoNotDeleteFlag

        1. Hi Neha,

          I just created a new build with a WebApp that has 3 webjobs. It automatically deploys all the webjobs on seperate directories. I even used a single deployment task to do this (just the webapp)
          With the support ticket you already have with us, we will get in touch with you for a discussion soon.

  2. Tim Norris says:

    Hey – thanks for this. I have a single build step as you have, that builds the solution with the webapp and the webjob. I’ve removed the ‘PackageAsSingleFile’ flag from the build arguments. The webapp deployment step successfully executes first, but when the webjob deployment step executes it complains:

    Cannot update deployment status for demowebapp – {“Message”:”Deployment with id ’50’ exists”}

    It also seems to ‘overwrite’ the webapp – I no longer seem to be able to get content from it.
    However, the webjob does seem to be deployed.

    I can’t seem to get them both to deploy together.

    Any ideas??

    1. It doesn’t quite work well if you do a single packaging. That’s why, we package it separately, use different deployment steps for each web app and web job.

  3. Prakash says:

    I am not able to schedule the jobs .My web jobs always configured as On-Demand jobs instead of scheduled jobs. My website runs in standard and I have enabled always-on as well.

    1. Prakash says:

      I have found that the batch job runs every 15 minutes as per the scheduled time.The problem is , eventhough the batch job is scheduled in the mamagement portal it still shows as the On-Demand process.


      1. Hi Prakash,
        It’s because the system will not know that it uses CRON scheduling in the background.
        It will only recognize the azure scheduler and it’s schedules.

  4. Javier Hertfelder says:

    Hi, I am trying to follow your post but the problem is that the WebJob does not get deployed into the artifacts folder, only the WebApps are being deployed. I am using Azure WebJob 2.0.0 and seems like the Build step only create zips for WebApps

    1. Rob says:

      Javier, I’m having the same issue. Did you ever find a solution?

    2. sanath says:

      i am having the same issue

    3. Manaus Lavens says:

      I had the same issue…
      Installing the nuget Microsoft.Web.WebJobs.Publish solved the problem.
      However, I am wondering if there is way to get this working without the publish package?

  5. Martin Ushima says:


    I have a app service which contains a website and a web API (using virtual apps) and 2 webjobs. Everytime the deployment has finished, only one webjob is deployed (the last one replaces the first).

    Is there any other setup that should be made in order to get it working?

  6. sanath says:

    i am not getting 2 files creating in stagingdirectory after remove singlefile=true from msbuild arguments.
    please let me know what possible reson so i m not getting thngs done

Comments are closed.

Skip to main content