Updating a Windows Azure Mobile Services project: Method not found

I've always tried to stay as much on the bleeding edge as possible. I used to donwload new version of Windows or Visual Studio as soon they released a public alpha or beta version.

I don't like to use outdated software, and the same goes for the software I rely on to build my own software.

So it was obvious that I should update all these outdated Nu Get packages in my new Windows Azure Mobile Services (ZUMO) project for Høst, only to discover some pretty serious Yellow Screens of Deaths (YSoD).

I got this nasty error, as soon as I ran the project after updating the Nu Get packages: Method not found: 'Void System.IdentityModel.Tokens.JwtSecurityTokenHandler.set_CertificateValidator(System.IdentityModel.Selectors.X509CertificateValidator)'

A quick search revealed a Stack Overflow answer instructing to revert to version 1.0.342 of the WindowsAzure.MobileServices.Backend package which is almost 6 months old.

Instead of doing that, I created a brand new ZUMO project and copied the packages.config file along with everything from the bindingRedirect section of Web.config. And of course, you need to change the project file (csproj) and all the references to the Nu Get packages you just changed. This is roughly everything in the first <ItemGroup> element, but keep in mind that you may already have some of your own dependencies in this section that you need to keep.

All this left me on version 1.0.405 of the WindowsAzure.MobileServices.Backend package which is from October - so a little better. But more importantly, this is the version that is actually running in Windows Azure right now, so you should aim to always match that.

Perhaps the biggest issue for me in all this, is that stuff is being released to Nu Get that isn't in production yet. I looked at the releases of the GitHub repo the Nu Get package refers to, and the versioning is completely out of order compared to the package versions. I have no idea how they do versioning, but from the outside it seems a little chaotic.

Seeing the current version of ZUMO

Since there's no way to count on either their Nu Get or GitHub versioning, I wanted to find a way to detect which version of Mobile Services my app is running when deployed to Azure. I usually add my own version number to either the footer of every pages for web apps, or a dedicated status page - but since this is an API I wanted to expose the information by providing an endpoint I can issue a GET request to.

So I write this AppStatusController that exposes a single action that returns the version for my own app, and the version of the Microsoft.WindowsAzure.Mobile.Service assembly.

A little side note, I actually named the controller StatusController and couldn't grasp why it wasn't showing up in the Web API Help pages when viewed locally. It turns out that there's a default StatusController that returns a simple health status message when issuing a GET request to /api/status. The message I got was this: { "description": "The service is considered to be in a healthy state." }

So I renamed the controller of mine to AppStatusController and right now it exposes one action named Version. Sending a GET request to /api/appstatus returns the version of my app and ZUMO: {"appVersion":"","zuMoVersion":""}

The code for that controller is right here:

I protected by setting AuthorizeLevel to Application which means you must specify the X-ZUMO-APPLICATION HTTP Header. If you don't care about security of that endpoint, just remove the attribute entirely.

To make your life a little easier when running the service locally, go ahead and change both MS_MasterKey and MS_ApplicationKey appSettings in Web.config to a single character value, or something short you can remember. When testing authentication, you need to add config.SetIsHosted(true) to the WebApiConfig class which casues basic authentication on all help pages. These expect the value from MS_MasterKey so if you just put the letter a in there, you won't forget and doesn't have to copy paste the value from elsewhere.

Have fun with ZUMO, I know I'll be experiencing further issues over the coming weeks but can't wait to see the power of Azure.