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

WinAzure_rgb

Windows Azure  makes it incredibly easy to connect your client and mobile applications to a scalable cloud backend.

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)

 

iOS Support

This initial support for connecting iOS based devices (including iPhones and iPads) to Windows Azure Mobile Services.  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:

Mobile_Web

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

The 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. Therefore offering far more choice to you app user.)

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. 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

You now have 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

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 https://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 https://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);

});

 

The above features are all now live in production and are available to use immediately.

Access to Azure for FREE for students and educators

If you don’t already have a Windows Azure account, you can sign-up for a FREE academic educators pass at https://www.windowsazure.com/education and start using Mobile Services today.

Curriculum Resources for Windows Azure

See https://www.microsoft.com/faculty for teaching materials for Windows Azure

Development Resources

Development Resources Visit the Windows Azure Mobile Developer Center to learn more about how to build apps with Mobile Services.

For details as new features become available soon https://www.windowsazure.com/en-us/community/blog/