如何在本地运行Azure WebJob

时间:2015-10-18 20:44:26

标签: c# azure azure-webjobs

我想创建一个连续运行的webjob,但首先我想尝试在本地运行它以进行调试。我正在使用Visual Studio 2015,我运行了azure存储模拟器(我可以在visual studio中运行azure webjobs的示例)。 当我运行它时,它在新的JobHost()行上失败 例外:值不能为空。参数名称:方​​法

    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));
        }
    }

我是否可以在本地运行连续运行的作业?

1 个答案:

答案 0 :(得分:16)

Azure Web作业通常只是控制台应用程序。您可以像调试,测试和运行任何其他控制台应用程序一样在本地运行它。我建议您获取Azure WebJobs SDK并浏览教程Create a .NET WebJob in Azure App Service

相关问题