Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent Azure WebJob from starting up after publishing?

We have an Azure Website setup with a "staging" deployment slot, and we use a continuous Azure WebJob to process long-running background jobs. It appears that when you publish to the Website (and include the WebJob binaries), that the WebJob will restart itself if it was previously stopped.

Our current deployment process looks like the following:

  1. Deploy to STAGING
  2. Immediately & Quickly stop the WebJob on STAGING (try to prevent 2 WebJobs from processing messages)
  3. Smoke test and verify code on STAGING works
  4. Stop the PRODUCTION WebJob (let it drain off queue messages)
  5. Swap between PRODUCTION and STAGING
  6. Start the PRODUCTION WebJob (which was just the STAGING WebJob)

Is there a trick (say a flag file or something) to tell a WebJob NOT to start up after publishing?

like image 782
ericb Avatar asked Jul 01 '14 14:07

ericb


People also ask

How do I stop Azure triggered WebJob?

There is however an easier way to do this via Application Settings inside the Configuration section of our App Service where the WebJobs are located. WEBJOBS_STOPPED – setting this to 1 will disable all jobs, and will also stop any jobs that are currently running.

What is difference between WebJob and azure function?

Summary. Azure Functions offers more developer productivity than Azure App Service WebJobs does. It also offers more options for programming languages, development environments, Azure service integration, and pricing. For most scenarios, it's the best choice.


1 Answers

To deploy a continuous WebJob in a stopped state simply add a file called disable.job at the root of your WebJob (binaries), this will tell the framework that the WebJob is currently stopped.

To view this behavior you can simply stop a continuous WebJob and see that this file is generated and placed at the WebJob's directory.

like image 67
Amit Apple Avatar answered Jan 14 '23 21:01

Amit Apple