Post on 09-May-2015
description
Developing iPhone and iPad apps that Leverage Windows Azure
Simon GuestDirector, Mobility SolutionsNeudesic, LLCsimon.guest@neudesic.com
I go to a lot of conferences…
Intro Section
Some of them are a little boring…
Some of them are more interesting than others…
IntroductionMIX is always interesting!
Intro Section
“There’s an app for that!”
Share stuff Access agenda Keep up to date
“There’s an app for that!”
Uploading stuff Accessing agenda Keeping up to date1Use Cloud for Storage
3Receive Notifications
2Access Applications
Scenarios
1Use Cloud for Storage
2 3Access Applications Receive Notifications
Scenarios
1Use Cloud for Storage
2 3Access Applications Receive Notifications
1
Scenario 1
Scenario 1
Blob Storage
Table Storage
Scenario 1• Most suitable for binary data
(images, video, audio)• Container-based approach• 8k metadata for each blob
Blob Storage
Table Storage
Scenario 1
• Most suitable for structured data
• Dynamic schema• Partitioning to enable scale
Blob Storage
Table Storage
Scenario 1
Blob Storage
Scenario 1
Blob Storage
Scenario 1
Blob Storage
Scenario 1
Blob Storage
REST Endpoint:http://[account].blob.core.windows.net
• List, Create, and Delete Containers
• List, Put, Get, Delete Blobs
photos
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
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?
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>
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
Using Blob Storage from iOS
demo
Scenario 1REST Endpoint:http://[account].table.core.windows.net
• List, Create, and Delete Tables• List, Put, Get, Delete Table
Entities
photodataTable Storage
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>
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>
Using Table Storage from iOS
demo
J!ResQ – Japanese Earthquake Rescue
case study
13,333 death toll. 15,000 missing. (4/13/11)
J!ResQ Case Study
J!ResQ Case Study
Municipality
Pinpointed photo using Bing Maps
http://www.j-resq.com
SituationalAnalysis
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
Scenarios
1Use Cloud for Storage
2 3Access Applications Receive Notifications
2
Scenario 2
“Where is my next session?”
Scenario 2
Pages
Web Role
Ability to host ASP.NET (MVC) application in 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
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
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
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”)
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
Using ASP.NET View Engine
demo
Scenario 2
“Great! …but it still looks like my original webpage”
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
Scenario 2
iUIhttp://iui-js.org
jQTouchhttp://jqtouch.com
jQueryMobilehttp://jquerymobile.com
Mobile Web Frameworks
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
Using jQueryMobile
demo
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?
Scenario 2
PhoneGaphttp://phonegap.com
Appceleratorhttp://appcelerator.com
Unifyhttp://unify.github.com/
unify
Device-Integrated Web Frameworks
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
Integrating the App with PhoneGap
demo
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
Scenarios
1Use Cloud for Storage
2 3Access Applications Receive Notifications
3
Scenario 3
“Looks like we have a session change”
Scenario 3
iPad/iPhone OS 4.3.1
Native Application
Apple Push Notification Servicegateway.sandbox.push.apple.com
User Acceptance
App Registration
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
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
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
Sending Push Notifications to iOS from Windows Azure
demo
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)
ConclusionHistorically not much interaction between iOS and 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
© 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 Solutionssimon.guest@neudesic.com