将MVC 6网站部署到Azure会导致错误502

时间:2016-05-16 11:12:23

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

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

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

远程调试无法达到任何代码是没用的,问题发生在应用程序的启动中。

更新

  

据我所知,到目前为止,它似乎与此有关   解决方案,因为同一项目在新的/空的解决方案中工作。一世   有一个基本的Soluion 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"/>

2 个答案:

答案 0 :(得分:0)

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

我将从启用herehere所述的详细诊断开始,看看日志中是否有任何事情发生。此外,在LogFiles控制台的调试控制台中,可以通过Kudu控制台(http://webappname.scm.azurewebsites.net,注意SCM)获得一些日志。

答案 1 :(得分:0)

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

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

也改为DNX46而不是451(之前尝试过,但在这个问题上没有任何区别)。

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

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

可能是我引用的类lib中有一些东西导致了这个版本问题,因为创建一个带有空类libs / mvc项目的新解决方案可以正常工作,但无论哪种方式我都很高兴这个问题得到了解决。