Connect your Windows 8 applications to the Cloud

The Windows Azure Mobile Services (WAMS) is a new offering of Microsoft Azure cloud platform that simplifies the implementation of software architectures that addresses the type of environment and challenges that includes;

  1. Multiple devices and Operating system’s to support.
  2. Applications that rely on asynchronous Web services, typically hosted in the cloud.
  3. Variable traffic that complicates resource planning and provisioning.

Windows Azure Mobile services supports all major mobile application development platforms i.e. Windows 8, Windows Phone, IOS and Android, that is why it is termed as “Mobile Services” because it is based on open standards.

Windows Azure Mobile services empowers a developer to add a cloud based backend to their application easily & instantly, allowing users to store relational data into SQL database, binary objects into Storage/Containers, encoding of media files and so on, so that you focus on application logic instead of infrastructure.

The major features of Azure Mobile Services are

  1. Authentication
    Provides authentication/User Login feature into your application, it supports multiple providers i.e. Microsoft Live ID, Facebook, Google and Twitter.
  2. Data
    Provides an interface to interact with your SQL Azure database and perform CRUD operations asynchronously.
  3. Push Notifications
    Provides a simplified way to send Push Notifications by attaching a notification channel to the inserted record.


Mobile Services with Windows 8

Now lets go ahead and create a simple application that will be connected to our SQL Azure database to demonstrate the simplicity and power of Mobile Services.

[Note: You can signup for Free 90 days trial of windows azure by visiting ]

Configuration on Azure Portal

First, we are going to create a Mobile service in our Windows Azure portal and make necessary configurations.
Go Ahead and login to your azure developer portal,

  1. Click “NEW” at bottom left corner and go to “Compute > Mobile Services >  Create”


  2. Provide a name(subdomain) to your Mobile Service, select “Create a new database instance” (incase you have not setup any database earlier), select your nearest region and click next.


  3. Enter the database name, and database server details, I have created a new database server to keep things simple, once everything is filled, click OK to create your Mobile Service.


    It will take few moments to create your mobile service.

  4. After everything is completed, you will see your mobile service status as “Ready” and a URL.
    Copy this URL, we will be needing this URL to connect our client with the mobile service.

  5. Click “Manage Keys'” at the bottom and copy “Application Key”.
    We will be needing this Application Key to connect our client with the mobile service.


  6. Go ahead and click your Mobile Service name, and click on “DATA” tab, located at the top.


  7. Click “Add a Table” to create a new data table in our SQL database.
    You can set permission on the table, so that only authenticated users can perform few or all operations. for now I am leaving it to default.


Connecting Windows 8 Application to our Mobile Service

Now, we have our Mobile service with a employee table UP & running, Lets move to connect our windows 8 application with the mobile service we just created to store & retrieve data.

Before we jump into the coding part, you have to installMobile Services SDK”.

  1. Create a new Windows Store application.
  2. Add a reference of “Windows Azure Mobile Services Managed Client” into your project.
  3. Open App.xaml.cs and add the following code.

    public static MobileServiceClient MicMobileService  = new MobileServiceClient( "URL", "Application Key" );

  4. Create a new class, name it “Employee” and add your desired properties. My class looks like this

    class Employee {
    public int ID { get; set; }
    public string Name { get; set; }
    public string Email { get; set; }
    public string Department { get; set; }
    public int Phone { get; set; } }
      Note: This class will represent our entities in the database, the approach similar to Entity Framework (ORM).
  5. Open your MainPage.xaml, insert few textboxes and a button to insert a new employee data into the database.


  6. On the Click Event Handler of “Add Employee” button add the following code.
    private async void Button_Click_1(object sender, RoutedEventArgs e) 
    MessageDialog msg; Employee item = new Employee {
    Name=name.Text, Department=dept.Text, Email=email.Text,
    Convert.ToInt32(phone.Text) };
    await App.MicMobileService.GetTable<Employee>().InsertAsync(item);
    msg =
    new MessageDialog("Employee added successfully");
    catch (Exception es)
    msg =
    new MessageDialog("Error has been occured \n" + es.Message);
  7. Now if you run the project and add a record, you would probably see a success message like this.


  8. Just to cross check, Go back to your Azure portal, click on your Mobile Service, go to DATA tab, select your “Employee” table and under
    Browse” tab, you will see your recently inserted data.



By using Windows Azure Mobile Service (WAMS), we have hooked up our client application with windows azure by typing only few lines of code., and our application can be scaled up instantly with the help of instantly scalability features of Windows Azure.

There is another feature called “Scripts”, that allows you to perform some specific operations (server side validation, push notifications, files manipulation etc. ) on each CRUD operation into the table. (depending upon your business logic),

Comments (7)

  1. Arsalan Adam Khatri says:

    awesome blog post, keep up the good work

  2. QSOFTSolution says:

    I knew it is available in VS.2012 but the article is clearly and nicely written , step by step defined and easier to follow.

    Good job Umer – I must say that!

  3. Faisal Qazi says:

    Excellent (Y)

  4. Muhammad Zeeshan says:

    Excellent Artical (Y)

  5. Mehak Zia says:

    sir i am facing an issue in step 6. On my screen there is no 'data' hyperlink…

  6. @Mehak, that's because in option 2, you've chosen .NET as backend script. You need to choose JavaScript as backend for Data tab to be visible. Azure has evolved a bit since this post was made. Good Luck.

  7. Mehak Zia says:

    Thanku so much sir it helps a lot…

Skip to main content