Quick guide: Build a mobile app on Azure

All the major clouds offer mobile back ends as a service, but InfoWorld judged Azure's to be the best. Here's how to create a mobile app on Azure Mobile Services fast

Building mobile apps needn’t be hard, but it often is. You spend time rolling your own cloud services, integrating with various push services, building databases, even setting up single-sign on -- that is, installing the plumbing when you could be writing code instead.

To avoid doing it yourself, you now have the option of using MBaaS (mobile back end as a service). InfoWorld recently compared MBaaS offerings from Amazon, Google and Microsoft -- and rounded up several independent MBaaS providers last year -- all of which are designed to make it easier to build mobile applications.

MBaaS makes a lot of sense. As with cloud-hosted email, you’re handing over the infrastructure your app needs to a platform that’s designed to run at scale. You’re also taking advantage of its services and features, including SQL and NoSQL stores, as well as scalable Web servers and integration with platform-specific notification tools. An app written on one MBaaS system can send notifications to Apple’s, Google’s, and Microsoft’s services based on user preferences.

Google, Amazon, and Apple all have their cloud service platforms, with integrated mobile SDKs for the main device platforms, but Microsoft’s Azure Mobile Services has the widest selection of mobile endpoints for its cloud services. That's one of the reasons it was the winner in Martin Heller's comparative review.

Set up a mobile service on Azure, and you can target Windows (in all its flavors), iOS, Android, and HTML5, as well as cross-platform frameworks like Xamarin and PhoneGap. It’s an approach that lets you build one cloud service, then use the tools Azure provides to roll out appropriate endpoints as you need them.

Writing an app with Azure Mobile Services is relatively simple, with tools built into the Azure Portal to get you started. You’ll start by setting up a service host, with a database and a Web server for the REST endpoints, using the Compute section of the Azure portal. Choose the Mobile Service option, and click Create.

You’ll need a URL for the service, which uses the azure-mobile.net domain. There’s no real need to have your own domain because your users will see only a native app. The wizard will check to see if the name you want to use is free, then you can choose to work with a free database (only 20MB, which is more than enough for most small apps) or a full SQL Azure instance. You’re also able to pick the region where your service will be hosted and whether you’ll be writing code in JavaScript or in your choice of .Net languages.

The wizard will automatically create a notification service hub for your app, though if you’ve already set one up for another app, you can specify its name instead. The next step is to set up the database, either connecting to an existing SQL Azure instance or creating a new host. Choose a login name and a password. There’s the option to tweak advanced database settings, but it’s not necessary for most applications.

Once the database is set up, you’re ready to start building your app. Initially Azure will create a free trial subscription, so you can start building and testing an Azure MBaaS app without having to worry about costs (testing complex apps can take advantage of the Azure credits that come bundled with MSDN subscriptions) before switching to a paid tier. You can also set up connections to push services, including Apple push notifications and Google cloud messaging, though you’ll need the appropriate certificates and API keys to configure access.

Building the endpoint apps is simplified by a set of tutorials built into the Azure portal. They walk you through creating tables in the database, before downloading a sample app in your choice of languages. Things get more interesting when you’re connecting existing apps to the service. There you’ll need to start with the appropriate SDK, adding headers and libraries to your code. As with most cloud services, you’ll need to put an application key in your code to verify users with the service, along with the service URL for its REST endpoints. You can then quickly add code to read and write date from the service you’ve built, with the SDK handling the REST connections.

Drilling into the service you’ve created, you’ll find a dashboard that shows the status of your application, including the number of API calls that have been made and how much data has been transferred. There are also options for integrating with source control tools and for using Microsoft’s monitoring tools so that you can keep an eye on user experience. If you’ve graduated to a paid tier, you can also configure autoscaling, so you can manage the number of servers your service uses and how it responds to changes in demand.

Microsoft goes a long way to isolate you from the underlying infrastructure. While you can use the Azure SQL tools to work with your database, you can also use the Data tab of your service dashboard to add tables to your cloud storage. Once a table has been created, you’re able to drill down into it, see its content, and test scripts -- without leaving your browser.

Other options let you build and manage your own custom methods, defining an API name and its HTTP endpoints. You’re able to edit the API code in the portal and set permissions for user access to its options. The default script is a simple "hello world," but it’s easy enough to start extending -- and to perhaps consider using other supported Azure technologies like Node.js for more complex services.

Azure’s Mobile Service is a quick and easy way of adding MBaaS to your applications, with the option of expanding basic service to take advantage of the entire Azure platform. That’s an intriguing prospect, particularly with the arrival of tools for working with Internet of things data, along with enhanced search and NoSQL storage for unstructured data. Who says mobile apps are second-class citizens?

Copyright © 2015 IDG Communications, Inc.