我的 WebJob 缺少依赖项

My WebJob is missing dependency

我用一个简单的 C# 控制台应用程序创建了一个网络作业。我使用 Azure blob 和数据库连接 - 在本地,一切都很好用。

在 Azure 门户中,我制作了一个简单的应用程序,我在其中添加了我的 exe 并将其强制为 运行。从日志中我得到:

[10/09/2016 20:38:52 > ed5cb9: ERR ] Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

不要介意6.0.0.0版本,我试过7.0.0.0和最新的7.2.1,结果没有区别。

Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

根据您提供的错误,我建议您尝试确保将特定程序集部署到Azure。您可以使用 Kudu 控制台(可以从 Azure 访问:App Service > Web App> Development Tools > Advanced Tools) 并在以下路径中检查您的程序集:

d:\home\site\wwwroot\app_data\jobs\[triggered|continuous]\{job name}

此外,如果您通过 Azure 门户部署 WebJob,则可以直接上传包含 WebJob 文件的 zip 文件。关于Web Jobs的更多详情,可以关注这个tutorial.