【问题标题】:Deploying MVC 6 website to Azure results in error 502将 MVC 6 网站部署到 Azure 会导致错误 502
【发布时间】:2016-05-16 11:12:23
【问题描述】:

我以前在将我的 asp.net 5/mvc6 网站部署到我的 Azure 应用程序/网站环境时没有问题,但上个月我遇到了奇怪的问题。

如果我将我的网站部署到 Azure,90% 的情况下,部署成功后浏览器会自动打开,它只会加载 5 分钟,最终会给我一个 502 错误或 500 超时错误.我可以重新部署很多次,但它永远不会工作。我无法确定基本的空网站和我的网站之间的区别,因为空模板网站最初可以工作,但是如果我根据我的问题网站对其进行一些更改,它会给出错误,但是当我恢复所有即使“hello world”网站为空,问题仍然存在。

任何代码都不会被远程调试是无用的,问题似乎发生在应用程序的启动中。

更新

据我目前所知,它似乎与 解决方案,因为同一个项目确实在新的/空的解决方案中工作。一世 有一个基本的解决方案 Items/src/test/tools 文件夹结构,有一个 解决方案项中的 global.json 和 .tfignore。 (尝试删除 global.json 但没有任何区别)

eventlog.xml 给了我

View Msvsmon's help for more information.</Data><Binary>08005E80</Binary></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-15T18:40:24Z"/><EventRecordID>1002678312</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '6424' failed to start. Port = 11271, Error Code = '-2147023829'.</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-15T19:40:29Z"/><EventRecordID>1006283437</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '9840' failed to start. Port = 20348, Error Code = '-2147023829'.</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-15T20:40:41Z"/><EventRecordID>1009895484</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '9796' failed to start. Port = 27433, Error Code = '-2147023829'.</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-15T21:40:56Z"/><EventRecordID>1013510812</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '7748' failed to start. Port = 33738, Error Code = '-2147023829'.</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-15T22:41:16Z"/><EventRecordID>1017131093</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '5844' failed to start. Port = 20405, Error Code = '-2147023829'.</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-15T23:41:43Z"/><EventRecordID>1020757406</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '4208' failed to start. Port = 16859, Error Code = '-2147023829'.</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-16T00:42:13Z"/><EventRecordID>1024387796</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '8840' failed to start. Port = 23996, Error Code = '-2147023829'.</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-16T01:42:48Z"/><EventRecordID>1028023000</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '8724' failed to start. Port = 9206, Error Code = '-2147023829'.</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-16T02:43:29Z"/><EventRecordID>1031663140</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '320' failed to start. Port = 9307, Error Code = '-2147023829'.</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-16T03:44:14Z"/><EventRecordID>1035308281</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '9540' failed to start. Port = 27060, Error Code = '-2147023829'.</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-16T04:44:14Z"/><EventRecordID>1038908703</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '8212' failed to start. Port = 31282, Error Code = '-2147023829'.</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-16T05:44:20Z"/><EventRecordID>1042514234</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '9608' failed to start. Port = 23608, Error Code = '-2147023829'.</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-16T06:44:30Z"/><EventRecordID>1046124390</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '4216' failed to start. Port = 15739, Error Code = '-2147023829'.</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-16T07:44:45Z"/><EventRecordID>1049739625</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '3544' failed to start. Port = 13495, Error Code = '-2147023829'.</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-16T08:45:05Z"/><EventRecordID>1053359796</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '908' failed to start. Port = 6457, Error Code = '-2147023829'.</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-16T09:45:30Z"/><EventRecordID>1056984968</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '5272' failed to start. Port = 32023, Error Code = '-2147023829'.</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>1000</EventID><Level>0</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2016-05-16T10:46:01Z"/><EventRecordID>1060615265</EventRecordID><Channel>Application</Channel><Computer>RD0003FF1D2CD5</Computer><Security/></System><EventData><Data>Process '7708' failed to start. Port = 9729, Error Code = '-2147023829'.</Data></EventData></Event></Events>

我的 web.config 是默认的。

 <handlers>
      <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
    </handlers>
    <httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/>

【问题讨论】:

  • 使用槽位进行部署。部署暂存槽等待初始化然后交换。可能您已经更改了项目并且 initilaize 比平时花费了更多的时间,并且您遇到了这个问题。
  • 我正在部署到登台,但两个环境都存在问题。由于这个问题,交换不会成功。

标签: c# azure asp.net-core asp.net-core-mvc


【解决方案1】:

看起来您可能会遇到一些关于超时或其他相关问题的限制。当然,还有性能。尝试将您的网络应用程序移动到更强大的模式(如标准),看看是否有帮助。 接下来,说500/502的原因就不是那么简单了。有official guidance 用于解决这些错误。

我将首先启用详细诊断,如 herehere 所述,然后查看日志中是否发生了任何事情。此外,一些日志可通过 LogFiles 控制台的 Debug 控制台中的 Kudu 控制台(http://webappname.scm.azurewebsites.net,注意 SCM)获得。

【讨论】:

  • 我基本上尝试了指南中的所有内容,但除了事件日志的错误 2147023829 之外,我从 Azure 中的故障排除指南/操作中没有得到太多。我也扩大到一个更大的实例,但这并没有什么不同。 (我现在在 Standard Small)
  • 嗯,我发现了一些旧的 GitHub 问题。我认为它与配置有关。你可以看看that if that是不是和你的问题有点相似?
  • 我也发现了那个线程,看起来很相似,但是他的解决方案对我没有用。
  • 据我所知,它似乎与解决方案有关,因为同一个项目确实在新的/空的解决方案中工作。我有一个基本的解决方案项目/src/test/tools 文件夹结构,解决方案项目中有一个 global.json 和 .tfignore。 (尝试删除 global.json 但没有任何影响)
  • 可能是的。我发现 Azure 中新版本的 MVC/etc 存在一些问题......看起来值得等待新版本
【解决方案2】:

在第二个测试解决方案中完全重新创建我的解决方案,并逐步添加项目和引用并尝试找到断点后,我注意到当我向解决方案添加另一个类库(相当大的类库)时并从我的 MVC6 应用程序中引用它会中断。如果我随后删除引用,它仍然会被破坏,所以这似乎是一个无法修复的问题。经过一些试验和错误后,我开始弄乱包和包装文件夹中的引用,并最终发现了问题。

默认情况下,asp.net 库使用嵌入式 Newtonsoft.json 版本 6.xxx。 我将最新版本的 Newtonsoft.json (8.xx) 添加到我的 MVC 6 项目中,然后从 wrap 和 packages 文件夹中删除了(旧的)newtonsoft 文件夹/文件。

也改为 DNX46 而不是 451(之前尝试过,但对这个问题没有任何影响)。

删除 6.xxx 文件后构建最初会中断,但重新启动 Visual Studio 将解决此问题。

在这些步骤之后,我部署到 Azure,一切正常。我在多个解决方案中尝试了这个修复,现在有完全相同的问题,它似乎是一个可靠的修复。

可能是我引用的类库中的某些内容导致了此版本控制问题,因为使用空白类库/mvc 项目创建新解决方案可以正常工作,但无论哪种方式,我都很高兴这个问题得到了解决。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-25
    相关资源
    最近更新 更多