如何在本地 运行 Azure WebJob?

How do I run an Azure WebJob locally?

我想连续创建一个 运行ning WebJob,但首先我想尝试 运行 在本地进行调试。我正在使用 Visual Studio 2015,我有 Azure 存储模拟器 运行ning(我可以 运行 visual studio 中的 Azure WebJobs 示例)。

当我 运行 下面的 new JobHost() 行失败时:

Exception: Value cannot be null. Parameter name: method

    static void Main()
    {
        var host = new JobHost();
        host.CallAsync(typeof(Functions).GetMethod("GetNextJob"));
        // The following code ensures that the WebJob will be running continuously
        host.RunAndBlock();
    }
    [NoAutomaticTriggerAttribute]
    public static async Task GetNextJob()
    {
        while(true)
        {
            try
            {
                var log = new Logger();
                log.WriteInfo("Getting next job to be run", 0, 0, "Brain");
                //Console.WriteLine("Getting new Job and putting to que");
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            await Task.Delay(TimeSpan.FromSeconds(5));
        }
    }

我什至可以 运行 在本地连续 运行ning 作业吗?

Azure WebJobs 通常只是控制台应用程序。您可以在本地 运行 它,就像调试、测试和 运行 任何其他控制台应用程序一样。我建议获得 Azure WebJobs SDK and running through the tutorial Create a .NET WebJob in Azure App Service.