2

I have a WebApi project that wraps the Dynamics CRM Online web service and provides a REST api. I have a simple controller that gets some contacts from CRM and returns them to the caller.

Everything works fine when I run it in the local emulator. However, when I deploy the project to Azure, I can reach the home page, but the controllers all return http 500 errors. Why would this happen? And how can I troubleshoot to get more details?

UPDATE

The issue is with the absence of Microsoft.IdentityModel.dll on the Server 2012 instance running the web role in Azure. I found this by opening web role instance in RDP, installing Fiddler, and making the request from Fiddler to the local IIS server. It responded with the detailed error.

Now my issue is figuring out how to enable IdentityModel on a Windows Azure Web Role. You're supposed to be able to add it via the Server 2012 Add Roles and Features wizard, but it's totally locked down on the Web Role. You can't check any boxes that aren't already checked. Is this even possible?

Andrew B Schultz
  • 1,512
  • 1
  • 23
  • 41
  • 1
    try with this article [http://blogs.technet.com/b/dodeitte/archive/2012/07/20/issue-when-installing-windows-identity-foundation-on-windows-server-2012.aspx](http://blogs.technet.com/b/dodeitte/archive/2012/07/20/issue-when-installing-windows-identity-foundation-on-windows-server-2012.aspx) – Guido Preite Apr 03 '13 at 17:32
  • Thanks Guido, that looks helpful. It doesn't work for me, because the Web Role in Windows Azure doesn't let you enable .NET 3.5 (or at least you have to install it before you enable it, which has to be done via installation media or Windows Update, neither of which seem possible in the Azure Web role). But that's a different question. Thanks for your answer here. – Andrew B Schultz Apr 03 '13 at 20:47
  • 1
    Just set copy local to true in your project reference. – David Peden Apr 03 '13 at 20:51
  • I tried that - with System.IdentityModel, but that didn't work. Seems to not be the same thing, there is no Microsoft.IdentityModel reference to add. – Andrew B Schultz Apr 03 '13 at 20:56
  • Ahhh-there is Microsoft.IdentityModel, you just have to have the WIF SDK installed. But there's still more to it than that, see my answer. – Andrew B Schultz Apr 04 '13 at 14:53

1 Answers1

1

The issue is giving the Web Role access to Windows Identity Foundation when it's inherently not there. Marc Schweigert provides clear steps to do this here:

http://blogs.msdn.com/b/devkeydet/archive/2013/01/27/crm-online-amp-windows-azure-configuring-single-sign-on-sso.aspx

Go to the 23:00 mark of the video and you'll see the 4 necessary steps:

  1. Reference Microsoft.IdentityModel.dll (need WIF SDK installed) a. Set copy local = true
  2. Create RegisterWIFGAC.cmd in your web role project
  3. Create Startup Task in ServiceDefinition.csdef that invokes RegisterWIFGAC.cmd
  4. Add GacUtil to the project (used in the startup task) to put Microsoft.IdentityModel.dll in the GAC every time the web role starts).
Andrew B Schultz
  • 1,512
  • 1
  • 23
  • 41