Sunday, April 7, 2013 #

TechEd India Data: Exposing Azure Mobile Services through Web API

For those who attended my session at TechEd India 2013, one of the topics I presented was, on Azure Mobile Services.  I also presented on new enhancements to ASP.NET with the Visual Studio 2012 Fall Update. 

As a mixture of both the sessions, I mentioned about building a Web API feed for Tech Ed Data that could be consumed through Azure Mobile Services.

If you are new to Azure Mobile Services, you can read up about from

Azure Mobile Services is best consumed through client apps such as Windows 8, iOS and Android Apps.  Recently, we also launched the HTML5 Apps template for Azure Mobile Services and CORS Support.

However, if you would like to use this in a ASP.NET Application, particularly, Web API, there are a few hops to make.

I decided to expose TechEd India data (Speakers, Schedule, Sessions, Tracks and Sponsors data) as an Azure Mobile Services.  That was good for me to build a Windows 8 App.

When I wanted to expose this in Web API, I had to do couple of things

1. Create Client Classes for each of the Mobile Service Tables. 

2. Create a Web API Controller for each of these classes which would make a HTTPClient request to the Azure Mobile Services.

I found this article handy

I pretty much created an API Controller each for Speakers, Tracks, Sessions, SessionsBySpeaker etc.,

Note that, in Azure Mobile Services, these are dummy tables that build upon the original tables to query a JOIN between related tables.

Finally, once you create the API Controllers for each of these classes, I hosted the app on Azure so that it can be consumed as JSon Data.  Note that, if you enable “Read” access for Everyone in the Permissions tab for Azure Mobile Service Table, you can achieve the same functionality.  However, Web API allows you to, a. add a logical layer between Mobile Service and Client Apps.  b. It also allows you to expose OData Queries on top of the Data.  I have provided the currently available URLs. Requesting them should provide you jSon Data.  Hope you find it useful.




Track Sessions:  

You could do a OData Query on this, for example,$top=1

As of now I have only exposed the GET Methods.  In future, I would refine it to allow all operations.

I don’t know how long I would be able to host this service.  Till then, enjoy!


Posted On Sunday, April 7, 2013 8:58 PM | Comments (5)