Building Scalable Cloud ConnectedMobile Apps using Windows AzureJahufar Sadique (99X)
What is Windows Azure MobileServices?• A set of services build on Azure that provides backend ‘plumbing’ toyour mobile app...
Getting Started• The service is not free• ..but comes with a 3 month free trial (subjectto credit card verification)• What...
• DEMO: Azure Dashboard• DEMO: Creating a new mobile service• DEMO: Download the SDK and setup project
Mobile Service: Data• Backend is Windows Azure SQL Database• Dynamic schema – create your model in code,and the fields are...
DEMOCreating a simple list of users
Authentication• Authenticate against: Facebook, Google,Twitter, Windows Live• Table level permissions for CRUD operations:...
DEMOSecuring the list of users
Server Scripts• Similar to a trigger• Allows you to build custom business logic whensomething happens to your data• Availa...
Server Scripts: ContinuedInsert: function insert(item, user, request) { }Update: function update(item, user, request) { }D...
Scripts: Continued• Example:function insert(item, user, request) {if (item.userId !== user.userId) {request.respond(status...
Push Notifications• Allows direct push to devices• Supported push services:– GCM (API key required)– APNS (Certificate req...
Implementing Push Notifications(in 5 easy steps)Code walkthrough
Push Notifications: Step 1Register App for Notifications• GCM is the native push system for Android• Register your app and...
Push Notifications: Step 2Configure Mobile Services• Copy generated API key from Google APIServices• Select ‘Push’ from Az...
Push Notifications: Step 3Integrate push library to your app• Copy gcm.jar to libs• Add permissions<permission android:nam...
Push Notifications: Step 4Register your device & handle pushes• Assuming you have ‘deviceId’ field on your data model:Stri...
Push Notifications: Step 5Getting the server to notifyfunction insert(item, user, request) {request.execute({ success: fun...
Diagnostics, Logging and Scale• Diagnostics:– CPU Time– Memory consumptions– API calls/time taken per request• Logging– Wi...
More Services• Scheduler– Schedule server scripts on demand or on interval– Examples:• Purge old data,• Poll/aggregate dat...
Thank you
Upcoming SlideShare
Loading in …5
×

Colombo Mobile Developer MeetUp - Building Scalable Cloud Connected Mobile Apps using Windows Azure

429 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
429
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Colombo Mobile Developer MeetUp - Building Scalable Cloud Connected Mobile Apps using Windows Azure

  1. 1. Building Scalable Cloud ConnectedMobile Apps using Windows AzureJahufar Sadique (99X)
  2. 2. What is Windows Azure MobileServices?• A set of services build on Azure that provides backend ‘plumbing’ toyour mobile apps.• Focus on building apps and not backend logic– Data (dynamic schema)– Authentication (Federated identities such as Facebook, Google,Twitter, Windows Live)– Server Logic (via Mobile Services Server Scripts)– Push Notifications (GCM, APNS, WNS)• Monitoring/Analytics/Logging infrastructure• Client SDKs supported for Android, iOS, Windows Phone andHTML/Javascript
  3. 3. Getting Started• The service is not free• ..but comes with a 3 month free trial (subjectto credit card verification)• What you get:http://www.windowsazure.com/en-us/pricing/free-trial/
  4. 4. • DEMO: Azure Dashboard• DEMO: Creating a new mobile service• DEMO: Download the SDK and setup project
  5. 5. Mobile Service: Data• Backend is Windows Azure SQL Database• Dynamic schema – create your model in code,and the fields are mapped by magic• Throttling and failures are automaticallyhandled.• NO RELATIONS (i.e. no foreign keys, cascadelogic etc)
  6. 6. DEMOCreating a simple list of users
  7. 7. Authentication• Authenticate against: Facebook, Google,Twitter, Windows Live• Table level permissions for CRUD operations:– Everyone (default)– Only authenticated users– Only scripts and admins
  8. 8. DEMOSecuring the list of users
  9. 9. Server Scripts• Similar to a trigger• Allows you to build custom business logic whensomething happens to your data• Available operations: insert, update, read, delete (del)e.g.:function insert (id, user, request) {request.execute();}
  10. 10. Server Scripts: ContinuedInsert: function insert(item, user, request) { }Update: function update(item, user, request) { }Delete: function del(id, user, request) { }Read: function read(query, user, request) { }•Script functions always take 3 arguments:– 2ndarg is always “user” (represents a user)– 3rdarg is always “request” (used to send responses).– 1starg changes according to operation
  11. 11. Scripts: Continued• Example:function insert(item, user, request) {if (item.userId !== user.userId) {request.respond(statusCodes.FORBIDDEN, ‘Access Denied.);} else {request.execute();}}* Complete script reference can be found at:http://msdn.microsoft.com/en-us/library/windowsazure/jj554226.aspx
  12. 12. Push Notifications• Allows direct push to devices• Supported push services:– GCM (API key required)– APNS (Certificate required)– WNS (Client secret & Package SID required)N.B: For Windows Phone/WNS: 500 notifications/per user/per day.
  13. 13. Implementing Push Notifications(in 5 easy steps)Code walkthrough
  14. 14. Push Notifications: Step 1Register App for Notifications• GCM is the native push system for Android• Register your app and enable GCM usingGoogle API console(https://code.google.com/apis/console/)
  15. 15. Push Notifications: Step 2Configure Mobile Services• Copy generated API key from Google APIServices• Select ‘Push’ from Azure Console and pastekey
  16. 16. Push Notifications: Step 3Integrate push library to your app• Copy gcm.jar to libs• Add permissions<permission android:name=“com.test.permission.C2D_MESSAGE" android:protectionLevel="signature" /><uses-permission android:name=“com.test.permission.C2D_MESSAGE" /><uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /><uses-permission android:name="android.permission.GET_ACCOUNTS" /><uses-permission android:name="android.permission.WAKE_LOCK" />• Add reciever/services<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver"android:permission="com.google.android.c2dm.permission.SEND"><intent-filter><action android:name="com.google.android.c2dm.intent.RECEIVE" /><action android:name="com.google.android.c2dm.intent.REGISTRATION" /><category android:name=“com.test" /></intent-filter></receiver><service android:name=".GCMIntentService" />
  17. 17. Push Notifications: Step 4Register your device & handle pushes• Assuming you have ‘deviceId’ field on your data model:String deviceId = GCMRegistrar.getRegistrationId(this);Users.deviceId = deviceId;//save here• When a push arrives, onMessage fires:protected void onMessage(Context context, Intent intent) {//notify user etc.}http://developer.android.com/google/gcm/gs.html
  18. 18. Push Notifications: Step 5Getting the server to notifyfunction insert(item, user, request) {request.execute({ success: function() {request.respond();push.gcm.send(Users.deviceId, item.text);}}
  19. 19. Diagnostics, Logging and Scale• Diagnostics:– CPU Time– Memory consumptions– API calls/time taken per request• Logging– With server scripts via console.x (console.info,console.error etc)• Scale– Scale up or down by spinning up new VMs or byscaling up VM size
  20. 20. More Services• Scheduler– Schedule server scripts on demand or on interval– Examples:• Purge old data,• Poll/aggregate data from other sources• Schedule pushes to be sent at a certain time• SendGrid (3rdparty service)– Email-As-A-Service• Pusher (3rdparty service)– Enhanced push services (among other things)
  21. 21. Thank you

×