How to Run a Continuous WebJob as a Singleton
If your Azure Web Sites site is running on multiple instances and you create a new continuous WebJob, the WebJob will run on all instances by default. (Note that a triggered WebJob will run on just one instance selected at random.) You may want your continuous WebJob to run on only one instance. You can do so by creating a file called settings.job and adding the following to it:
{ "is_singleton": true }
After you’ve added this line, save the settings.job file into the root folder for the continuous WebJob.
Alternatively, you can use the WebJobs API to do the same. There’s more information available on this at GitHub.
Comments
Anonymous
July 28, 2014
I feel as it is the only other setting in: github.com/.../JobSettingsKeys.cs "stopping_wait_time" deserves a mention, blog.amitapple.com/.../webjobs-graceful-shutdownAnonymous
May 07, 2015
I have deployed a Azure Web Job which listens to a Queue and then process the message received. When i run it locally, it runs perfectly well; but i deploy to Azure it exits with code -2146232576. [05/08/2015 13:28:42 > cb5dfe: SYS INFO] Run script 'CertsInvoicesJob.exe' with script host - 'WindowsScriptHost' [05/08/2015 13:28:42 > cb5dfe: SYS INFO] Status changed to Running [05/08/2015 13:28:43 > cb5dfe: SYS ERR ] Job failed due to exit code -2146232576 [05/08/2015 13:28:43 > cb5dfe: SYS INFO] Process went down, waiting for 60 seconds [05/08/2015 13:28:43 > cb5dfe: SYS INFO] Status changed to PendingRestart When is the thing i am doing wrongly. What does this code mean. Please help!!!Anonymous
September 26, 2016
This works but requires a couple of additional steps.-Modify the properties of the file and set the:---Build Action = Content---Copy to Output Directory = Copy alwayscredit to Dave http://blog.devdave.com/2015/12/singleton-azure-webjob.htmlAnonymous
January 23, 2017
Is the preferred method to now use the SingletonAttribute instead of the settings.job file?https://github.com/Azure/azure-webjobs-sdk/wiki/Singletonhttps://github.com/Azure/azure-webjobs-sdk/blob/master/src/Microsoft.Azure.WebJobs/SingletonAttribute.cs