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 http://www.windowsazure.com/en-us/develop/mobile/

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 http://www.strathweb.com/2012/09/using-azure-mobile-services-in-your-web-apps-through-asp-net-web-api/

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.

Events: http://techedindia2013.cloudapp.net/api/events  

Speakers: http://techedindia2013.cloudapp.net/api/speakers

Sponsors: http://techedindia2013.cloudapp.net/api/sponsors

Track Sessions: http://techedindia2013.cloudapp.net/api/tracksessions  

You could do a OData Query on this, for example, http://techedindia2013.cloudapp.net/api/speakers?$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!

Cheers!!!

Print | posted on Sunday, April 7, 2013 8:58 PM

Comments on this post

# re: TechEd India Data: Exposing Azure Mobile Services through Web API

Requesting Gravatar...
If you want a greener floor, you'll want to choose something that has the smallest carbon footprint possible. - Larry Starr Sarasota
Left by chantal2013 on Jan 30, 2014 3:49 AM

# Awesome post

Requesting Gravatar...
Haven't any expression to like this post… ..Really i am inspired from this post… .the individual who make this post it was an incredible human..thanks for imparted this with us. Web Design Company in Delhi
Left by jeremywilliams on Apr 25, 2014 4:42 PM

Your comment:

 (will show your gravatar)