5

Azure web role (MVC 3 project) wont' start with Twilio controller class

  • I have an MVC 3 app that is hosted on MS Azure. It publishes to Azure Web role - No problems.
  • I added the Nuget Twilio and Twilio.Mvc packages. It still published to Azure Web role - No problems.
  • I added a class that inherits from the Mvc.TwilioController base class and subsequently the Azure web role no longer starts.
  • If I remove the TwilioController class inheritance the web role starts.

The projects publishes, runs and twilio functions fine in my local VS Azure emulator environment.

The project References; Twilio.api, Twilio.mvc, Twilio.Twiml, RestSharp, and NewtonSoft.Json are all set to 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. Note: If I comment out the twilioController I get an abundance of log data so Azure Diags are configured correctly.

Because the web role continues to abort/cycle/abort, there is no opportunity to RDP to the vm for further troubleshooting.


The following two errors are written to the failing web role's Windows System Event Log about every minute:

The application '/' belonging to site '1273337584' has an invalid AppPoolId 'ca5c9ecb-e68d-4f3a-84c2-c0b4430373e9' set. Therefore, the application will be ignored.

.

Site 1273337584 was disabled because the root application defined for the site is invalid. 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
  2. Create a new project using the Azure template (visual studio 10 sp1)
  3. Choose the Asp.net MVC 3 Web Role
  4. Build and Publish to Azure
  5. Success - Web Role starts
  6. Add Nuget Package "Twilio" version 3.3.2
  7. Add Nuget Package "Twilio.Mvc" version 3.1.3
  8. Build and Publish To Azure
  9. Success - Web Role starts
  10. Create an empty controller (HelloController). See below code snippet.
  11. Add TwilioController base class (e.g. Public Class HelloController : TwilioController)
  12. Build and Publish to Azure
  13. Fail - the web role just cyles/aborts/cyles.
  14. Comment out TwilioController (e.g. Public Class HelloController // :TwilioController)
  15. Buld and Publish to 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

6
  • Is RDP enabled on the web role? Can you log in and check the logs? msdn.microsoft.com/en-us/library/gg443832.aspx Dec 14, 2011 at 22:01
  • I enabled RDP but but was not able to connect (the "Remote" button in Azure Management Console is never active while the web role is cycling.
    – JimSTAT
    Dec 14, 2011 at 23:31
  • If you add something like ELMAH to catch exceptions does something get logged? Dec 15, 2011 at 4:59
  • I can reproduce this everytime with the vanilla Azure Mvc 3 project template (see the steps above). If anyone has an Azure account I'd be curious of your results if you follow the steps to reproduce I added to the question.
    – JimSTAT
    Dec 15, 2011 at 15:50
  • 1
    I suspect the Azure package is missing a twilio dependancy because I ran into something similar with Entity Framework last year and the temporary fix was to manually include a file in the package. However, like I mentioned in the Question, all the twilio, restsharp, and newtonsof references are Copy Local = True.
    – JimSTAT
    Dec 15, 2011 at 15:59

4 Answers 4

4

Jim:

I work for Twilio, and own the .NET helper library.

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. Its not finding it because its obviously not being packaged with your MVC 3 project.

The fix if fairly easy. Get the Twilio.Mvc source, change the reference to the newer version of MVC and recompile the assembly. 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

1
  • You've solved the problem! I pulled out the Nuget Twilio.Mvc version 3.1.3 and added a reference to the Twilio.Mvc you provided me that references System.Web.Mvc 3.x and problem solved. Hopefully Twilio will create a Nuget Twilio.Mvc package for MVC 3. I've edited the answer with the steps for creating a Twilio/MVC 3/Azure project.
    – JimSTAT
    Dec 31, 2011 at 20:31
3
+50

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. This way, the VM was already created and the role already started.

  1. Publish new MVC3 role to Azure, enabling web deploy - works
  2. Add Twilio NuGet packs and web deploy - still works
  3. Extend from TwilioController and web deploy -

The first time I did step 3, web deploy caused an error:

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. Have removed all Twilio and am publishing again to reset webdeploy. Will update answer in about 30 minutes.

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. I now have a controller in an MVC3 web role on Azure that extends TwilioController. <-- note this is temporary and will be removed.

I suggest you try the steps above, and even try your repro without using WebDeploy. However, before deploying with a controller that extends TwilioController, close and restart Visual Studio.

If that still doesn't work, try this:

  1. Right-click Azure project and choose Package.
  2. Go to portal, and click New Staging Deployment.
  3. Navigate to and upload the cscfg and cspkg files manually.

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. 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.

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. It could have something to do with the COM object error mentioned above.

P.S. -- you owe me 96 cents for 8 hours of a small compute instance.

4
  • I have followed your steps and getting the same results - (The twilioControler can be added via web deploy after the fact). This is progress -Thanks. One thing I'm noticing on the failure scenario are multiple WAS errors in the Windows System Log. I'll post the errors in the Question. You can delete your web role now :)
    – JimSTAT
    Dec 17, 2011 at 20:58
  • The instance URL used above has been deleted. Good luck.
    – danludwig
    Dec 17, 2011 at 21:19
  • Thanks for the workaround. If I publish to Azure with webdeploy as you discovered I can rdp in after the fact and shut off the web deploy service/port when I swap it into production which means I have options now(thanks, so bounty is yours). I'm going to leave the question open however until MS or Twilio resolves the underlying issue and will provide an anwser if nobody else does.
    – JimSTAT
    Dec 24, 2011 at 1:00
  • Did you file a support ticket with MS? If you haven't, you should. After you turn off web deploy, can you change the VM site? I think you can change the instance count, but what a pain to have to web deploy in order to change VM site.
    – danludwig
    Dec 24, 2011 at 5:46
2

Try using Intellitrace in VS2010 Ulitimate. That can capture such dependency problems, allowing you to download the Intellitrace files and find the appropriate exception(s).

2

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. I know of plenty of applications running on AppHarbor that successfully use Twilio (see this post for example).

(disclaimer, I'm co-founder of AppHarbor)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.