Azure WebJob不会在调试器中本地运行 [英] Azure WebJob won't run locally in debugger

查看:53
本文介绍了Azure WebJob不会在调试器中本地运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Azure WebJob曾经在VS2015调试器中运行,但是我发现它逐渐变得非常间歇,现在根本无法运行.我将其部署到Azure时,它工作正常.该作业被标记为RunOnStartUp.

My Azure WebJob used to run in the VS2015 Debugger, but I found it gradually became very intermittent and now won't run at all. It works fine it I deploy it to Azure. The job is marked as RunOnStartUp.

public class Program
{
    static void Main()
    {
        var config = new JobHostConfiguration();
        config.UseTimers();
        var host = new JobHost(config);
        host.RunAndBlock();
    }
}

public class TestJob : BaseJob
{
    public static async Task StartupJob([TimerTrigger("05:00:00", RunOnStartup = true)] TimerInfo timerInfo, TextWriter log)
    {
        log.WriteLine("StartupJob");
        await Jobs.Test(some params);
        log.WriteLine("Sorted");
    }
}

我需要做什么才能使其在调试器中运行?

What do I need to do to get it running in the Debugger?

推荐答案

我猜您在Azure中为您的工作使用了相同的存储帐户,而在本地调试时又使用了相同的存储帐户?如果是这样,TimeTrigger将作为单例运行,这意味着它需要获取一个锁才能执行.如果您的Web作业已经在Azure中运行,则您要调试的本地版本将无法获取该锁.

I'm guessing you use the same storage account for your job in Azure and when you debug it locally? If that's the case - the TimeTrigger runs as a singleton which means it needs to acquire a lock to be able to execute. If your webjob is already running in Azure your local version, which you're trying to debug, is not able to acquire the lock.

为避免这种情况,只需对实时" Azure版本和本地本地开发使用不同的存储帐户.

To avoid this just use different storage accounts for "live" Azure version and local local development.

我还建议您在本地调试时启用开发设置"- config.UseDevelopmentSettings(); .如果启用它,您将看到消息无法获取功能的锁..."(或类似内容).

I would also recommend to enable "development settings" - config.UseDevelopmentSettings(); - when you debug locally. If you enable it you'll see the messages "unable to acquire lock for function..." (or something similar).

这篇关于Azure WebJob不会在调试器中本地运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆