首页 > 解决方案 > 无效的 web.config 导致 HTTP 502.5 错误

问题描述

我正在尝试在 azure 上部署一个 Asp.net 样板应用程序,并且我已经部署了我的后端并且 Swagger 应用程序工作正常,当我尝试也部署 Angular 前端时,我不断收到此错误:HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure.

我找到了其他讨论这个问题的线程,但是由于我使用的是 ASP.NET 样板框架,所以我没有可以运行的文件.exe.dll文件来启动 Web.Host 项目,至少我不知道。

Kudu 中的日志显示:Application '/LM/W3SVC/288745522/ROOT' with physical root 'D:\home\site\wwwroot\' failed to start process with commandline '%LAUNCHER_PATH% %LAUNCHER_ARGS%'.

它可能与那些%LAUNCHER%未找到的变量有关,我发现其他一些线程建议您应该替换 LAUNCHER_ROOT [projectname].exeor[projectname].dll但我似乎无法在我的项目中找到这些。这可能是因为 ASP.NET Boilerplate 的构建方式。

这是我的 web.config:

<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00">
      <environmentVariables />
    </aspNetCore>
    <httpProtocol>
      <customHeaders>
        <remove name="X-Powered-By" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>
</configuration>

标签: asp.netangularazure.net-coreazure-web-app-service

解决方案


错误消息表示 ASP.NET Core 模块尝试启动工作进程但无法启动。进程启动失败的原因通常可以从应用程序事件日志和 ASP.NET Core 模块标准输出日志中的条目中查看。两个日志都可以在 Kudu/SCM 站点的 d:\home\Logfiles 中找到。在位于 wwwroot 文件夹中的 web.config 文件中,启用标准输出日志,如下所示: Web.config 示例:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\MyApplicationAssembly.dll" stdoutLogEnabled="true" 
    stdoutLogFile="\\?\%home%\LogFiles\stdout" forwardWindowsAuthToken="false" />
  </system.webServer>
</configuration>

请检查您收集的 eventlog.xml 和标准输出日志。

在此处输入图像描述

参考https ://blogs.msdn.microsoft.com/waws/2018/06/10/troubleshooting-http-502-5-startup-issues-in-azure-appservice-for-asp-net-core-websites/

ASP.Net 的其他故障排除方法,位于

https://docs.microsoft.com/en-us/aspnet/core/test/troubleshoot-azure-iis?view=aspnetcore-2.2#troubleshoot-on-azure-app-service

希望能帮助到你。


推荐阅读