Microsoft Research Mobile Backend as a Service: Introducing Project Hawaii

 

Microsoft Research(MS Research) is an infinite source of technical innovation. Because of my academic background, I am constantly following the new MS Research projects and drawing ideas and inspiration from them. Recently, I came across Project Hawaii (http://research.microsoft.com/en-us/projects/hawaii/ ) which provides a set of mobile services hosted in Windows Azure for computational and data storage. Sounds familiar? Yes, Project Hawaii overlaps slightly with Windows Azure Mobile Services but it focuses on new and innovative service capabilities. In this first release, Project Hawaii enables the following capabilities:

·        The Key-Value service enables a mobile application to store application-wide state information in the cloud.

·        The Optical Character Recognition (OCR) Service returns the text that appears in a photographic image. For example, given an image of a road sign, the service returns the text of the sign.

·        The Path Prediction Service predicts a destination based on a sequence of current locations and historical data.

·        The Relay Service provides a relay point in the cloud that mobile applications can use to communicate.

·        The Rendezvous Service maps from well-known human-readable names to endpoints in the Hawaii Relay Service.

·        The Speech-to-Text Service takes a spoken phrase and returns text. Currently this service supports English only.

·        The Translator service enables a mobile application to translate text from one language to another, and to obtain an audio stream that renders a string in a spoken language.

 

Obviously, given my recent work in the mobile backend as a service (mBaaS) space, Project Hawaii results super interesting to me. After spending a few hours playing with the current release, I thought the experience would make a few interesting blog posts.

Let’s start with the Hawaii’s key-value service:

Project Hawaii’s Key-Value Service (KVS) provides a simple key-value store for mobile applications. By using the KVS, an application can store and retrieve application-wide state information as text using key-value pairs.

Obtaining a Project Hawaii Application ID

Prior to use any of the Project Hawaii services, developers need to obtain a valid application ID. We can achieve that by going to the Project Hawaii signup page (http://hawaiiguidgen.cloudapp.net/default.aspx.)  and registering your Windows Live credentials. After that, you will obtain an application identifier that can be used to authenticate to the different cloud services. As illustrated in the following figured.

 

After having completed this process, we need to register our application in the Windows Azure Marketplace.

 

Using the Project Hawaii Key Value Service

As its name indicates, the key-value service provides a service interface that enables mobile applications to store information in key-value pair forms. The main vehicle to leverage this capability is a RESTful interface abstracted by SDKs for the Android, Windows Phone and Windows 8 platforms. In the case of Windows 8, the KeyValueService class included in the Microsoft.Hawaii.KeyValue.Client namespace abstracts the capabilities of the Project Hawaii Key-Value service. The following matrix summarizes some of the operations provided by the KeyValueService class.

Methods

Name

Description

CreateAsync

Initiates a call to create a key-value item. The item must not already exist.

DeleteAsync

Initiates a call to delete key-value items.

DeleteByKeysAsync

Initiates a call to delete key-value items by keys.

GetAsync

Initiates a call to get key-value items.

GetByKeyAsync

Initiates a call to get key-value items by key.

GetByKeysAsync

Initiates a call to get key-value items by keys.

SetAsync

Initiates a call to set one or more key-value items. If the key does not exist, the method creates it.

Like any good mBaaS SDK, the KeyValueService class provides a very succinct syntax to integrate with the Project Hawaii key-value service. For instance, the following code illustrates the process of inserting different items using the Project Hawaii key-value service.

 

 

private const string clientID = "My Client ID";

private const string clientSecret = "My Client Secret";

 

private void SetItem_Test()

{

KeyValueItem item1 = new KeyValueItem() { Key = "Key2", Value = "value2" };

KeyValueService.SetAsync(clientID, clientSecret, new KeyValueItem[1]{item1}, this.OnSetComplete, null) ;

}

 

 

private async void OnSetComplete(SetResult result)

{

        await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>

        {

                   if (result.Status != Microsoft.Hawaii.Status.Success)

                      Result.Text = "Success";

                   else

                       Result.Text = "Error";

            });

 

      }

 

 

 Similarly, applications can query items stored in the key-value infrastructure using the following syntax.

private void GetItem_Test()

{

  KeyValueService.GetByKeyAsync(clientID, clientSecret, "Key1", GetByKeyComplete, null);

}

 

Key-value storage can be a really useful capability in mobile applications. The Project Hawaii Key Value service provides a very simple mechanism to enable mobile application to leverage these capabilities using a very simple syntax.

We will cover other capabilities of Project Hawaii in future blog posts.

No Comments