You are on page 1of 33

Building Mobile Phone

Applications in the Cloud


Name
Title
Organization
Agenda

This session is focused on


building device applications
with Windows Azure
We’ll talk about storage,
identity, communications,
platform services, and tools
Several demos
BabelCam

demo
Windows Phone application
leveraging Windows Azure
User Authentication
Store
Process
Send Notification
Image
Image in Windows Azure Blob Storage

Any pictures?
Process Image
SAS

WAZ Storage
Windows Azure

Shared Token
Authenticate
Access Access Send ImageText
Translated
Signature Translated
Text

Translated
Text

Microsoft Push Hawaii OCR &


Notification Service Bing Translator
Features in Action

Storage Identity Communications Platform Services


Three Reasons for Device + Cloud

1 Allows new
application scenarios

2 the playing field


The cloud levels

3 reach across device platforms


The cloud provides a way to

and a larger pool of resources


from which to pull
Why Windows Azure?
PaaS: you built it, Windows Azure runs it
Automatic O/S patching
Elasticity and scale
Utility billing
Higher-level services
ACS, Caching, CDN, Traffic Manager
Storage
Storage: What are our options?
Benefits:
Windows Azure
Non-relational structured storage
Tables Massive scale-out
Benefits:
Windows Azure
Big files
Blobs
Benefits:
Windows Azure
Persistent Async Messaging
Queues Enqueue, Dequeue
Benefits:
Windows Azure SQL
Relational database
Database Highly available
Managed for you as a service
Storage: Secrets
Windows Azure
Storage name
Storage key

Windows Azure
SQL Database
Username
Once you share your secret,
Password it’s no longer secret
Storage: How do we keep secrets secret?
Proxy the requests
Client sends data (2)
to web role
Web role sends
data to storage Web Role

(1)
Storage: Using Shared Access Signatures
Client makes request
of Web Role for SAS
Web Role sends
client SAS (3)
(2) (4)
Client makes request Web Role

(1)
Client gets response
Storage: Windows Azure SQL Database
Client sends
request to proxy
Proxy makes SQL call (2)
against SQL Database (3)
SQL Database
returns a response Web Role (4)

Proxy returns (1)


response to device
Storage: Offloading work through queues
Client writes a
message to a queue
(3)
Worker role is Worker Role
polling the queue (2)

Worker role finds


the message
(1)
Windows Azure
Toolkits for Devices

demo
Identity
Identity: What are the options?
Create your own
Username + password, token, etc.
ASP.NET Membership Providers

Use a single existing identity system


Live Id, Facebook, etc.
Develop directly against IdP protocol

Outsource identity management


Access Control Service
Using ACS from Windows
Phone using NuGet

demo
Communications
Communications

Two forms of communication with devices

Device-initiated Cloud-initiated
Communications: Device-initiated
OData 8.5kb REST-XML 1.2kb Device-initiated options
<?xml version="1.0" encod ing="utf-8" standalone="yes" ?>
- <feed xml:base="http://lo calhost:33779/WcfDataService1.svc/" xmlns:d="http://schemas.microso ft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado /2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<ArrayOfDriver xmlns= HTTP-based, request/response
Framework choices (WCF, OData, WebRequest, etc.)
<title type="text">Drivers</title>
<id>http://lo calhost:33779/WcfDataService1.svc/Drivers</id>

http://schemas.datacontract.org/2004/07/ContosoWcfService.Models
<updated>2010-05-24T22:12:38Z</updated>
<link rel="self" title="Drivers" href="Drivers" />
- <entry>
<id>http://lo calhost:33779/WcfDataService1.svc/Drivers(1)</id>
<title type="text" />

xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<updated>2010-05-24T22:12:38Z</updated>
- <author>
<name />
</author>
<link rel="edit" title="Driver" href="Drivers(1)" />

<Driver>
<link rel="http://schemas.microsoft.com/ado/2007/08/d ataservices/related/DistributionCenter" type="application/atom+xml;type=entry" title="DistributionCenter" href="Drivers(1)/DistributionC enter" />
<link rel="http://schemas.microsoft.com/ado/2007/08/d ataservices/related/Todays" type="application/ato m+xml;type=feed" title="Tod ays" href="Drivers(1)/Tod ays" />
<category term="C ontosoBottlingModel.Driver" scheme="http://schemas.micro so ft.com/ado/2007/08/dataservices/scheme" />
- <content type="ap plication/xml">

Wire format choices (SOAP, JSON, POX, etc.)


<DistributionCenterId>1</DistributionCenterId>
- <m:p rop erties>
<d:DriverId m:type="Ed m.Int32">1</d:DriverId>
<d:Distributio nC enterId m:type="Edm.Int32">1</d:Distributio nC enterId>
<d:FirstName>Rob</d:FirstName>
<d:LastName>Tiffany</d:LastName>

<DriverId>1</DriverId>
</m:properties>
</content>
</entry>
- <entry>

<FirstName>Rob</FirstName>
<id>http://lo calhost:33779/WcfDataService1.svc/Drivers(2)</id>
<title type="text" />
<updated>2010-05-24T22:12:38Z</updated>
- <author>
<name />

<LastName>Tiffany</LastName>
</author>
<link rel="edit" title="Driver" href="Drivers(2)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/d ataservices/related/DistributionCenter" type="application/atom+xml;type=entry" title="DistributionCenter" href="Drivers(2)/DistributionC enter" />
<link rel="http://schemas.microsoft.com/ado/2007/08/d ataservices/related/Todays" type="application/ato m+xml;type=feed" title="Tod ays" href="Drivers(2)/Tod ays" />

</Driver>
<category term="C ontosoBottlingModel.Driver" scheme="http://schemas.micro so ft.com/ado/2007/08/dataservices/scheme" />
- <content type="ap plication/xml">
- <m:p rop erties>
<d:DriverId m:type="Ed m.Int32">2</d:DriverId>
<d:Distributio nC enterId m:type="Edm.Int32">1</d:Distributio nC enterId>

<Driver>
<d:FirstName>Loke Uei</d :FirstName>
<d:LastName>Tan</d:LastName>
</m:properties>
</content>

<DistributionCenterId>1</DistributionCenterId>
</entry>
- <entry>
<id>http://lo calhost:33779/WcfDataService1.svc/Drivers(3)</id>
<title type="text" />
<updated>2010-05-24T22:12:38Z</updated>

<DriverId>2</DriverId>
- <author>
<name />
</author>
<link rel="edit" title="Driver" href="Drivers(3)" />

<FirstName>Loke Uei</FirstName>
<link rel="http://schemas.microsoft.com/ado/2007/08/d ataservices/related/DistributionCenter" type="application/atom+xml;type=entry" title="DistributionCenter" href="Drivers(3)/DistributionC enter" />
<link rel="http://schemas.microsoft.com/ado/2007/08/d ataservices/related/Todays" type="application/ato m+xml;type=feed" title="Tod ays" href="Drivers(3)/Tod ays" />
<category term="C ontosoBottlingModel.Driver" scheme="http://schemas.micro so ft.com/ado/2007/08/dataservices/scheme" />
- <content type="ap plication/xml">
- <m:p rop erties>

<LastName>Tan</LastName>
<d:DriverId m:type="Ed m.Int32">3</d:DriverId>
<d:Distributio nC enterId m:type="Edm.Int32">1</d:Distributio nC enterId>
<d:FirstName>Dan</d:FirstName>
<d:LastName>Bouie</d :LastName>

</Driver>
</m:properties>
</content>
</entry>
- <entry>
<id>http://lo calhost:33779/WcfDataService1.svc/Drivers(4)</id>

<Driver>
<title type="text" />
<updated>2010-05-24T22:12:38Z</updated>
- <author>
<name />

<DistributionCenterId>1</DistributionCenterId>
</author>
<link rel="edit" title="Driver" href="Drivers(4)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/d ataservices/related/DistributionCenter" type="application/atom+xml;type=entry" title="DistributionCenter" href="Drivers(4)/DistributionC enter" />
<link rel="http://schemas.microsoft.com/ado/2007/08/d ataservices/related/Todays" type="application/ato m+xml;type=feed" title="Tod ays" href="Drivers(4)/Tod ays" />
<category term="C ontosoBottlingModel.Driver" scheme="http://schemas.micro so ft.com/ado/2007/08/dataservices/scheme" />

<DriverId>3</DriverId>

JSON 639 bytes


- <content type="ap plication/xml">
- <m:p rop erties>
<d:DriverId m:type="Ed m.Int32">4</d:DriverId>
<d:Distributio nC enterId m:type="Edm.Int32">1</d:Distributio nC enterId>

<FirstName>Dan</FirstName>
<d:FirstName>John</d:FirstName>
<d:LastName>Dietz</d:LastName>
</m:properties>
</content>
</entry>

<LastName>Bouie</LastName>
- <entry>
<id>http://lo calhost:33779/WcfDataService1.svc/Drivers(5)</id>
<title type="text" />
<updated>2010-05-24T22:12:38Z</updated>

</Driver>
- <author>
<name />
</author>
<link rel="edit" title="Driver" href="Drivers(5)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/d ataservices/related/DistributionCenter" type="application/atom+xml;type=entry" title="DistributionCenter" href="Drivers(5)/DistributionC enter" />

<Driver>
<link rel="http://schemas.microsoft.com/ado/2007/08/d ataservices/related/Todays" type="application/ato m+xml;type=feed" title="Tod ays" href="Drivers(5)/Tod ays" />
<category term="C ontosoBottlingModel.Driver" scheme="http://schemas.micro so ft.com/ado/2007/08/dataservices/scheme" />
- <content type="ap plication/xml">
- <m:p rop erties>

<DistributionCenterId>1</DistributionCenterId>
<d:DriverId m:type="Ed m.Int32">5</d:DriverId>
<d:Distributio nC enterId m:type="Edm.Int32">2</d:Distributio nC enterId>
<d:FirstName>Derek</d:FirstName>
<d:LastName>Snyd er</d :LastName>
</m:properties>

<DriverId>4</DriverId>
</content>
</entry>
- <entry>
<id>http://lo calhost:33779/WcfDataService1.svc/Drivers(6)</id>

<FirstName>John</FirstName>
[{"DistributionCenterId":1,"DriverId":1,"FirstName":"Rob","LastName":"Tiffany"},
<title type="text" />
<updated>2010-05-24T22:12:38Z</updated>
- <author>
<name />
</author>

<LastName>Dietz</LastName>
<link rel="edit" title="Driver" href="Drivers(6)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/d ataservices/related/DistributionCenter" type="application/atom+xml;type=entry" title="DistributionCenter" href="Drivers(6)/DistributionC enter" />
<link rel="http://schemas.microsoft.com/ado/2007/08/d ataservices/related/Todays" type="application/ato m+xml;type=feed" title="Tod ays" href="Drivers(6)/Tod ays" />
<category term="C ontosoBottlingModel.Driver" scheme="http://schemas.micro so ft.com/ado/2007/08/dataservices/scheme" />

</Driver>
- <content type="ap plication/xml">

{"DistributionCenterId":1,"DriverId":2,"FirstName":"Loke Uei","LastName":"Tan"},
- <m:p rop erties>
<d:DriverId m:type="Ed m.Int32">6</d:DriverId>
<d:Distributio nC enterId m:type="Edm.Int32">2</d:Distributio nC enterId>

<Driver>
<d:FirstName>Steve</d:FirstName>
<d:LastName>Hegenderfer</d :LastName>
</m:properties>
</content>
</entry>

<DistributionCenterId>2</DistributionCenterId>
- <entry>
<id>http://lo calhost:33779/WcfDataService1.svc/Drivers(7)</id>

{"DistributionCenterId":1,"DriverId":3,"FirstName":"Dan","LastName":"Bouie"},
<title type="text" />
<updated>2010-05-24T22:12:38Z</updated>
- <author>

<DriverId>5</DriverId>
<name />
</author>
<link rel="edit" title="Driver" href="Drivers(7)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/d ataservices/related/DistributionCenter" type="application/atom+xml;type=entry" title="DistributionCenter" href="Drivers(7)/DistributionC enter" />

<FirstName>Derek</FirstName>
<link rel="http://schemas.microsoft.com/ado/2007/08/d ataservices/related/Todays" type="application/ato m+xml;type=feed" title="Tod ays" href="Drivers(7)/Tod ays" />
<category term="C ontosoBottlingModel.Driver" scheme="http://schemas.micro so ft.com/ado/2007/08/dataservices/scheme" />
- <content type="ap plication/xml">

{"DistributionCenterId":1,"DriverId":4,"FirstName":"John","LastName":"Dietz"},
- <m:p rop erties>

<LastName>Snyder</LastName>
<d:DriverId m:type="Ed m.Int32">7</d:DriverId>
<d:Distributio nC enterId m:type="Edm.Int32">2</d:Distributio nC enterId>
<d:FirstName>Chip</d:FirstName>
<d:LastName>Vollers</d:LastName>
</m:properties>

</Driver>
</content>
</entry>
- <entry>
<id>http://lo calhost:33779/WcfDataService1.svc/Drivers(8)</id>

<Driver>
<title type="text" />
<updated>2010-05-24T22:12:38Z</updated>
- <author>
<name />
</author>

<DistributionCenterId>2</DistributionCenterId>
<link rel="edit" title="Driver" href="Drivers(8)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/d ataservices/related/DistributionCenter" type="application/atom+xml;type=entry" title="DistributionCenter" href="Drivers(8)/DistributionC enter" />
<link rel="http://schemas.microsoft.com/ado/2007/08/d ataservices/related/Todays" type="application/ato m+xml;type=feed" title="Tod ays" href="Drivers(8)/Tod ays" />
<category term="C ontosoBottlingModel.Driver" scheme="http://schemas.micro so ft.com/ado/2007/08/dataservices/scheme" />

<DriverId>6</DriverId>
- <content type="ap plication/xml">

{"DistributionCenterId":2,"DriverId":5,"FirstName":"Derek","LastName":"Snyder"},
- <m:p rop erties>
<d:DriverId m:type="Ed m.Int32">8</d:DriverId>
<d:Distributio nC enterId m:type="Edm.Int32">2</d:Distributio nC enterId>
<d:FirstName>James</d:FirstName>

<FirstName>Steve</FirstName>
<d:LastName>Pratt</d:LastName>
</m:properties>
</content>
</entry>

<LastName>Hegenderfer</LastName>
</feed >
The same list o f 8 Customers using SOAP and a DataSet dropp ed us d own to 3 kb but still too big for my taste.

{"DistributionCenterId":2,"DriverId":6,"FirstName":"Steve","LastName":“Harris"},
<?xml version="1.0" encod ing="utf-8"?>
<DataSet xmlns="http://tempuri.o rg/">
<xs:schema id ="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microso ft-com:xml-msdata">

</Driver>
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unb ounded">
<xs:element name="Driver">

<Driver>
<xs:complexType>
<xs:sequence>
<xs:element name="DriverId" type="xs:int" minOccurs="0" />

{"DistributionCenterId":2,"DriverId":7,"FirstName":"Chip","LastName":"Vollers"},
<xs:element name="Distrib utionCenterId " type="xs:int" minOccurs="0" />
<xs:element name="FirstName" typ e="xs:string" minOccurs="0" />

<DistributionCenterId>2</DistributionCenterId>
<xs:element name="LastName" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexTyp e>
</xs:element>
</xs:choice>

<DriverId>7</DriverId>
</xs:complexTyp e>
</xs:element>
</xs:schema>

{"DistributionCenterId":2,"DriverId":8,"FirstName":"James","LastName":"Pratt"}]
<diffgr:diffg ram xmlns:msd ata="urn:schemas-microsoft-com:xml-msdata" xmlns:d iffgr="urn:schemas-microsoft-co m:xml-diffgram-v1">

<FirstName>Chip</FirstName>
<NewDataSet xmlns="">
<Driver diffgr:id="Driver1" msd ata:rowOrder="0">
<DriverId>1</DriverId>
<DistributionCenterId>1</DistributionC enterId>
<FirstName>Rob</FirstName>

<LastName>Vollers</LastName>
<LastName>Tiffany</LastName>
</Driver>
<Driver diffgr:id="Driver2" msd ata:rowOrder="1">
<DriverId>2</DriverId>

</Driver>
<DistributionCenterId>1</DistributionC enterId>
<FirstName>Loke Uei</FirstName>
<LastName>Tan</LastName>
</Driver>
<Driver diffgr:id="Driver3" msd ata:rowOrder="2">

<Driver>
<DriverId>3</DriverId>
<DistributionCenterId>1</DistributionC enterId>
<FirstName>Dan</FirstName>
<LastName>Bouie</LastName>
</Driver>

<DistributionCenterId>2</DistributionCenterId>
<Driver diffgr:id="Driver4" msd ata:rowOrder="3">
<DriverId>4</DriverId>
<DistributionCenterId>1</DistributionC enterId>
<FirstName>John</FirstName>

<DriverId>8</DriverId>
<LastName>Dietz</LastName>
</Driver>
<Driver diffgr:id="Driver5" msd ata:rowOrder="4">
<DriverId>5</DriverId>
<DistributionCenterId>2</DistributionC enterId>

<FirstName>James</FirstName>
<FirstName>Derek</FirstName>
<LastName>Snyder</LastName>
</Driver>
<Driver diffgr:id="Driver6" msd ata:rowOrder="5">

<LastName>Pratt</LastName>
<DriverId>6</DriverId>
<DistributionCenterId>2</DistributionC enterId>
<FirstName>Steve</FirstName>
<LastName>Hegend erfer</LastName>
</Driver>

</Driver>
<Driver diffgr:id="Driver7" msd ata:rowOrder="6">
<DriverId>7</DriverId>
<DistributionCenterId>2</DistributionC enterId>
<FirstName>C hip</FirstName>

</ArrayOfDriver>
<LastName>Vollers</LastName>
</Driver>
<Driver diffgr:id="Driver8" msd ata:rowOrder="7">
<DriverId>8</DriverId>
<DistributionCenterId>2</DistributionC enterId>
<FirstName>James</FirstName>
<LastName>Pratt</LastName>
</Driver>
</NewDataSet>
</diffgr:diffg ram>
</DataSet>
Communications: Cloud-initiated
Push Notifications

!Raaawww

Push data to your application


Single connecting between the If app is not currently running MPNS
device and the notification service discards the message.
Bandwidth- and battery-friendly Watch out for max payload size. If
Note: no guarantee of delivery exceeds use to drive app to pull content
from service
Communications: Subscribing to Push
Device requests a channel
(4)
*NS returns channel *NS

Device sends URL to cloud


Channel URL is stored in cloud (1) (2)
(5)
Web Role
Cloud sends notification
(3)
*NS pushes to device
Communications: Cloud-initiated to device?
Common pattern
Use cloud-initiated push to tell
the device to call to a service (1) *NS

Cloud sends notification


Notification services (2)
pushes to device Web Role
(3)
Device receives message (4)
and calls to a service
Web Role sends a response
Notifications: Different services
Windows 8: Windows Push Notification Service (WNS)

Windows Phone: Microsoft Push Notification Service (MPNS)

iOS: Apple Push Notification Service (APNS)

Android: Google Cloud Messaging (GCM)


Demonstrate Push
Notifications on Windows
Phone using NuGets

demo
Platform Services
Platform Services

Access Control Service Caching

Content
Delivery
Network
SQL Database Data Sync Traffic Manager (CDN)
Tools &
Resources
Windows Azure Toolkits for Devices
Easier for device developers to use Windows Azure
Windows Phone iOS Android

http://bit.ly/watwp7 http://bit.ly/watios http://bit.ly/watandroid


Summary
Devices + Cloud

Storage Identity

Communications Platform Services

Toolkits
Summary
© 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.

You might also like