Introduction
Windows Azure Mobile Service is a tool that can integrated with the Windows Azure cloud. This tool will help you to connect a cloud backend to your Windows 8 application. The goal of the Windows Azure Mobile Service is to make Windows Azure the obvious choice for the Windows 8 Metro style application developer. Currently we can only use the Windows Azure Mobile Service in Metro style applications but in the near future the mobile service can also work with iOS, Android and Windows Phone.
Using the Windows Azure Mobile Service, a developer can easily store structured data in the cloud that can be used for both the device and the user, to easily authenticate a user and easily communicate with the WNS (Windows notification Service) for sending Push Notification. (Toast, Badge and Tile.)
Getting Started with Windows Azure Mobile Service
As I already mentioned the Windows Azure mobile service is a new tool that can be integrated with Windows Azure. So if we want to use the Windows Azure Mobile Service then we need to create an account in Windows Azure. Click here to sign up for a 90 days free-trial. Once you are signed-up, click the "preview features" section under the "account" tab of the http://www.windowsazure.com/en-us/ website and enable your account to support the "Mobile Services" preview. Instructions on how to enable this can be found here.
- Create mobile service application.
- Quick Start page
- Dashboard
- Create data table in mobile service application.
- How to script work in portal
- Insert
- Update
- Read
- Delete
- How to set permission to work in the portal
- Every one
- Anybody with the application key
- Only Authenticated Users
- Only Scripts and Admins
- Push Notification
- Connect with Live SDK
- Configuration of mobile service
- Scale
- Logs
1. Create mobile service application
Creating a mobile service in Windows Azure is quite easy. Log into Windows Azure with your credentials and click on the "+New" Button from the bottom-left corner. Look at the following image:
Select "Compute --> Mobile Service" and then click on Create.
The portal will popup a dialog box and ask you to enter a valid application name.
The Azure portal asks the user to choose the database, either a new database or an existing database.
New Database
The "New Database" option allows the user to create a new database in a new server or in an existing server. To create a database use the following steps:
Step 1: Click on the New button and create a mobile service
Step 2: Enter a valid name and select "Create a new SQL database" from the database
Step 3: Move to the next step by clicking on the next icon
Step 4: Enter a valid database name into the Name textbox.
Step 5: Select "New SQL Database Server" for creating a new server and store your new database in it.
Step 6: Enter the required value and move to the next
The user can also set a database size by clicking on the "Configure advanced database settings" checkbox. Once the user has checked this check box the portal will add one more page and wait for the user to move to the next.
Click on the next icon and set the database size according to the user application. Look at the following image:
A Web related application can select web edition and a business related application can select business edition but that is not mandatory.
If everything is working perfectly then the Azure portal will create a brand new mobile service within 30 seconds. Look at the following image:
Existing Database
The user can also use an existing database in its mobile service application. Use the following steps to create a mobile service application with an existing database.
Step 1: Click on the New button and create a mobile service
Step 2: Enter a valid name and select "Use an existing SQL database" from the database
Step 3: Move to the next step by clicking on the next icon.
Step 4: Select an existing database name from the database combo box and enter the database credentials.
Step 5: Press ok to create the application.
If everything is working perfectly then the Azure portal will create a brand new mobile service within 30 seconds. Look at the following image:
2. Quick Start Page
A Quick start page provides the facility to integrate your mobile service application with the new Window 8 apps or use an existing Windows 8 app to connect your mobile service. Use the following steps for that.
Step 1: Click on Mobile service from the Azure portal and then click on the mobile application that you just created.
Step 2: Click on the Quick startup page if it is not opened by default; see:
The Quick startup page provides a way to connect your mobile service with the Windows 8 application within 3 minutes. The Quick start page helps users to download a sample Windows 8 project or use a newly created mobile service in the existing project. Use the following steps for that.
1. Click on the "Create a new Windows store app" link and read all the information carefully
Get the Tools: The user can set up a machine environment by downloading VS and the Mobile service SDK.
Create a table: Create a TodoItem table for a C#/JS project by clicking the "Create TodoItem table" button.
Download and run your app: Download a C#/JS project and test your mobile service.
2. Click on the "Connect an existing Windows Store app" and read all the info carefully. This operation assumes you already have a Metro style application.
Get the tools: Setup mobile service SDK
Connect your app: select the programing language and copy the code which is shown by the portal in a Gray Square
Store data in your mobile service: This is an optional step if you don't have any other table then you can create an item table and copy and paste code in your project.
The Quick start page also provides a help link to know about the Authentication and Push notification. I will explain both Authentication and Push notification later in this article.
3. Dashboard
The Dashboard page is designed to show the mobile service details in three formats.
Graph: A graph will show the users data in a graphical format. The user can see their data by hour, day and week.
Usage Overview: It shows overall usage of the user's space. Such as memory usage, data out and CPU time.
Quick Glance: It shows general info of the application and subscription info of the user.
4. Data
This is the page where the user can create a table to store their data. The user can create as many tables as they want. Creating a table is very simple, just click on the create button from the bottom of the footer. The Portal opens a popup dialog box once the user hits the create button and asks the user to enter a table name and set its permission. See the following image:
The user can set access permissions of the table. Mobile service provides four types of permissions for tables in general.
Table contains the following tabs in it:
- Browse : This page displays all data stored in the table.
- Script : Script page helps the user to run scripts on the server side, a script can help the user to validate their input and many more. The Portal provides four types of scripts:
- Insert script
- Update script
- Del script
- Read script
- Columns : Used to display a structure of the table such as column name and its data type and it also displays a column index if it is set by the user. The user can set an index in all the basic data types provided by the portal (String, Date, Number and Booleans).
- Permissions : Permission is used to provide accessibility of the table. The permission page allows a user to add permissions on the table. The Portal is providing four types of permissions.
Every one:
All users can have the access permission and they can perform Insert, Update, Delete and Read on the table.
Anybody with the Application Key:
Only the user can have the access permission that has the application key.
Only Authenticated User:
Only an Authenticated user can have access to perform their task. Windows 8 apps authenticate by connecting to Live. In the near future, the mobile service can also be integrated with Facebook, Twitter and Google. All users who use this account will all come under an authenticated user.
Only Scripts and Admins:
This permission needs a master key to perform the operation. The mobile service user can get the master key by clicking on the Manage key button which was in the Quick startup page. This permission limits the operation only to registered scripts or to administrator accounts.
5. Push
Push notification is a feature of the mobile service. The mobile service can easily allow a user to connect to the WNS (Windows Notification Services) server and send a Toast, Tile and Badge.
To work with push in the mobile service the user needs to provide their client secret and Package SID (which you can get by registering your application on the Live dash board. Click here to learn more about how to register an application on the Live dash board). Use the following image to set up the push tab in a mobile service:
Add your Client secret and Package SID key (which you get from the live dashboard) in the portal and click on the save button to save your changes.
6. Identity
A Identity page is designed to provide live connectivity, so the user can use their Live credentials. It is very easy to connect using the Live SDK using Window Azure. The Portal only needs the client's secret key which you can obtain from the Live Dashboard by registering your application (Click here to learn more about how to register an application on the Live dashboard). If your application registers on the Live dashboard successfully then you have a client secret key and package name. Copy your client secret key and paste it in the Identity page.
If you noticed, the Push and identity tab both have the client secret text box and both are the same. If you save your client secret key in one of the pages then the portal can consider that key for both the pages.
7. Configure
This page simply designs the setting of some configuration of the mobile service. The following configuration settings are provided by the configure tab:
- Change Database: The Change database setting allows you to change the existing database and a new database by clicking on the CHANGE DB option.
- Dynamic Schema: Dynamic schema is one of the features of the mobile service. In other words a Dynamic schema automatically creates a table structure. The Portal allows the user to enable or disable the Dynamic schema.
- Manage Key: The user can also change their application key and master key by clicking on the manage key button
8. Scale
The Scale tab allows the user to scale their Windows Azure SQL database, switching the server mode and server reserved capacity. The Scale tab provides two mobile service modes:
- Shared mode : In Shared mode, all mobile services share the servers and are created in the same geographical region.
- Reserved mode : In Reserved mode, all mobile services in a given region run on dedicated virtual machines. The Reserved mode provides your sites more processing power and performance and allows you to scale your instance count and size.
- SQL Database : In a SQL Database, the user can change their database size or also switch them into Web or Business.
Note: once you have set reserved mode from the scale tab, all your mobile applications in the same region is run in reserved mode.
9. Logs
The Logs page is designed to write system and script errors generated by the Windows Azure mobile service. The mobile service allows the user to define their custom business logic and they can run it on the server side. The mobile service server can accept a business login by a JavaScript function, these JavaScript functions are registered in an insert, update, delete and read operation on the table.
Reference:
http://msdn.microsoft.com/en-US/library/windowsazure/jj554226
http://www.windowsazure.com/en-us/develop/mobile/tutorials/get-started/
http://www.windowsazure.com/en-us/develop/mobile/resources/