简体   繁体   English

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

[英]Deploying MVC 6 website to Azure results in error 502

I used to have no problem with deploying my asp.net 5/mvc6 website to my Azure apps/website environment, but last months I'm having weird issues. 我过去将asp.net 5 / mvc6网站部署到我的Azure应用程序/网站环境时没有问题,但是上个月我遇到了奇怪的问题。

If I deploy my website to Azure, 90% of the times, the browser will be opened automatically when the deploy succeeded, and it will just load for 5 minutes and eventually will give me a 502 error or a 500 error for timeout. 如果我将网站部署到Azure的机率达到了90%,则部署成功后,浏览器将自动打开,仅加载5分钟,最终会出现502错误或500错误。 I can redeploy many times but it will never work. 我可以重新部署很多次,但是它永远都行不通。 I can't pinpoint the difference between a basic empty website and my website because the empty template website will initially work, but if I make some changes to it inline with my problem-website it will give the error, but then when I revert all changes the problem persists even with a empty 'hello world' website. 我无法查明基本空网站和我的网站之间的区别,因为空模板网站最初可以正常工作,但是如果我与问题网站内联对其进行一些更改,它将给出错误信息,但是当我恢复所有内容时即使网站为空,“问题”仍然存在。

None of the code will ever be reached to remote debugging is useless, the problem happens in the startup of the app it seems. 没有任何代码将到达远程调试是没有用的,问题似乎发生在应用程序的启动中。

update 更新

From what I can tell so far is that it seems be related to the solution, since the same project does work in a new/empty solution. 到目前为止,我可以说的是它似乎与解决方案有关,因为同一项目确实可以在新的/空的解决方案中工作。 I have a basic Soluion Items/src/test/tools folder structure, with a global.json and .tfignore in the Solution Items. 我有一个基本的Soluion Items / src / test / tools文件夹结构,在解决方案项目中带有global.json和.tfignore。 (tried deleting global.json but didnt make a difference) (尝试删除global.json,但没有改变)

The eventlog.xml gives me 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>

My web.config are default. 我的web.config是默认的。

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

That looks like you may hit some limits about timeout or different related issue. 看来您可能在超时或其他相关问题上遇到了一些限制。 And performance, for sure. 性能,当然。 Try to move your web app to more powerful mode like a standard and see if that will help. 尝试将您的网络应用程序移动到标准等更强大的模式,看看是否有帮助。 Next, it is not so simple to say the reason of 500/502. 接下来,要说出500/502的原因并不是那么简单。 There is the official guidance for troubleshooting these errors. 有解决这些错误的官方指南

I would start with enabling a verbose diagnostics as described here and here and see if you have any things going on in the logs. 我将从启用此处此处所述的详细诊断开始,看看日志中是否有任何事情在进行。 Also, some logs are available through the Kudu console ( http://webappname.scm.azurewebsites.net , note SCM) in the Debug console in the LogFiles console. 另外,某些日志可通过LogFiles控制台的Debug控制台中的Kudu控制台( http://webappname.scm.azurewebsites.net ,请注意SCM)获得。

After completely recreating my solution in a 2nd test-solution, and adding in projects and references step by step and trying to find the breaking point, I noticed that when I added another class lib (quite a large one) to the solution and reference it from my MVC6 app it would break. 在第二个测试解决方案中完全重新创建了我的解决方案,并逐步添加项目和引用并尝试找到断点后,我注意到当我向解决方案中添加另一个类库(相当大的类)并引用它时从我的MVC6应用中会损坏。 If I would then remove the reference it would still be broken so it seemed like a unfixable issue. 如果我随后删除该引用,它将仍然被破坏,因此似乎是无法解决的问题。 After some trial and error's I started messing with the references in the packages and wrap-folders, and eventually found the issue. 经过一番尝试和错误之后,我开始弄乱软件包和包装文件夹中的引用,最终发现了问题。

By default the asp.net libs use an embedded Newtonsoft.json version 6.xxx. 默认情况下,asp.net库使用嵌入式Newtonsoft.json版本6.xxx。 I added the latest version of Newtonsoft.json (8.xx) to my MVC 6 project, then deleted the (old) newtonsoft folders/files from the wrap and packages folder. 我将最新版本的Newtonsoft.json(8.xx)添加到我的MVC 6项目中,然后从wrap和packages文件夹中删除了(旧的)newtonsoft文件夹/文件。

Also changed to DNX46 instead of 451 (tried that before, but didnt make a difference regarding the issue). 也更改为DNX46而不是451(之前曾尝试过,但在问题上没有任何不同)。

The build would break initially after deleting the 6.xxx files but rebooting Visual Studio will fix this. 最初删除6.xxx文件后,构建将中断,但是重新启动Visual Studio将解决此问题。

After these steps I deployed to Azure and everything worked. 完成这些步骤后,我部署到了Azure,一切正常。 I tried this fix in multiple solutions now that had the exact same issue and it seems to be a solid fix. 现在,我在多个解决方案中尝试了此修复程序,这些解决方案具有完全相同的问题,而且似乎是可靠的修复程序。

It could be that there is something in my referenced class lib that is causing this versioning issue since creating a new solution with blank class libs/mvc projects will work fine, but either way I'm glad this is resolved. 我引用的类库中可能有某种原因导致此版本问题,因为使用空白类库/ mvc项目创建新的解决方案可以正常工作,但是无论哪种方式,我都高兴地解决了这一问题。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM