Building Windows 8 blog
Windows Store for developers blog
Visual Studio blog
The Windows blog
Inside SkyDrive blog
Download Windows 8 Release Preview
Windows Dev Center
Follow us @WinDevs
The //build/ conference
Developer forums
Great Windows Store apps are connected. They use live tiles, authenticate users with single sign-on and share data between devices and users. To get all these great benefits of being connected, your app needs to use services in the cloud.
Building cloud services is hard. Most cloud platforms offer general purpose capabilities to store data and execute code, but you have to author reams of infrastructure code to glue these capabilities together. I’m sure you are up for the challenge, but I bet backend infrastructure code is not your first priority. You want to focus on realizing your awesome app idea.
Addressing this difficulty, earlier this week we announced a preview of the new service in Windows Azure: Mobile Services. Let me show you how you can add the cloud services you need to your app in minutes, using Mobile Services.
To get started, sign up for the free trial of Windows Azure. You’ll get 10 Mobile Services for free. Let’s use one of them to build a simple todo list app.
Figure 1. Create drawer in the management portal.
Figure 2 Create Mobile Service wizard, first screen.
Figure 3. Create Mobile Service wizard, second screen.
Click the tick button to complete the process. In just a few seconds you’ll have a Mobile Service – a backend that you can use to store data, send push notifications and authenticate users. Let’s try it out from an app.
Figure 4. Your newly created mobile service.
You now have two choices: to create a new app, or to connect an existing app to your Mobile Service. Let’s pick the first option and create a simple todo list that stores todo items in your SQL database. Follow the steps on the screen:
Figure 5. Creating a Mobile Services app.
Figure 6. Completed app.
Let us take a look at the code inside the app that saves your data. Stop the todo list app and double-click on App.xaml.cs. Notice the lines:
public static MobileServiceClient MobileService = new MobileServiceClient( "https://todolist.azure-mobile.net/", "xPwJLJqYTMsAiBsHBHDhDEamZdtUGw75");
This is the only code you need to connect your app to your Mobile Service. If you are connecting an existing app to your Mobile Service, you can copy this code from the quick start “Connect your existing app” option. Now, open MainPage.xaml.cs and take a look at the next code that inserts data into the Mobile Service:
private IMobileServiceTable<TodoItem> todoTable = App.MobileService.GetTable<TodoItem>();private async void InsertTodoItem(TodoItem todoItem){ await todoTable.InsertAsync(todoItem); items.Add(todoItem); }
This is all that’s needed to store data in your cloud backend. Here is an equivalent code in JavaScript:
var client = new Microsoft.WindowsAzure.MobileServices.MobileServiceClient( "https://todolist.azure-mobile.net/", "xPwJLJqYTMsAiBsHBHDhDEamZdtUGw75");var todoTable = client.getTable('TodoItem');var insertTodoItem = function (todoItem) { todoTable.insert(todoItem).done(function (item) { todoItems.push(item); });};
Go back to the Windows Azure Management Portal, click the Dashboard tab to see real-time monitoring and usage info for your new Mobile Service.
Figure 7. Mobile Services dashboard.
Click the Data tab and then click on the TodoItems table.
Figure 8. Data tab.
From here you can browse the data that the app inserted into the table.
Figure 9. Browse data.
In this brief overview we’ve looked at how easy it is to add the power of Windows Azure to your app without the drag that comes with authoring, managing and deploying a complex backend project. We’ve only scraped the surface of what you can do with Mobile Services. Here’s a teaser of some of the other features that are ready for you to explore.
Learn more about Mobile Services at http://www.windowsazure.com/mobile.
--Kirill Gavrylyuk,, Lead Program Manager, Windows Azure