Skip to main content

Azure Mobile Services (Day 14 of 41)

List of all posts from this series:

Short Description 
Mobile Services are a collection of Azure services dedicates to developers that are developing mobile application. This services can be your best friend if you are developing a mobile application that requires backend.
With a minimal development time, you can build your application backend without needing to invest time, energy or money. Mobile Services is a solution cross platform, meaning that you can use it as a single backend for your iOS, Adroid or/and Windows Apps.

Main Features 
Push support
There is full support for push mechanism, which give us the ability to push content to our applications. The most interesting things is how you push the content. You can push the same content for all your mobile clients (even if there are WP clients, iOS or Androids) clients. The API give us the ability to push the content in the same way.
Broadcasting support
Can be used with success to push not only one notification to one client, but we can also broadcast notifications and messages to them.
Single Sign-On
In combination with Active Directory we can create application dedicated to enterprise segment that use Single Sign-On support of Active Directory.
Offline/Online support
There is full support from Mobile Services to create applications that can work in both ways and that are able to synchronize the data content in the moment when a connection is available.
Mobile Services can be used to monitor your application and know the health of your application, create client profiles and many more.
This service is not create for 10 clients, 100.000 clients. This is the kind of service that can scale very easily from 10.000 clients to 10M clients very easily and in the same time you will play only what you use - nothing more.
Social Integration
We have support for different authentication mechanism. On top of Active Directory, we can use as authentication mechanism Facebook, Google or Twitter. The client part is full managed by the library. Because of this, for example, you can integrate Facebook authentication in less than 15 minutes.
Support for different databases
Mobile Services give us the possibility to integrate and use different databases from Oracle or SQL to NoSQL databases like MongoDB. Because this is a flexible and adaptive solution integration with different providers and services is not complex or time consuming.
Secure Connection
An enterprise connection is not only about authentication. We need to be able to establish secure connection to different on-premises resources. From this perspective, Mobile Services is perfect. We can establish a secure connection and use on-premises resources from SAP, Oracle, SharePoint or SQL Server.
Full support from Xamarin and PhoneGAP
Mobile Services is already supported and integrated by PhoneGAP . We can create application using cross-platform solution without any kind of problem.
Fast start
Once you create a Mobile Services service on Azure, you can download a clean project for each mobile platform that is already configured to communicate with your backend. In this way you don’t need to lose time for configuration.
Real-Time communication
The application can have a real time communication between each other and with out on-premises resources. In this way you can create applications that send and receive data to other resources with a minimal latency.
Data Storage
We are allowed to store data SQL, Table Storage or MongoDB by default.
Full access control to resources
This service enable us to have a granular access control for each user. For example we can allow only to a specific users to access data from a specific table. In this way we can keep user personal data in a secure way that is offered out of the box.
Data can be stored in table that are created inside Mobile Services. This tables can be managed easily and we have also support for custom triggers.
JavaScript for triggers
The language that can be used when we need to define a trigger is JavaScript. This is a well know language – because of this developers don’t need to learn a new (another) language.
Scheduling support
There is full support to define scripts that can run at a specific time interval. For example we can schedule cleaning steps to run every day at a specific time.
Custom API and backend
Yes. We have the ability to define custom backend and expose it as an API that can be consumed by our mobile applications. Using this feature, we can extend the capabilities of Mobile Services with the one that we need.
HTML and web application support
Beside mobile application, we can use Mobile Services for our web application. All the services are exposed as REST API that can be consumed and accessed by web application also.
Debug Support
This is a very nice feature that allow us to debug our code that runs on Mobile Services. For example we can very easily debug JavaScript code that is written by us and runs on Mobile Services. In this way we don’t need to use the modify and test approach when we have a problem.
GIT Integration
We have support to integrate Mobile Services with GIT and make deployment directly from out GIT account.

For normal mobile applications I don’t see any kind of limitations that could be blockers. We could have issues if we create mobile application that needs a lot of CPU resource power on the backend. In this scenario we may need on top of Mobile Services another source of CPU power, but this are special use cases and we should handle with care.
For example data reporting over a database should not be done by Mobile Services. The reporting part should be made by another services of components.

Applicable Use Cases 
Below you can find 4 use cases when I would use Mobile Services.
Tracking Application
A mobile application that can track user’s location can use a backend Mobile Services. We could use this service not only to store user GPS location, but also create different view of data or notify other users when a specific other users if a user is in trouble.
User personal settings
Because nowadays, a person has more than one smart device (tablet and phone for example) we need a mechanism to synchronize user data. In this case we can use Mobile Services as a synchronization platform that allow users to have the same configuration on phone and tablet.
Sharing ideas app
Because we have the ability to share content with specific users (table content) we can create a ‘social’ networks that allow uses to share their ideas with friends and family. For a use case like this, the backend implementation would be very simple.
Notification broadcasting
Mobile Services allow us to broadcast messages to Android, iOS and Windows Apps. For scenarios when we need to broadcast notification to devices that are on different platforms, this service can be used with success.

Code Sample 
// Connect to Mobile Services
MobileService mobileService= new MobileServiceClient("","[secretKey]");

// Get data from a table
var carTable = mobileService.Context.Current.MobileService.GetTable<Car>();
var car = await ticketTable.LookupAsync(carId);

Pros and Cons 

  • Integration with different social vendors
  • JavaScript language support for custom backend code
  • Simple to use
  • Extensible
  • Data Access management  
  • Cross-Platforms
  • Strong Notification infrastructure


When we want to calculate the cost how much Mobile Services would cost we need to take into account the fallowing components:

  • Number of API calls
  • Number of devices
  • Number of units (for scaling)
  • Number of push notifications
  • Support for offline sync
  • Backend tasks complexity and volume
  • Outbound data traffic

I think that Mobile Services is a good options to create the backend of our mobile applications.
It can be a good solution not only for enterprise but also for startups when resources are limited (money and time). If I would be a startup my first option for backend would be Mobile Services.


Popular posts from this blog

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine:
threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration:

TeamCity.NET 4.51EF 6.0.2VS2013
It seems that there …

Entity Framework (EF) TransactionScope vs Database.BeginTransaction

In today blog post we will talk a little about a new feature that is available on EF6+ related to Transactions.
Until now, when we had to use transaction we used ‘TransactionScope’. It works great and I would say that is something that is now in our blood.
using (var scope = new TransactionScope(TransactionScopeOption.Required)) { using (SqlConnection conn = new SqlConnection("...")) { conn.Open(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = conn; sqlCommand.CommandText = ... sqlCommand.ExecuteNonQuery(); ... } scope.Complete(); } Starting with EF6.0 we have a new way to work with transactions. The new approach is based on Database.BeginTransaction(), Database.Rollback(), Database.Commit(). Yes, no more TransactionScope.
In the followi…

GET call of REST API that contains '/'-slash character in the value of a parameter

Let’s assume that we have the following scenario: I have a public HTTP endpoint and I need to post some content using GET command. One of the parameters contains special characters like “\” and “/”. If the endpoint is an ApiController than you may have problems if you encode the parameter using the http encoder.
using (var httpClient = new HttpClient()) { httpClient.BaseAddress = baseUrl; Task<HttpResponseMessage> response = httpClient.GetAsync(string.Format("api/foo/{0}", "qwert/qwerqwer"))); response.Wait(); response.Result.EnsureSuccessStatusCode(); } One possible solution would be to encode the query parameter using UrlTokenEncode method of HttpServerUtility class and GetBytes method ofUTF8. In this way you would get the array of bytes of the parameter and encode them as a url token.
The following code show to you how you could write the encode and decode methods.