Developing iPhone and iPad apps that leverage Windows Azure

64

description

My presentation from MIX11 showing how to build applications on iPhone and iPad devices that leverage the cloud (Windows Azure)

Transcript of Developing iPhone and iPad apps that leverage Windows Azure

Page 1: Developing iPhone and iPad apps that leverage Windows Azure
Page 2: Developing iPhone and iPad apps that leverage Windows Azure

Developing iPhone and iPad apps that Leverage Windows Azure

Simon GuestDirector, Mobility SolutionsNeudesic, [email protected]

Page 3: Developing iPhone and iPad apps that leverage Windows Azure

I go to a lot of conferences…

Page 4: Developing iPhone and iPad apps that leverage Windows Azure

Intro Section

Some of them are a little boring…

Some of them are more interesting than others…

Page 5: Developing iPhone and iPad apps that leverage Windows Azure

IntroductionMIX is always interesting!

Page 6: Developing iPhone and iPad apps that leverage Windows Azure

Intro Section

“There’s an app for that!”

Share stuff Access agenda Keep up to date

“There’s an app for that!”

Page 7: Developing iPhone and iPad apps that leverage Windows Azure

Uploading stuff Accessing agenda Keeping up to date1Use Cloud for Storage

3Receive Notifications

2Access Applications

Page 8: Developing iPhone and iPad apps that leverage Windows Azure

Scenarios

1Use Cloud for Storage

2 3Access Applications Receive Notifications

Page 9: Developing iPhone and iPad apps that leverage Windows Azure

Scenarios

1Use Cloud for Storage

2 3Access Applications Receive Notifications

1

Page 10: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 1

Page 11: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 1

Blob Storage

Table Storage

Page 12: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 1• Most suitable for binary data

(images, video, audio)• Container-based approach• 8k metadata for each blob

Blob Storage

Table Storage

Page 13: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 1

• Most suitable for structured data

• Dynamic schema• Partitioning to enable scale

Blob Storage

Table Storage

Page 14: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 1

Blob Storage

Page 15: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 1

Blob Storage

Page 16: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 1

Blob Storage

Page 17: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 1

Blob Storage

REST Endpoint:http://[account].blob.core.windows.net

• List, Create, and Delete Containers

• List, Put, Get, Delete Blobs

photos

Page 18: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 1

Blob Storage

REST Endpoint:http://[account].blob.core.windows.net

GET http://iostest.blob.core.windows.net/?comp=list&include=metadata

x-ms-date: Thu, 14 Apr 2011 20:30:00 GMTx-ms-version: 2009-09-19x-ms-blob-type: BlockBlobAuthorization: SharedKey iostest:[ComputedHash]

REST request for listing all containers

Page 19: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 1

Blob Storage

REST Endpoint:http://[account].blob.core.windows.net

To calculate the computed hash:

AccountKey: /9seXadQ9HwOpXUO1jKxFN8q…

Request: GET\n\n\n\n\n\n\n\n\n\n\n\nx-ms-blob-type:BlockBlob\nx-ms-date:Thu, 14 Apr 2011 20:30:00 GMT\nx-ms-version:2009-09-19\n/iostest/\ncomp:list\ninclude:metadata

Hash = HMACSHA256(UTF8Encode(Request), Base64Decode(AccountKey))

Account Key: /9seXadQ9HwOpXUO1jKxFN8q…

…but how do I get that computed hash?

Page 20: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 1

Blob Storage

REST Endpoint:http://[account].blob.core.windows.net

Making the call

GET http://iostest.blob.core.windows.net/?comp=list&include=metadata

x-ms-date: Thu, 14 Apr 2011 20:30:00 GMTx-ms-version: 2009-09-19x-ms-blob-type: BlockBlobAuthorization: SharedKey iostest:[ComputedHash]

<?xml version="1.0" encoding="utf-8"?><EnumerationResults AccountName="http://myaccount.blob.core.windows.net/"> <Prefix>c</Prefix> <MaxResults>3</MaxResults> <Containers> <Container> <Name>container1</Name> <Url>http://iostest.blob.core.windows.net/photos</Url> <Properties> <Last-Modified>Sun, 14 Apr 2011 20:09:03 GMT</Last-Modified> </Properties> </Container> </Containers>

Page 21: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 1

Blob Storage

REST Endpoint:http://[account].blob.core.windows.net

PUT http://iostest.blob.core.windows.net/photos/party.jpg

x-ms-date: Thu, 14 Apr 2011 20:30:00 GMTx-ms-version: 2009-09-19x-ms-blob-type: BlockBlobAuthorization: SharedKey iostest:[ComputedHash]

{...binary representation of photo...}

REST request (PUT) for adding a new photo

Page 22: Developing iPhone and iPad apps that leverage Windows Azure

Using Blob Storage from iOS

demo

Page 23: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 1REST Endpoint:http://[account].table.core.windows.net

• List, Create, and Delete Tables• List, Put, Get, Delete Table

Entities

photodataTable Storage

Page 24: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 1REST Endpoint:http://[account].table.core.windows.net

• List, Create, and Delete Tables• List, Put, Get, Delete Table

Entities

REST request for listing all tables

photodataTable Storage

GET http://iostest.blob.core.windows.net/Tables

x-ms-date: Thu, 14 Apr 2011 20:30:00 GMTx-ms-version: 2009-09-19DataServiceVersion: 1.0;NetFxMaxDataServiceVersion: 2.0;NetFxAuthorization: SharedKey iostest:[ComputedHash]

<feed xml:base="http://iostest.tables.core.windows.net/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom"> <title type="text">Tables</title> <id>http://iostest.tables.core.windows.net/Tables</id> <updated>2011-04-04T17:18:54.7062347Z</updated> <link rel="self" title="Tables" href="Tables" /> <entry> <id>http://myaccount.tables.core.windows.net/Tables(’photodata')</id> <title type="text"></title> <updated>2009-01-04T17:18:54.7062347Z</updated> <author> <name /> </author> <link rel="edit" title="Tables" href="Tables(’photodata')" /> <m:properties> <d:TableName>photodata</d:TableName> </m:properties> </content> </entry></feed>

Page 25: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 1REST Endpoint:http://[account].table.core.windows.net

• List, Create, and Delete Tables• List, Put, Get, Delete Table

Entities

REST request for inserting an entity

photodataTable Storage

PUT http://iostest.blob.core.windows.net/Tables

x-ms-date: Thu, 14 Apr 2011 20:30:00 GMTx-ms-version: 2009-09-19DataServiceVersion: 1.0;NetFxMaxDataServiceVersion: 2.0;NetFxAuthorization: SharedKey iostest:[ComputedHash]

<entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom"> <title /> <updated>2011-04-10T23:46:19.3857256Z<updated/> <author> <name /> </author> <id /> <content type="application/xml"> <m:properties> <d:Description>My coworker is drunk</d:Description> <d:DrinkCount m:type="Edm.Int32”>10</d:DrinkCount></m:properties> </content></entry>

Page 26: Developing iPhone and iPad apps that leverage Windows Azure

Using Table Storage from iOS

demo

Page 27: Developing iPhone and iPad apps that leverage Windows Azure

J!ResQ – Japanese Earthquake Rescue

case study

Page 28: Developing iPhone and iPad apps that leverage Windows Azure

13,333 death toll. 15,000 missing. (4/13/11)

Page 29: Developing iPhone and iPad apps that leverage Windows Azure
Page 30: Developing iPhone and iPad apps that leverage Windows Azure
Page 31: Developing iPhone and iPad apps that leverage Windows Azure
Page 32: Developing iPhone and iPad apps that leverage Windows Azure

J!ResQ Case Study

Page 33: Developing iPhone and iPad apps that leverage Windows Azure

J!ResQ Case Study

Municipality

Pinpointed photo using Bing Maps

http://www.j-resq.com

SituationalAnalysis

Page 34: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 1 - Takeaways

Recommendations:

• Use blob storage for images, videos, audio

• Use table storage for structured, non relational data

• Wrap REST calls in library

Watch out for:

• Blob storage doesn’t offer hierarchical structure

• REST signatures can be a little complex and differ between the two storage types

Page 35: Developing iPhone and iPad apps that leverage Windows Azure

Scenarios

1Use Cloud for Storage

2 3Access Applications Receive Notifications

2

Page 36: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 2

“Where is my next session?”

Page 37: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 2

Pages

Web Role

Ability to host ASP.NET (MVC) application in Windows Azure

Page 38: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 2

User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0;

SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR

3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3; MS-RTC LM 8)

Windows 7 / IE8.0

Web Role

Pages

HTTP Request

HTTP Response

Page 39: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 2

UserAgent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_1 like Mac OS X; en-us)

AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5

Web Role

Pages

iPhone OS 4.3.1

HTTP Request

HTTP Response

Page 40: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 2

HTTP Request

HTTP Response

Web Role

Pages

iPad OS 4.3.1

Mozilla/5.0 (iPad; U; CPU OS 4_3_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like

Gecko) Version/4.3.1 Mobile/7B334b Safari/531.21.10

Page 41: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 2

Web Role

User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET

CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3; MS-RTC

LM 8)

Windows 7 / IE8.0

iPhone OS 4.3.1

UserAgent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148

Safari/6533.18.5

Pages

if (useragent contains ”MSIE”)

Pages

if (useragent contains

”iPhone”)

Page 42: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 2

Web Role

User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET

CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3; MS-RTC

LM 8)

Windows 7 / IE8.0

iPhone OS 4.3.1

UserAgent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148

Safari/6533.18.5

Controller

ViewCSS

ViewCSS

if (useragent contains ”MSIE”)

if (useragent contains

”iPhone”)

if (Response.Headers[“User-Agent”].Contains(“iPhone”)){

return View(“iPhone”);}

if (Response.Headers[“User-Agent”].Contains(“iPad”)){

return View(“iPad”);}

if (Response.Headers[“User-Agent].Contains...ASP.NET MVCViewEngine

Page 43: Developing iPhone and iPad apps that leverage Windows Azure

Using ASP.NET View Engine

demo

Page 44: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 2

“Great! …but it still looks like my original webpage”

Page 45: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 2

Web Role

User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET

CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3; MS-RTC

LM 8)

Windows 7 / IE8.0

iPhone OS 4.3.1

UserAgent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148

Safari/6533.18.5

Controller

ViewCSS

ViewCSS

if (useragent contains ”MSIE”)

if (useragent contains

”iPhone”)ASP.NET MVCViewEngine

Page 46: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 2

iUIhttp://iui-js.org

jQTouchhttp://jqtouch.com

jQueryMobilehttp://jquerymobile.com

Mobile Web Frameworks

Page 47: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 2

Web Role

User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET

CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3; MS-RTC

LM 8)

Windows 7 / IE8.0

iPhone OS 4.3.1

UserAgent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148

Safari/6533.18.5

Controller

ViewCSS

ViewCSS

if (useragent contains ”MSIE”)

if (useragent contains

”iPhone”)ASP.NET MVCViewEngine

Page 48: Developing iPhone and iPad apps that leverage Windows Azure

Using jQueryMobile

demo

Page 49: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 2

“Looking good! But this is still a mobile web app. How about…”

Accessing the Camera?

Getting location via GPS?

Uploading to the AppStore?

Local storage?

Page 50: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 2

PhoneGaphttp://phonegap.com

Appceleratorhttp://appcelerator.com

Unifyhttp://unify.github.com/

unify

Device-Integrated Web Frameworks

Page 51: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 2

Web RoleiPhone OS

4.3.1

Controller

ViewCSS

ViewCSS

if (useragent contains ”MSIE”)

if (useragent contains

”iPhone”)ASP.NET MVCViewEngine

WebViewController

Native Libraries (ObjC)

JavaScript bridge

Web Storage

Native shell upload to AppStore

Local HTML

Page 52: Developing iPhone and iPad apps that leverage Windows Azure

Integrating the App with PhoneGap

demo

Page 53: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 2 - Takeaways

Recommendations:

• Mobile Web sites let you target multiple devices

• ASP.NET MVC with ViewEngine support. V3 for improved HTML5 attributes

• Hybrid approach with PhoneGap

Watch out for:

• Many different UI frameworks – choose carefully, think about longevity

Page 54: Developing iPhone and iPad apps that leverage Windows Azure

Scenarios

1Use Cloud for Storage

2 3Access Applications Receive Notifications

3

Page 55: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 3

“Looks like we have a session change”

Page 56: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 3

iPad/iPhone OS 4.3.1

Native Application

Apple Push Notification Servicegateway.sandbox.push.apple.com

User Acceptance

App Registration

Page 57: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 3

iPad/iPhone OS 4.3.1

Native Application

Apple Push Notification Servicegateway.sandbox.push.apple.com

App Registration

User Acceptance

Worker Role

Send Message Payload

• Azure Role optimized for background tasks

0 0 32 deviceToken 0 34 message

Token Length Payload Length JSON formatted

Page 58: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 3

iPad/iPhone OS 4.3.1

Native Application

Apple Push Notification Servicegateway.sandbox.push.apple.com

App Registration

User Acceptance

Worker Role

Send Message Payload

Windows Azure Queue

Page 59: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 3

iPad/iPhone OS 4.3.1

Native Application

Apple Push Notification Servicegateway.sandbox.push.apple.com

App Registration

User Acceptance

Worker Role

Send Message Payload

Windows Azure QueueWeb Role

Session Updated through Web

Update Queue

Receive Message, Launch App

Request Changed Session

Details

Page 60: Developing iPhone and iPad apps that leverage Windows Azure

Sending Push Notifications to iOS from Windows Azure

demo

Page 61: Developing iPhone and iPad apps that leverage Windows Azure

Scenario 3 - Takeaways

Recommendations:

• APN useful for updating users of events

• Worker Role, Azure Queue, and Web Role can be used in conjunction with APN

• Can also be used with PhoneGap shell

Watch out for:

• Use Worker Role to maintain persistent connection to APN (to prevent DOS)

Page 62: Developing iPhone and iPad apps that leverage Windows Azure

ConclusionHistorically not much interaction between iOS and Windows

Azure

Page 63: Developing iPhone and iPad apps that leverage Windows Azure

ConclusionHistorically not much interaction between iOS and Windows

Azure

1Use Cloud for Storage

3Receive Notifications

2Access Applications

Possibilities for building iPhone/iPad apps that leverage Windows Azure

Page 64: Developing iPhone and iPad apps that leverage Windows Azure

© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION

IN THIS PRESENTATION.

Simon GuestDirector, Mobility [email protected]