Unable to acquire Singleton lock in Azure WebJob after removing SingletonAttribute

D. Siemer

I have got a WebJob containing functions having a TimeTriggerAttribute. They also have a SingletonAttribute on them, so they don't get executed in parallel.

Deployed in the App Service everything works as expected.

When running it locally it did work as expected for a while and then the output of the Job host reports:

Development settings applied

Found the following functions:


Unable to acquire Singleton lock (bd99766f202e4ac4ba230557b7180bd2/MyNamespace.WebJobs.Functions.MyFuncitonAsync.Listener).

I removed the singleton attribute, but the message keeps showing. I also re-built the project and restarted the machine. Nothing helped.

I renamed the function and it was again scheduled as expected. Now I could also re-add the SingletonAttribute and everything worked as expected. When I rename it back to the original, the error comes back.

What can I do in order to be able to acquire the lock again from the Job host?

D. Siemer

By reading this article I figured out that on top of the SingletonAttribute I did set, the TimeTriggerAttribute uses another one behind the scenes. Thank you Janley Zhang.

The ID of the host is, by default, constant across deployments. So when multiple developers that use the same storage account execute the code locally, they would try to acquire the same blob lease and only the first would be successful.

I ended up using a distinct host ID for each developer, like

if (jobHostConfiguration.IsDevelopment)
    jobHostConfiguration.HostId = Environment.UserName.ToLowerInvariant();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at


Login to comment