Windows Azure Mobile Services: New support for iOS apps, Facebook/Twitter/Google identity, Emails, SMS, Blobs, Service Bus and more

A few weeks ago I blogged about Windows Azure Mobile Services - a new capability in Windows Azure that makes it incredibly easy to connect your client and mobile applications to a scalable cloud backend.

Earlier today we delivered a number of great improvements to Windows Azure Mobile Services.  New features include:

  • iOS support – enabling you to connect iPhone and iPad apps to Mobile Services
  • Facebook, Twitter, and Google authentication support with Mobile Services
  • Blob, Table, Queue, and Service Bus support from within your Mobile Service
  • Sending emails from your Mobile Service (in partnership with SendGrid)
  • Sending SMS messages from your Mobile Service (in partnership with Twilio)
  • Ability to deploy mobile services in the West US region

All of these improvements are now live in production and available to start using immediately. Below are more details on them:

iOS Support

This week we delivered initial support for connecting iOS based devices (including iPhones and iPads) to Windows Azure Mobile Services.  Like the rest of our Windows Azure SDK, we are delivering the native iOS libraries to enable this under an open source (Apache 2.0) license on GitHub.  We’re excited to get your feedback on this new library through our forum and GitHub issues list, and we welcome contributions to the SDK.

To create a new iOS app or connect an existing iOS app to your Mobile Service, simply select the “iOS” tab within the Quick Start view of a Mobile Service within the Windows Azure Portal – and then follow either the “Create a new iOS app” or “Connect to an existing iOS app” link below it:

image

Clicking either of these links will expand and display step-by-step instructions for how to build an iOS application that connects with your Mobile Service:

image

Read this getting started tutorial to walkthrough how you can build (in less than 5 minutes) a simple iOS “Todo List” app that stores data in Windows Azure.  Then follow the below tutorials to explore how to use the iOS client libraries to store data and authenticate users.

Facebook, Twitter, and Google Authentication Support

Our initial preview of Mobile Services supported the ability to authenticate users of mobile apps using Microsoft Accounts (formerly called Windows Live ID accounts).  This week we are adding the ability to also authenticate users using Facebook, Twitter, and Google credentials.  These are now supported with both Windows 8 apps as well as iOS apps (and a single app can support multiple forms of identity simultaneously – so you can offer your users a choice of how to login).

The below tutorials walkthrough how to register your Mobile Service with an identity provider:

The tutorials above walkthrough how to obtain a client ID and a secret key from the identity provider. You can then click on the “Identity” tab of your Mobile Service (within the Windows Azure Portal) and save these values to enable server-side authentication with your Mobile Service:

image

You can then write code within your client or mobile app to authenticate your users to the Mobile Service.  For example, below is the code you would write to have them login to the Mobile Service using their Facebook credentials:

Windows Store App (using C#):

var user = await App.MobileService

                    .LoginAsync(MobileServiceAuthenticationProvider.Facebook);

iOS app (using Objective C):

UINavigationController *controller =

[self.todoService.client

    loginViewControllerWithProvider:@"facebook"

    completion:^(MSUser *user, NSError *error) {

       //...

}];

Learn more about authenticating Mobile Services using Microsoft Account, Facebook, Twitter, and Google from these tutorials:

Using Windows Azure Blob, Tables and ServiceBus with your Mobile Services

Mobile Services provide a simple but powerful way to add server logic using server scripts. These scripts are associated with the individual CRUD operations on your mobile service’s tables. Server scripts are great for data validation, custom authorization logic (e.g. does this user participate in this game session), augmenting CRUD operations, sending push notifications, and other similar scenarios.  

Server scripts are written in JavaScript and are executed in a secure server-side scripting environment built using Node.js.  You can edit these scripts and save them on the server directly within the Windows Azure Portal:

image

In this week’s release we have added the ability to work with other Windows Azure services from your Mobile Service server scripts.  This is supported using the existing “azure” module within the Windows Azure SDK for Node.js.  For example, the below code could be used in a Mobile Service script to obtain a reference to a Windows Azure Table (after which you could query it or insert data into it):

    var azure = require('azure');

    var tableService = azure.createTableService("<< account name >>",

                                                "<< access key >>");

Follow the tutorials on the Windows Azure Node.js dev center to learn more about working with Blob, Tables, Queues and Service Bus using the azure module.

Sending emails from your Mobile Service

In this week’s release we have also added the ability to easily send emails from your Mobile Service, building on our partnership with SendGrid. Whether you want to add a welcome email upon successful user registration, or make your app alert you of certain usage activities, you can do this now by sending email from Mobile Services server scripts.

To get started, sign up for SendGrid account at http://sendgrid.com . Windows Azure customers receive a special offer of 25,000 free emails per month from SendGrid. To sign-up for this offer, or get more information, please visit http://www.sendgrid.com/azure.html .

One you signed up, you can add the following script to your Mobile Service server scripts to send email via SendGrid service:

    var sendgrid = new SendGrid('<< account name >>', '<< password >>');

 

    sendgrid.send({

        to: '<< enter email address here >>',

        from: '<< enter from address here >>',

        subject: 'New to-do item',

        text: 'A new to-do was added: ' + item.text

    }, function (success, message) {

        if (!success) {

            console.error(message);

        }

    });

Follow the Send email from Mobile Services with SendGrid tutorial to learn more.

Sending SMS messages from your Mobile Service

SMS is a key communication medium for mobile apps - it comes in handy if you want your app to send users a confirmation code during registration, allow your users to invite their friends to install your app or reach out to mobile users without a smartphone.

Using Mobile Service server scripts and Twilio’s REST API, you can now easily send SMS messages to your app.  To get started, sign up for Twilio account. Windows Azure customers receive 1000 free text messages when using Twilio and Windows Azure together.

Once signed up, you can add the following to your Mobile Service server scripts to send SMS messages:

    var httpRequest = require('request');

    var account_sid = "<< account SID >>";

    var auth_token = "<< auth token >>";

 

    // Create the request body

    var body = "From=" + from + "&To=" + to + "&Body=" + message;

 

    // Make the HTTP request to Twilio

    httpRequest.post({

        url: "https://" + account_sid + ":" + auth_token +

             "@api.twilio.com/2010-04-01/Accounts/" + account_sid + "/SMS/Messages.json",

        headers: { 'content-type': 'application/x-www-form-urlencoded' },

        body: body

    }, function (err, resp, body) {

        console.log(body);

    });

I’m excited to be speaking at the TwilioCon conference this week, and will be showcasing some of the cool scenarios you can now enable with Twilio and Windows Azure Mobile Services.

Mobile Services availability in West US region

Our initial preview of Windows Azure Mobile Services was only supported in the US East region of Windows Azure.  As with every Windows Azure service, overtime we will extend Mobile Services to all Windows Azure regions. With this week’s preview update we’ve added support so that you can now create your Mobile Service in the West US region as well:

image

Summary

The above features are all now live in production and are available to use immediately.  If you don’t already have a Windows Azure account, you can sign-up for a free trial and start using Mobile Services today. Visit the Windows Azure Mobile Developer Center to learn more about how to build apps with Mobile Services.

We’ll have even more new features and enhancements coming later this week – including .NET 4.5 support for Windows Azure Web Sites.  Keep an eye out on my blog for details as new features become available.

Hope this helps,

Scott

P.S. In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: twitter.com/scottgu

9 Comments

  • Hi Scott, do you have any clue when the mobile services will be available in europe?

  • Holy crap. iOS before Windows Phone? Come on guys. The WP7/8 OS is legit. Give it first rate support with your own products.

  • Is there any way to keep the scripts code in source control outside of manual copying and pasting?
    Can I deploy scripts from a visual studio project?
    Is there any way to get/save a script outside of the Windows Azure Portal, such as from the Management API?

  • "including .NET 4.5 support for Windows Azure Web Sites"
    What about Web Roles? The support request for 4.5 on the feature voting page is sky rocketing, leading ahead with 600 votes after the second highest request. A lot of people are eagerly waiting for 4.5 support, and in my opinion it really is a joke that it is not supported already. If now support will only be released for Azure WebSites, then this will be a clear punch in the face of all "early adopters" that use Web Roles. And it would at least make us (and probably many others too) reconsider Azure as the choice of cloud service for future projects.

  • Is Azure Access Control or custom WIF authentication going to be supported?

  • Hi Scott, when will azure mobile services be available for VS 2010 / .net 3.5 so we can build applications for windows 7, xp etc.

  • Hi Scott, thanks for that comprehensive update.
    One Question: What about WebRoles? Still missing?
    Regards

  • Hi Scott, quick questions re: the preview tag.

    Are mobile services safe to use in production apps? I am about to deploy a Windows 8 app to the store, and was considering using a small DB to manage the availability of updates to content. Mobile services would be perfect for this, but I don't want to deploy it without knowing that my Mobile Services apps may suddenly disappear (or be down for x amount of time while the preview status is lifted).

    It's not a biggie to roll my own, but I figured it would be a great, simple use of the Mobile Services API if they were stable enough for production.

  • @Jono

    I'm a member of the Mobile Services team and I can assure you that Mobile Services is production ready. There are already several apps in the Windows 8 app store that run on our service. Feel free to get in touch with me at pbatum@microsoft.com if you have more questions.

    Paul

Comments have been disabled for this content.