Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Continuous WebJob as Singleton?

I've seen some guidance around using settings.job to set the WebJob as singleton but it's not working - in the console, I see:

 WebJob singleton setting is False

How can I go about preventing scale-outs from running multiple instances of my WebJob?

like image 434
SB2055 Avatar asked Oct 19 '25 09:10

SB2055


2 Answers

As far as I know, to set a continuous job as singleton, we could create a file called settings.job with the content: { "is_singleton": true } and put it at the root of the WebJob directory. And we could get continuous job settings to make sure whether it is singleton.

GET /api/continuouswebjobs/{job name}/settings

enter image description here

in the console I see: WebJob singleton setting is False

Please use Kudu tool to check whether the settings.job is existing at the root of the WebJob directory and the actual value of is_singleton property.

like image 65
Fei Han Avatar answered Oct 22 '25 08:10

Fei Han


If you can use the WebJobs SDK, I prefer to use the Singleton attribute.

How to use the Azure WebJobs SDK for event-driven background processing - Singleton attribute

[Singleton]
public static async Task ProcessImage([BlobTrigger("images")] Stream image)
{
     // Process the image.
}

If you have something like a ServiceBus trigger you should use [Singleton(Mode = SingletonMode.Listener)] in combination with the other host settings.

like image 33
Alex AIT Avatar answered Oct 22 '25 07:10

Alex AIT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!