简体   繁体   English

添加TwilioController基类继承后,Microsoft Azure MVC 3 Web角色无法启动

[英]Microsoft Azure MVC 3 web role not starting after adding TwilioController base class inheritance

Azure web role (MVC 3 project) wont' start with Twilio controller class Azure Web角色(MVC 3项目)不会从Twilio控制器类开始

  • I have an MVC 3 app that is hosted on MS Azure. 我有一个在MS Azure上托管的MVC 3应用程序。 It publishes to Azure Web role - No problems. 它发布到Azure Web角色 - 没有问题。
  • I added the Nuget Twilio and Twilio.Mvc packages. 我添加了Nuget Twilio和Twilio.Mvc软件包。 It still published to Azure Web role - No problems. 它仍然发布到Azure Web角色 - 没有问题。
  • I added a class that inherits from the Mvc.TwilioController base class and subsequently the Azure web role no longer starts. 我添加了一个继承自Mvc.TwilioController基类的类,随后Azure Web角色不再启动。
  • If I remove the TwilioController class inheritance the web role starts. 如果我删除TwilioController类继承,则Web角色启动。

The projects publishes, runs and twilio functions fine in my local VS Azure emulator environment. 项目在我的本地VS Azure模拟器环境中发布,运行和twilio功能很好。

The project References; 该项目参考文献; Twilio.api, Twilio.mvc, Twilio.Twiml, RestSharp, and NewtonSoft.Json are all set to CopyLocal=True. Twilio.api,Twilio.mvc,Twilio.Twiml,RestSharp和NewtonSoft.Json都设置为CopyLocal = True。

All Azure Diagnostic logging/tracing is enabled and sending to table storage every 5 seconds but no log data is available when the web role fails to start. 所有Azure诊断日志记录/跟踪都已启用,并且每5秒发送到表存储,但在Web角色无法启动时没有可用的日志数据。 Note: If I comment out the twilioController I get an abundance of log data so Azure Diags are configured correctly. 注意:如果我注释掉twilioController,我会获得大量日志数据,因此可以正确配置Azure Diags。

Because the web role continues to abort/cycle/abort, there is no opportunity to RDP to the vm for further troubleshooting. 由于Web角色继续中止/循环/中止,因此没有机会通过RDP进行进一步的故障排除。


The following two errors are written to the failing web role's Windows System Event Log about every minute: 大约每分钟都会将以下两个错误写入失败的Web角色的Windows系统事件日志中:

The application '/' belonging to site '1273337584' has an invalid AppPoolId 'ca5c9ecb-e68d-4f3a-84c2-c0b4430373e9' set. 属于网站'1273337584'的应用程序'/'具有无效的AppPoolId'ca5c9ecb-e68d-4f3a-84c2-c0b4430373e9'集。 Therefore, the application will be ignored. 因此,应用程序将被忽略。

.

Site 1273337584 was disabled because the root application defined for the site is invalid. 站点1273337584已禁用,因为为站点定义的根应用程序无效。 See the previous event log message for information about why the root application is invalid. 有关根应用程序无效原因的信息,请参阅上一个事件日志消息。


Steps to reproduce (exact steps): 重现的步骤(确切的步骤):

  1. Install Azure Sdk v 1.6 安装Azure Sdk v 1.6
  2. Create a new project using the Azure template (visual studio 10 sp1) 使用Azure模板创建新项目(visual studio 10 sp1)
  3. Choose the Asp.net MVC 3 Web Role 选择Asp.net MVC 3 Web角色
  4. Build and Publish to Azure 构建并发布到Azure
  5. Success - Web Role starts 成功 - Web角色开始
  6. Add Nuget Package "Twilio" version 3.3.2 添加Nuget Package“Twilio”版本3.3.2
  7. Add Nuget Package "Twilio.Mvc" version 3.1.3 添加Nuget包“Twilio.Mvc”3.1.3版
  8. Build and Publish To Azure 构建并发布到Azure
  9. Success - Web Role starts 成功 - Web角色开始
  10. Create an empty controller (HelloController). 创建一个空控制器(HelloController)。 See below code snippet. 请参阅下面的代码段。
  11. Add TwilioController base class (eg Public Class HelloController : TwilioController) 添加TwilioController基类(例如Public Class HelloController:TwilioController)
  12. Build and Publish to Azure 构建并发布到Azure
  13. Fail - the web role just cyles/aborts/cyles. 失败 - 网络角色只是cyles / aborts / cyles。
  14. Comment out TwilioController (eg Public Class HelloController // :TwilioController) 注释掉TwilioController(例如Public Class HelloController //:TwilioController)
  15. Buld and Publish to Azure Buld并发布到Azure
  16. Success - web role starts 成功 - 网络角色开始

     using System.Web.Mvc; using Twilio.TwiML.Mvc; namespace WindowsAzureProject857481.Controllers { public class HelloController : TwilioController { // // GET: /Hello/ public ActionResult Index() { return View(); } 

Any ideas appreciated. 任何想法都赞赏。

Thanks, Jim 谢谢,吉姆

Jim: 吉姆:

I work for Twilio, and own the .NET helper library . 我为Twilio工作,并拥有.NET帮助程序库

Whats happening is that the Twilio.Mvc assembly is looking for 2.0 version the System.Web.Mvc assembly, since that's what its built against. 发生的事情是Twilio.Mvc程序集正在寻找2.0版本的System.Web.Mvc程序集,因为它是它构建的。 Its not finding it because its obviously not being packaged with your MVC 3 project. 它找不到它,因为它显然没有与你的MVC 3项目一起打包。

The fix if fairly easy. 修复如果相当容易。 Get the Twilio.Mvc source, change the reference to the newer version of MVC and recompile the assembly. 获取Twilio.Mvc源代码,更改对较新版本MVC的引用并重新编译程序集。 I believe our support team is going to contact you with a version I built for you if you don't want to do it yourself. 我相信如果您不想自己动手,我们的支持团队会为您与我建立的版本联系。

I think there is probably also a way to use assembly binding redirects to fix the problem as well, if you wanted to try that. 我认为如果你想尝试,也可能还有一种方法可以使用程序集绑定重定向来解决问题。

Devin 德文 -

I went through your repro steps, except that I changed one thing -- I enabled WebDeploy for the role early, before adding the twilio+deps packs and extending a controller from TwilioController. 我完成了你的repro步骤,除了我改变了一件事 - 我在添加twilio + deps包和从TwilioController扩展控制器之前,早期启用了WebDeploy角色。 This way, the VM was already created and the role already started. 这样,VM已经创建,角色已经开始。

  1. Publish new MVC3 role to Azure, enabling web deploy - works 将新的MVC3角色发布到Azure,实现Web部署 - 正常工作
  2. Add Twilio NuGet packs and web deploy - still works 添加Twilio NuGet包和Web部署 - 仍然有效
  3. Extend from TwilioController and web deploy - 从TwilioController扩展和Web部署 -

The first time I did step 3, web deploy caused an error: 我第一次执行第3步时,Web部署导致错误:

COM object has been separated from its underlying RCW cannot be used

I am now retrying to make sure this last step is reproducible with WebDeploy. 我现在正在重试以确保最后一步可以使用WebDeploy重现。 Have removed all Twilio and am publishing again to reset webdeploy. 已删除所有Twilio并再次发布以重置webdeploy。 Will update answer in about 30 minutes. 将在大约30分钟内更新答案。

Update 更新

Ok, this is strange. 好的,这很奇怪。 I was able to reproduce the error above. 我能够重现上面的错误。 However, I closed Visual Studio, restarted, and was then able to web deploy. 但是,我关闭了Visual Studio,重新启动,然后才能进行Web部署。 I now have a controller in an MVC3 web role on Azure that extends TwilioController . 我现在在Azure上有一个MVC3 Web角色的控制器,它扩展了TwilioController <-- note this is temporary and will be removed. < - 注意这是暂时的,将被删除。

I suggest you try the steps above, and even try your repro without using WebDeploy. 我建议你尝试上面的步骤,甚至在不使用WebDeploy的情况下尝试你的repro。 However, before deploying with a controller that extends TwilioController, close and restart Visual Studio. 但是,在使用扩展TwilioController的控制器进行部署之前,请关闭并重新启动Visual Studio。

If that still doesn't work, try this: 如果仍然无效,请尝试以下方法:

  1. Right-click Azure project and choose Package. 右键单击Azure项目,然后选择“包”。
  2. Go to portal, and click New Staging Deployment. 转到门户,然后单击“新建暂存部署”。
  3. Navigate to and upload the cscfg and cspkg files manually. 导航并手动上载cscfg和cspkg文件。

Final Answer 最终答案

I tried the steps above. 我尝试了上面的步骤。 When disabling web deploy, it appears to not matter whether the package is published from Visual Studio or manually from the portal. 禁用Web部署时,无论包是从Visual Studio发布还是从门户手动发布都无关紧要。 Both keep aborting and retrying. 两者都保持中止和重试。 The only way I could get the TwilioController to deploy was by using WebDeploy, but of course this is not acceptable. 我可以使用WebDeploy获取TwilioController的唯一方法,但当然这是不可接受的。

I suggest you file a support request with Microsoft. 我建议你向微软提出支持请求。 It doesn't appear to be a dependency as you mentioned though, since I was able to run the code on an instance by sneaking in the Twilio stuff over web deploy. 它似乎并不像你提到的那样依赖,因为我能够通过在Web部署中偷偷摸摸Twilio的东西来在一个实例上运行代码。 It could have something to do with the COM object error mentioned above. 它可能与上面提到的COM对象错误有关。

PS -- you owe me 96 cents for 8 hours of a small compute instance. PS - 8小时的小型计算实例你欠我96美分。

Try using Intellitrace in VS2010 Ulitimate. 尝试在VS2010 Ulitimate中使用Intellitrace。 That can capture such dependency problems, allowing you to download the Intellitrace files and find the appropriate exception(s). 这可以捕获此类依赖性问题,允许您下载Intellitrace文件并找到相应的异常。

I realise this question is about getting the TwilioController to work on Azure, but in case you weren't aware of that option, I wanted to suggest you run your project on AppHarbor . 我意识到这个问题是关于让TwilioController在Azure上工作,但是如果你不知道这个选项,我想建议你在AppHarbor上运行你的项目。 I know of plenty of applications running on AppHarbor that successfully use Twilio (see this post for example). 我知道在AppHarbor上运行的大量应用程序成功使用了Twilio(例如参见这篇文章 )。

(disclaimer, I'm co-founder of AppHarbor) (免责声明,我是AppHarbor的联合创始人)

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

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