Thursday, September 13, 2012

Windows Azure Mobile Services

On August 28th, Microsoft announced an addition to the Azure platform, Windows Azure Mobile Services.  The capabilities seem very powerful and target easy development and deployment of mobile applications with a cloud-based backend service hosted on Azure.  While this is targeted at Windows 8 applications exclusively, it appears to scale very well into using a mobile-first approach to all of your Windows 8 applications, desktop or mobile.  The backend framework allows for direct access to SQLAzure data via the mobile service.  In fact, when you create a Windows Azure Mobile Service, it is automatically associated with a SQL Database inside Windows Azure.  This all happens without creating any custom server code.   The management portal includes the ability to create new tables, control access, view data and other administrative items.  By leveraging this infrastructure, developers can connect directly to their cloud-based data very easily without having any insight into the server side code.  The data can be automatically accessed and stored via a secure RESTful interface.  This allows a client side developer to quickly and easily connect any Windows 8 application to the new mobile platform and its data.

Here is a code snippet showing the mechanism for directly consuming mobile cloud based data.  The native interface supports LINQ based queries of POCO objects (strongly typed) via the RESTful interface.  This code will populate a presentation layer asynchronously without creating ANY server side code to handle it.

private void RefreshTodoItems()
{
    items = App.MobileService.GetTable< TodoItem >()
       .Where(todoItem => todoItem.Complete == false)
       .ToCollectionView();

    ListItems.ItemsSource = items;
}

At this point, you have built a data driven SOA that is able to be consumed directly by any windows 8 presentation layer.

Other items that are directly supported via the Azure Mobile Services are: push notifications, user authentication and  paged queries -- all with the native services provided.  It seems to be quite easy to directly connect your Windows 8 application to the mobile services in Azure.  The upside being that it makes developing a Windows 8 client based on a cloud solution very quick and easy.  The unanswered question is still how easily you can use this to consume data in cloud style without using a Windows 8 application.  It appears that it would be possible to directly hit this service from any application able to read JSON from a REST service, but all of the supporting documentation is focused on a Windows 8 client.  Either way, this is an exciting addition that should be investigated by those of us using Azure.