简体   繁体   English

部署后Az​​ure Web Jobs无法运行

[英]Azure Web Jobs fails to run once deployed

I've created a web job using web jobs 3.0 and dotnet core. 我已经使用Web作业3.0和dotnet core创建了一个Web作业。 This webjob is triggered by a service bus trigger, and currently works a treat locally. 此Webjob由服务总线触发器触发,当前在本地工作。 However, when I deploy the webjob to azure (via standard zip process, with type set to continuous, and scale to multi instance) the webjob deploys, and then fails to run with the following error. 但是,当我将webjob部署为azure(通过标准zip流程,类型设置为“连续”,并缩放为多实例)时,webjob就会部署,然后由于以下错误而无法运行。

[07/03/2019 11:30:47 cdae3f: SYS INFO] Run script 'run.cmd' with script host - 'WindowsScriptHost'
[07/03/2019 11:30:47 cdae3f: SYS INFO] Status changed to Running
[07/03/2019 11:30:48 cdae3f: INFO] 
[07/03/2019 11:30:48 cdae3f: INFO] D:\local\Temp\jobs\continuous\export-pdf\kucubmeb.3gj>dotnet exec Foo.ExportPdf.WebJob.dll 
[07/03/2019 11:30:48 cdae3f: ERR ] Error:
[07/03/2019 11:30:48 cdae3f: ERR ]   An assembly specified in the application ependencies manifest (Foo.ExportPdf.WebJob.deps.json) was not found:
[07/03/2019 11:30:48 cdae3f: ERR ]     package: 'System.Text.Encoding.CodePages', version: '4.5.1'
[07/03/2019 11:30:48 cdae3f: ERR ]     path: 'runtimes/win/lib/netcoreapp2.0/System.Text.Encoding.CodePages.dll'
[07/03/2019 11:30:48 cdae3f: ERR ] 
[07/03/2019 11:30:48 cdae3f: SYS ERR ] Job failed due to exit code -2147450740
[07/03/2019 11:30:48 cdae3f: SYS INFO] Process went down, waiting for 60 seconds
[07/03/2019 11:30:48 cdae3f: SYS INFO] Status changed to PendingRestart

Now looking at the error log above, it clearly suggests that "System.Text.Encoding.CodePages.dll" is missing, and thats whats causing the issue. 现在查看上面的错误日志,很明显地表明“ System.Text.Encoding.CodePages.dll”丢失了,这就是引起问题的原因。 So upon seeing this, I installed the nuget package for Encoding.CodePages, and can now see the .dll file in the output directory, however it's had no effect on the error message. 因此,看到此消息后,我为Encoding.CodePages安装了nuget包,现在可以在输出目录中看到.dll文件,但是它对错误消息没有影响。

I have a feeling that either the error message is a red herring, or there's something up with the deps.json file which I don't understand. 我感觉错误消息是红色鲱鱼,或者是我不理解的deps.json文件有问题。

Happy to provide any code examples too, but as this seems to be a deployment issue, wasn't sure it would be relevant. 也很乐意提供任何代码示例,但是由于这似乎是部署问题,因此不确定是否相关。

I had a similar issue before for a .net core web job. .net核心Web作业之前也有类似的问题。

Here is my solution: 这是我的解决方案:

After create the .net core console project and install all the necessary nuget packages, and make sure the webjob can work locally. 创建.net核心控制台项目并安装所有必需的nuget软件包之后,并确保webjob可以在本地工作。

Then right click the project -> select Publish -> in the publish popup window,select Folder and also choose the path(you can keep the default path), then click publish button: 然后在发布弹出窗口中右键单击项目->选择发布->,选择文件夹,然后选择路径(可以保留默认路径),然后单击发布按钮:

在此处输入图片说明

After the publish is completed, you can go to the path where you defined in the above step(by default, the path looks like this: webjob_name\\bin\\Release\\netcoreapp2.1\\publish). 发布完成后,您可以转到上一步中定义的路径(默认情况下,该路径如下所示:webjob_name \\ bin \\ Release \\ netcoreapp2.1 \\ publish)。 Create a run.cmd file, and write something like dotnet your_webjob_name.dll into run.cmd -> then send all the files here into a .zip file. 创建一个run.cmd文件,并将dotnet your_webjob_name.dll写入run.cmd->,然后将此处的所有文件发送到.zip文件中。

在此处输入图片说明

The last step is that nav to azure portal, upload the .zip file / configure the webjob etc. 最后一步是导航到azure门户,上传.zip文件/配置webjob等。

I managed to get this working, whilst maybe not necessarily getting to the root of why the above doesn't work. 我设法使这一工作奏效,而可能未必一定要弄清上述无效的原因。

I followed the article below, which outlines how to deploy dotnet core webjobs via a website and a publish profile. 我跟随下面的文章,该文章概述了如何通过网站和发布配置文件部署dotnet核心webjob。 Publishing the webjob this way makes it start up and operate as expected. 通过这种方式发布Webjob使其可以启动并按预期运行。

https://dotnetcoretutorials.com/2018/10/12/azure-webjobs-in-net-core-part-3 https://dotnetcoretutorials.com/2018/10/12/azure-webjobs-in-net-core-part-3

In case the website is taken down, these are the basic steps I had to follow to get it working. 万一该网站被关闭,这些是我必须遵循的基本步骤才能正常运行。

  1. Add an asp.net core website to your solution (blank template) 将asp.net核心网站添加到您的解决方案中(空白模板)
  2. Add the following snippet to your new websites csproj file (change the WebJobExample to be the name and location of your webjob) 将以下代码段添加到新的网站csproj文件中(将WebJobExample更改为您的webjob的名称和位置)
    <Target Name="PostpublishScript" AfterTargets="Publish">
      <Exec Command="dotnet publish ..\WebJobExamples.WebJobExample\ -o 
      $(PublishDir)App_Data\Jobs\continuous\WebJobExample"   />
    </Target>
  1. Download publish profile from app service and deploy the application using Web Deploy (FTP did not work for me) 从应用程序服务下载发布配置文件并使用Web Deploy部署应用程序(FTP对我不起作用)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 部署到Azure的Azure Web App System.UnauthorizedAccessException无法访问本地网络上的共享文件夹 - Azure Web App System.UnauthorizedAccessException once deployed to Azure can't access shared folder on local network Azure Web 作业/队列 - DecoderFallbackException - Azure Web Jobs / Queue - DecoderFallbackException 部署后无法运行Websphere MQ应用程序 - Unable to run Websphere MQ application once deployed Azure Web作业失败-剩余ReadLine() - Azure Web Jobs failure - ReadLine() left in 可配置的计时器触发器 - Azure Web作业 - Configurable Timer Triggers - Azure Web Jobs Web api在本地工作,但在部署到Azure时则不能 - Web api working locally but not when deployed to Azure Web 部署在 Azure 上的应用程序未返回 UTC 日期时间 - Web App deployed on Azure not returning datetimes in UTC 将MVC应用程序部署到服务器后,CSV文件导入失败 - CSV file fails to import once MVC Application deployed to Server 部署后,Azure 函数中的依赖注入失败但在本地工作 - Dependency Injection failing in Azure function once deployed but works locally 部署在Azure Web App / Azure API上时缺少CORS标头 - CORS headers missing when deployed on Azure Web App / Azure API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM