How to prevent Azure WebJob from starting after publishing?

We have an Azure Website setup with an “intermediate” slot for deployment, and we use continuous Azure WebJob to handle long background jobs. It appears that when you publish to the Website (and include WebJob binaries), WebJob will restart if it was previously stopped.

Our current deployment process is as follows:

  • Deployment for STAGING
  • Stop WebJob immediately and quickly. STAGING (try to prevent the processing of 2 WebJobs messages)
  • Smoke test and check the code when performing STAGING operations
  • Stop the PRODUCT web application (let it clear the queue messages)
  • Exchange between PRODUCTION AND STAGING
  • Launch Producation WebJob (which was only STAGING WebJob).

Is there a trick (say, a flag file or something else) to tell WebJob to NOT run after publication?

+14
source share
3 answers

To deploy a continuous WebJob in a stopped state, simply add a file with a name disable.jobto the root of your WebJob (binaries), this will show the infrastructure that the web application is currently stopped.

To view this behavior, you can simply stop the continuous WebJob and see that this file is generated and placed in the WebJob directory.

+19
source

You can add an application parameter WEBJOBS_STOPPEDto your intermediate segment and set it to 1. Make this Slot option so that it is not replaced by production.

+14

AFAIK, there is no ready-made solution for this. However, you can set the application parameter and check the webjob code when it starts. Alternatively, you can use a variable HTTP_HOSTto define the environment.

0
source

Source: https://habr.com/ru/post/1569047/


All Articles