Azure / azure-webjobs-sdk

Azure WebJobs SDK
MIT License
738 stars 358 forks source link

Howto deploy WebJob with DevOps #2166

Open enterprisebug opened 5 years ago

enterprisebug commented 5 years ago

I am experiencing a new behaviour when deploying a WebJob manually.

Repro steps

  1. Upload is done using Azure Portal: 2019-04-08 12_34_08-Add WebJob - Microsoft Azure

Expected behavior

Job is deployed under /site/wwwroot/App_Data/...

Actual behavior

The job gets deployed in a folder called "jobs" which is directly under "wwwroot". This is new to me. 2019-04-08 12_16_24-Diagnostic Console

Question

essmd commented 5 years ago

This new jobs folder under „sites“ is available since „Run-From-Package/Zip“. Run-From-Packe or Run-From-Zip is a feature where your WebApp (as *.zip) is uploaded to a blob? store and then finally the wwwroot folder mounted/linked to that zip. This should be faster, prevent lock(ed) files etc. The side effect of this deployments is, that the wwwroot folder is then „read-only“. It would not be possible to upload/add a WebJob to the read-only wwwroot. I read that info when i was testing and playing with the new Run-From-Zip deployment method.

As we are using separate App Services for web and jobs (within the same service plan), i can not tell you how to deploy the job into this „new“ jobs folder - we are continue deploying into wwwroot/App_Data/jobs

Maybe MS Portal is just using the new jobs folder always, because it works for every scenario/deployment method.

So if you are not using RunAsPackage/Zip, you can deploy the job from Azure DevOps into the known App_Data/jobs folder (at the same time as the webapp) or separate (before/after) the WebApp has been deployed. I recommend to deploy it after and be careful with „Exclude App_Data“ as this will result in an empty deployment (jobs are in App_Data).

hope this helps a bit!

Some links with further information:

GA Release Announcement https://github.com/Azure/app-service-announcements/issues/110

Documentation (for Azure Functions¹) https://docs.microsoft.com/en-us/azure/azure-functions/run-functions-from-deployment-package

¹ - Everything described here applies equally to Web Apps and Function Apps. It applies to App Service on Windows, but not on Linux (from the announcement above)