What you should know about Azure Mobile Services

If you are developer, you may have heard of this buzzword floating around lately. After seeing a VERY impressive demo (starts around 1:08 mark with Josh Twist) of it last week in AzureConf, I decided to spend invest some time in exploring it. I learned a ton, and I wanted to write some of this down while it’s still fresh in my head.

What are Azure Mobile Services?
In short, it’s a PaaS offering in Azure which gives you a RESTful front-end in front of a database. It also automatically supports OAuth and using social logins, and it also supports offline syncing for all platforms. That means your phone app can be disconnected and add/remove/update data – and then “sync” when they have a cell signal again. This is natively supported for iOS, Android, Windows Phone, and Windows Store (at least).

Imagine you had a website where you created your WebAPI REST services over your database. That is what Azure Mobile Services is – but it also includes the OAuth support, and client libraries for connecting, for each platform. So, it’s almost like a pre-built backend for “any” kind of application. Best of all, you don’t have to write the code, you can just use it as a service, via their SDK.

Despite the name – this can, and arguably should, be used for every platform as the sole, common backend of y our app. What I mean is, what is the ideal state for any public application, nowadays?

  • Available on all platforms: iOS, Android, Windows Phone, Windows Store, (and Blackberry, Amazon Fire Phone/TV, etc)
  • Offline support and syncing for the mobile devices
  • Available as a website

If you were to take this on (as many companies have and do), this is a pretty big project. Just the logistics of having a common database, re-using as much code as possible, then trying to sync it – it’s… a lot. It’s a lot of planning, and a lot of code on every platform.

Azure Mobile Services can be a central, common, very-secure back-end to your “application” regardless whether it’s web, windows, or mobile. It simplifies several significant things for you, including handling all of the OAuth stuff, syncing, committing and merging data – as well as simple client library for each platform (including .NET, JavaScript, and the mobile platforms) to managing all of this.

If it helps, here’s how I imagine this:

image

A web application and your mobile app (on a variety of platforms) connect to the Azure Mobile Service for it’s backend. The backend authenticates every app either at the app level (using the key/token for the app) – or using OAuth, forcing the end-user to authenticate via one of the supported providers.

One authenticated, the Azure Mobile Service serves up data for JUST that user, making it difficult/impossible for anyone to hack.

Getting Started:
The bad news is that to use all of this technology – is multi-disciplinary, and somewhat complex. If you want apps on every platform, then you need to be familiar with OAuth, asynchronicity, and then the technology for each platform too.

They’ve made it as simple as possible, but it’s still just a complexticated topic. The good news is that they’ve done a really exceptional job at GENERATING sample code specific to your Azure Mobile Service, and the documentation is thorough and high-quality.

To start, I’ll assume you have an Azure account – so you’d navigate to https://manage.windowsazure.com

You can click the “+” in the bottom left and choose: Compute –> Mobile Service –> Create and follow the prompts:

image

With this, I had (and still have difficulty). I wanted to pre-create my database server, and database, and have this connect to it. However, when I do that, I always get that the credentials are bad, and it won’t create the service. The only way around this that I found was to create a new database, and you can change where it points, later.

.NET vs node.JS
Another thing you’ll see in the Create wizard is the option for a node.js backend or a .NET backend:
image

This is significant and not as obvious as you might think. Here are the pros and cons I found, for each:

  • node.js
    • Pros: Super-simple, supports simple OAuth. You can use the Azure portal to manage the data and the API. You don’t have to write, modify, or maintain any of the back-end code. You use the Azure portal to do everything for the backend.
    • Cons: You simply can’t do some things. For example, node.js running in Azure is who makes your OAuth calls. So, if you want to change this – or make calls to get more user information, you simply can’t because you can’t include other JavaScript libraries or anything like that.
  • .NET
    • Pros: You have complete control over the back-end. Since your code (running in Azure) is making the OAuth calls, you can add code to go get user profiles – or whatever else you want the service to provide to all of your platforms.
    • Cons: More complicated. You have to maintain, manage, and deploy the backend code that IS your Azure Mobile Service. It’s not a lot of code, but you need to be careful not to break your entire app!

Bottom line, if you have a simple app and especially if you don’t need to get more detail about the user (if you are using authentication at all), then choose node.js. The management tools in the Azure portal are straight-forward and powerful. If you will to make other OAuth calls, or if you need custom code in your back-end service, then choose .NET. The portal will provide the code you need, and you just tweak it as necessary.

Getting Help:
The first thing I did was head to Pluralsight. I watched/skimmed most of Matt Milner’s session. It was pretty good for getting initially familiar with it – and it is worth a watch!

Windows Azure Mobile Services
http://www.pluralsight.com/courses/windows-azure-mobile-services

Next, one of the amazing things about Azure Mobile Services is that if gives you complete sample projects in a variety of languages and technologies – SPECIFICALLY wired up for your Azure Mobile Service! So, right on the Quick Start page:

image

As you might imagine, a project that you can download and run immediately is helpful. However, that is just a basic app. If you want to add authentication (OAuth), or do more complicated things, they have a series of walkthrough’s. These are really exceptional. They are thorough, they answered all my questions and best-of-all, they all work (or some needed the tiniest of corrections).

To get to all of the tutorials, start here: http://azure.microsoft.com/en-us/documentation/services/mobile-services/

Bottom line:
The bottom line for me after digging into this, is that this does appear to be as impressive as that demo suggests. This is a very clever, well-made solution for an application backend.

For my sample project, I created (and/or got working):

  • Web app, written entire in AngularJS – with all 4 OAuth providers. I did not try the push notifications though.
  • Windows Store app, with offline syncing.
  • Windows Phone app, with offline syncing.

It all worked with the sample code and the tutorials. So, for a project I’m working on now, I am going to move forward with using this as my back-end. I used node.js as the backend for my sample app, and ran into those OAuth roadblocks. So, I will use a .NET backend on my project.

I will likely have some blog posts about some other things I’ve learned. Generally-speaking though, the tutorials above answered most of my questions.

Posted in Azure, Cloud Computing, Computers and Internet, General, Infrastructure, Mobile, Mono, New Technology, Professional Development, Security, Uncategorized
One comment on “What you should know about Azure Mobile Services
  1. […] understood this concept or the term, I first learned of this from Azure Mobile Services. In fact I wrote about it here, about a year ago. However, last week I colleague Allan Gagnon posted a link to http://www.backand.com, […]

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archives
Categories

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 5 other followers

%d bloggers like this: