none
How to Stop/Disable Azure WebJob using C# code?

    Question

  • Hello, I am looking for a programming snippet where I can stop or disable the azure web job using C# code.

    I am able to find some thing mentioned here http://blog.logiticks.com/post/2015/04/30/programmatically-custom-invoke-azure-web-job-using-c

    but this code doesn't stops or disable the WebJob. Kindly share some reference/solution to my problem?

    regards,

    Shobhit

    Tuesday, June 02, 2015 1:47 PM

Answers

  • My previous reply was on stopping the WebJob from inside the Website/WebJob.

    To stop the WebJob from an external client you just need to make a REST call: https://github.com/projectkudu/kudu/wiki/WebJobs-API#stop-a-continuous-job

    POST https://{sitename}.scm.azurewebsites.net/api/continuouswebjobs/{job name}/stop

    With basic auth using your deployment credentials.

    Tuesday, June 02, 2015 4:25 PM
  • Can you tell us which type of WebJob you are trying to stop?

    For continuous, you can do it simply by putting a file called "disable.job" in the root of the WebJob directory (without content).

    To start the WebJob again simply remove this file.

    You cannot directly stop a triggered WebJob, your options are to go to the process explorer (https://{sitename}.scm.azurewebsites.net/ProcessExplorer) and kill it or restart the website (update an app setting).

    Amit

    Tuesday, June 02, 2015 4:04 PM

All replies

  • Hi Shobhit,

    Option below is not a C# code snippet but an alternate option which serves the same purpose of stopping / disabling the Web job.

    In configuration settings, there is an option to Set the Application Variable: WEBJOBS_STOPPED = 1 to disable running any job (this will also stop all currently running jobs). For details, see configuration settings in Webjobs

    Also to start or stop a continuous WebJob, right-click the WebJob in the list and click Start or Stop. See details here.

    Regards,

    Shirisha Paderu

    Tuesday, June 02, 2015 2:17 PM
    Moderator
  • Can you tell us which type of WebJob you are trying to stop?

    For continuous, you can do it simply by putting a file called "disable.job" in the root of the WebJob directory (without content).

    To start the WebJob again simply remove this file.

    You cannot directly stop a triggered WebJob, your options are to go to the process explorer (https://{sitename}.scm.azurewebsites.net/ProcessExplorer) and kill it or restart the website (update an app setting).

    Amit

    Tuesday, June 02, 2015 4:04 PM
  • My previous reply was on stopping the WebJob from inside the Website/WebJob.

    To stop the WebJob from an external client you just need to make a REST call: https://github.com/projectkudu/kudu/wiki/WebJobs-API#stop-a-continuous-job

    POST https://{sitename}.scm.azurewebsites.net/api/continuouswebjobs/{job name}/stop

    With basic auth using your deployment credentials.

    Tuesday, June 02, 2015 4:25 PM