The Hitchhicker’s Guide to Windows Azure Mobile Services | FalafelCON 2014
-
Upload
falafelsoftware -
Category
Software
-
view
306 -
download
1
description
Transcript of The Hitchhicker’s Guide to Windows Azure Mobile Services | FalafelCON 2014
A Hitchhiker's Guide to
Azure Mobile Services
@DavidGiard
David Giard
Microso. Technical Evangelist • @DavidGiard • DavidGiard.com • TechnologyAndFriends • [email protected]
@DavidGiard
Agenda
• Why Azure Mobile Services? • Mobile Architecture • Common Data Access • CustomizaCon • Dynamic Data • Client Code • IdenCty and Permissions • Scaling • API Scripts • NoCficaCons
@DavidGiard
Why Azure Mobile Services?
• Frees you from plumbing code • Handles API Changes • Cross-‐PlaLorm soluCon • Choose JavaScript or .NET
@DavidGiard
Mobile Architecture
Windows Phone
Data
Windows 8.1
iPhone
iPad Android
JavaScript
REST API
@DavidGiard
Permissions
Pieces of Azure Mobile Services
SQL Server table
READ
INSERT
UPDATE
DELETE
IdenCty Client Code
@DavidGiard
CreaBng a Mobile Service
@DavidGiard
CreaBng a Mobile Service
@DavidGiard
CreaBng a Mobile Service
@DavidGiard
REST
hUps://Giard.azure-‐mobile.net/Tables/Table1 • GET, PUT, POST, DELETE, PATCH • Extend GET with oData Query syntax
@DavidGiard
REST
Client Endpoint
Request Verb
Data (JSON)
Response
@DavidGiard
REST
HTTP Verb Ac+on SQL GET Read Data SELECT… POST Create Data INSERT… DELETE Delete Data DELETE… PUT or PATCH Update Data UPDATE…
@DavidGiard
oData Query Syntax
Extension Descrip+on
$filter WHERE clause
$inlinecount # items in table
$orderby SORT clause
$select Columns to return
$skip #records to skip
$top #records to return
../Tables/Table1?$filter=AcCve%20eq%20true
../Tables/Table1?$filter=AcCve eq true
../Tables/Table1$filter=AcCve%20eq%20true&$orderby=LastName
@DavidGiard
Dynamic Schema
• “Configure” tab • AutomaCcally adds columns if matching data submiUed • Useful during development • Turn off during producCon
@DavidGiard
Permissions
@DavidGiard
Scripts
• Insert • Update • Delete • Read
@DavidGiard
Demo
@DavidGiard
IdenBty – Single Sign-‐On
Client
Azure Mobile Services API
TwiUer or Facebook or Google
or Microso.
Request
TOKEN
@DavidGiard
IdenBty
@DavidGiard
IdenBty
funcCon insert(item, user, request) { item.CreatedBy = user.userId; request.execute(); }
funcCon read(query, user, request) { query.where ({CreatedBy:user.userId}); request.execute(); }
@DavidGiard
Demo
@DavidGiard
Scaling
@DavidGiard
Scaling
@DavidGiard
API Scripts
@DavidGiard
API Scripts
exports.post = funcCon(request, response) { // Use "request.service" to access features of your mobile service, e.g.: // var tables = request.service.tables; // var push = request.service.push; response.send(statusCodes.OK, { message : 'Hello World!' }); }; exports.get = funcCon(request, response) { response.send(statusCodes.OK, { message : 'Hello World!' }); };
<Mobile Service URL>/api/<API Name>
hUps://giard.azure-‐mobile.net/api/MyApi
@DavidGiard
Scheduler
@DavidGiard
Mobile Services in .NET
@DavidGiard
Mobile Services in .NET
@DavidGiard
Demo
@DavidGiard
Push NoBficaBons
@DavidGiard
Push NoBficaBons
App
Push Service APN (Apple) GCM (Google)
WNS (Windows 8) MPNS (Windows Phone)
Azure Mobile Services
var payload = '<?xml version="1.0" encoding="uL-‐8"?><toast><visual><binding template="ToastText01">' + '<text id="1">Sample Toast</text></binding></visual></toast>'; var push = request.service.push; push.wns.send(null, payload, 'wns/toast', { success: funcCon (pushResponse) { console.log("Sent push:", pushResponse); } }); }
@DavidGiard
exports.post = funcCon(request, response) {
response.send(statusCodes.OK,{ message : 'Hello World!' })
// The following call is for illustraCon purpose only
// The call and funcCon body should be moved to a script in your app
// where you want to send a noCficaCon
sendNoCficaCons(request);
};
// The following code should be moved to appropriate script in your app where noCficaCon is sent
funcCon sendNoCficaCons(request) {
var payload = '<?xml version="1.0" encoding="uL-‐8"?><toast><visual><binding template="ToastText01">' +
'<text id="1">Sample Toast</text></binding></visual></toast>';
var push = request.service.push;
push.wns.send(null,
payload,
'wns/toast', {
success: funcCon (pushResponse) {
console.log("Sent push:", pushResponse);
}
});
}
@DavidGiard
Azure Mobile Services
Push NoBficaBons
Push Service APN (Apple) GCM (Google)
WNS (Windows 8) MPNS (Windows Phone)
NoCficaCon Hub
@DavidGiard
So Long and Thanks!
David Giard • @DavidGiard • DavidGiard.com • TechnologyAndFriends.com