Getting lots of "Unable to aquire Singleton lock" during localhost development
See original GitHub issueHeya 😃
So I’ve just started playing around / trying to use the TimerTrigger
with a new webjob. I’m doing localhost development to make sure the code works, before I deploy it up to Azure.
To do this, I click F5
to Debug
my webjob console app. Ok, great! works/etc… I then stop this (or the code throws an exception and crashes).
I then change one tiny thing and then hit F5
again … and then get this:
Sometimes, I wait 10 or even 20 seconds after the webjob stopped/stops and then hit F5
and still get that error.
Shouldn’t the host 100% tear down after it’s stopped? I should be able to hit F5
, then close app, then hit F5
straight away, right?
Update / More info.
Here’s my program.cs
as a reference:
class Program
{
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
static void Main()
{
var config = new JobHostConfiguration();
config.Tracing.ConsoleLevel = TraceLevel.Verbose;
config.UseTimers();
var host = new JobHost(config);
host.RunAndBlock();
//var host = new JobHost();
//// The following code ensures that the WebJob will be running continuously
//host.RunAndBlock();
}
}
Issue Analytics
- State:
- Created 8 years ago
- Comments:15 (7 by maintainers)
Top Results From Across the Web
How to resolve unable to acquire singleton lock issue in ...
Make sure no instance of the web job is running in Azure. That means, stop the web job in Azure. Even the local...
Read more >How to resolve unable to acquire singleton lock issue in Azure ...
After looking at everything I figured out what it was: Make sure no instance of the web job is running in Azure. That...
Read more >Reducing initial request latency by pre-building services in ...
In this post I show a startup task that pre-builds all the services registered in the DI container to reduce the duration of...
Read more >host.json reference for Azure Functions 2.x and later
Reference documentation for the Azure Functions host.json file with the v2 runtime.
Read more >Contexts and Dependency Injection
If it's not possible to acquire the lock in the given time a LockException is thrown. 4.14. Repeatable interceptor bindings. Quarkus has limited...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok, I’ve added
JobHostConfiguration.IsDevelopment
andJobHostConfiguration.UseDevelopmentSettings()
. You can see an example in the extensions sample here. This new method sets up all the optimal local dev settings as mentioned above.See the xml doc on these new methods for details. Basically if your environment has a setting AzureWebJobsEnv, IsDevelopment will be true. Note that these changes are in prerelease packages available on myget.
I’m all for that 😃 Was just thinking about options, but yes! all for that 😃
e.g.:
<Setting name="AzureConnectionString" value="UseDevelopmentStorage=true" />