【问题标题】:Azure WebJob fail to startAzure WebJob 无法启动
【发布时间】:2023-03-10 00:05:01
【问题描述】:

我在 Visual Studio 2015 中创建了一个 Azure WebJob 并将其部署到 Azure。

尝试运行 WebJob 时出现此错误:

[03/12/2017 22:47:46 > 070c62: SYS INFO] Status changed to Running
[03/12/2017 22:47:47 > 070c62: ERR ] 
[03/12/2017 22:47:47 > 070c62: ERR ] Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.HostingProcess.Utilities.Sync, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
[03/12/2017 22:47:47 > 070c62: ERR ]    at Microsoft.VisualStudio.HostingProcess.EntryPoint.Main()
[03/12/2017 22:47:47 > 070c62: SYS ERR ] Job failed due to exit code -532462766
[03/12/2017 22:47:47 > 070c62: SYS INFO] Process went down, waiting for 60 seconds
[03/12/2017 22:47:47 > 070c62: SYS INFO] Status changed to PendingRestart

我已尝试搜索此错误,但找不到与此相关的任何内容。我不知道这是我的 WebJob 代码中的问题还是 Azure 中 WebJob 的配置问题。

是否有人对问题所在有一些想法或指示?

【问题讨论】:

  • 你可以从this开始帮助隔离。

标签: azure azure-webjobs azure-webjobssdk


【解决方案1】:

[03/12/2017 22:47:47 > 070c62:ERR] 未处理异常:System.IO.FileNotFoundException:无法加载文件或程序集 'Microsoft.VisualStudio.HostingProcess.Utilities.Sync,版本 = 14.0.0.0 , Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 或其依赖项之一。该系统找不到指定的文件。 [03/12/2017 22:47:47 > 070c62: ERR ] 在 Microsoft.VisualStudio.HostingProcess.EntryPoint.Main()

首先,正如 David Ebbo 所说,请尝试在 Azure Web App 沙箱之外运行相同的逻辑,并检查它是否工作正常。

此外,据我所知,如果 WebJobs 项目错过了引用的程序集或文件,我们会遇到与您类似的问题。例如,我的控制台应用程序引用了 Newtonsoft.Json,但是当我将控制台应用程序作为 WebJobs 部署到 Azure 时,我没有包含此文件,我得到以下错误。

ConsoleApplication13.Program.Main() 是我的控制台应用程序的入口点,请检查您的项目以确保您没有错过一些程序集。

【讨论】:

    【解决方案2】:

    我通过稍微改变Main() 方法解决了同样的问题。 请务必在 Main() 的顶部保留以下几行。

    var config = new JobHostConfiguration();
    
    if (config.IsDevelopment)
    {
        config.UseDevelopmentSettings();
    }
    config.Queues.BatchSize = 2; //Number of messages to dequeue at the same time.
    config.Queues.MaxDequeueCount = 5; //Max retries before move the messate to the poison.
    config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(1); //Pooling request to the queue.
    config.NameResolver = new QueueNameResolver(); //Dynamic queue name resolver.
    
    JobHost host = new JobHost(config);
    

    之后我搜索了我在所有源代码中编写的所有“Console.Writeline()”并将它们删除,因为我认为它属于 Microsoft.VisualStudio.HostingProcess.Utilities.Sync dll。

    之后,我删除了门户中 webApp 中配置的所有 webjobs 并再次发布。

    瞧,所有 WebJobs 都重新运行了。

    现在我再次编写了“console.WriteLine”并且每个都继续运行良好。所以我认为重要的是将 JobHostconfiguration 放在 Main 的最顶部:

    var config = new JobHostConfiguration();
    
    if (config.IsDevelopment)
    {
        config.UseDevelopmentSettings();
    }
    config.Queues.BatchSize = 2; //Number of messages to dequeue at the same time.
    config.Queues.MaxDequeueCount = 5; //Max retries before move the messate to the poison.
    config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(1); //Pooling request to the queue.
    config.NameResolver = new QueueNameResolver(); //Dynamic queue name resolver.
    
    JobHost host = new JobHost(config);
    

    【讨论】:

      【解决方案3】:

      首先,从 azure 中删除有错误的 web 作业。

      然后验证解决方案配置是否处于“发布”模式。

      最后,再次部署。

      PS:希望网络作业在本地运行时没有任何错误!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-05-20
        • 2018-03-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多