12
votes

When I publish a site on existing one where I created multiple webjobs, this deletes all the files on server and all the web jobs are deleted.

I assume this is because webjobs are stored in App_Data folder. When the APP_Data directory is deleted, the jobs are deleted.

How can I avoid deleting the app_data folder when doing a publish?

3

3 Answers

9
votes

A third option to Andy's answer would be to deploy you WebJobs with your website, just make sure the WebJobs scripts go to the right place which is under app_data\jobs\{job type: continuous/triggered}\{job name}.

See more about deploying WebJobs: http://blog.amitapple.com/post/74215124623/deploy-azure-webjobs/

7
votes

I noticed this as well and can offer the solutions I came up with.

If you are publishing from Visual Studio you can deselect the file publish option "Remove additional files at destination". Of course you are now no longer deleting unused files on the server which probably isn't ideal.

The other option is to simply create a second website just for your webjobs. You can leave the site blank, you don't need to publish anything to it or configure anything beyond the webjobs. One advantage to this approach is you can monitor (and potential scale) the webjobs site separately from your original website.

4
votes

The solution I found was to exclude publishing to the App_Data folder.

If you are publishing using web deploy from Visual Studio 2013, you can enable this option as follows:

  1. Right-click on the web project.
  2. Click Publish...
  3. Click on Settings
  4. Expand File Publish Options and check Exclude files from the App_Data folder
  5. Close and save changes.