I am getting unable to acquire singleton lock issue when I am running the application locally. How may I resolve it?
Below is my code
static void Main()
{
JobHostConfiguration config = new`enter code here` JobHostConfiguration();
config.UseTimers();
AutoMapperManager.SetAutomapper();
JobHost host = new JobHost(config);
//Task.Factory.StartNew(() => host.Call(typeof(Functions).GetMethod("GetActionItemPullData")));
config.Tracing.ConsoleLevel = TraceLevel.Verbose;
host.RunAndBlock();
}
Regards, Vantage
It happened to me that I migrated the web jobs to a new app service and I was getting the same error. After looking at everything I figured out what it was:
Make sure no instance of the web job is running in Azure. That means, stop the web job in Azure. Even the local copy won't run if you are targeting the same storage account.
Stopping the app service doesn't stop the web jobs. You need to stop the web jobs explicitly.
Adding a verbose logging level helped me a lot.
config.Tracing.ConsoleLevel = System.Diagnostics.TraceLevel.Verbose;
You can overwrite the host ID to something other than the default. This code snippet is for v3 of the WebJobs SDK, but there is a similar setting also for the v2. This solution even works, if multiple people work locally on the same project.
builder.ConfigureWebJobs(context =>
{
if (IsLocal)
{
context.UseHostId(Environment.UserName);
}
// other context operations
}
If you have published your webjob already to Azure, make sure it is not running there when in the meantime trying to run it locally.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With