Your SlideShare is downloading. ×
0
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

CloudBrew: Windows Azure Mobile Services - Next stage

626

Published on

Have a need for backend but don't have people to build it for you? Windows Azure Mobile Service is service to build backend service quickly with all of the often needed features. In this session we …

Have a need for backend but don't have people to build it for you? Windows Azure Mobile Service is service to build backend service quickly with all of the often needed features. In this session we will start from basics and continue to next level from there and look how you can start to use the service for advanced scenarios!

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
626
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Thank you, sponsors!
  • 2. What is Mobile Services?
  • 3. Authentication out of the box • • • • Microsoft Account Twitter login Google login Facebook login
  • 4. Developers.facebook.com
  • 5. Setup facebook
  • 6. Setup Mobile Services
  • 7. Create Windows 8 project
  • 8. Set table access level
  • 9. Windows 8 sample application
  • 10. Enable authenication private MobileServiceUser user; private async Task Authenticate() { user = await App.MobileService.LoginAsync(MobileServiceAuthenticationProvider.Facebook); var message = string.Format("You are now logged in - {0}", user.UserId); var dialog = new MessageDialog(message); dialog.Commands.Add(new UICommand("OK")); await dialog.ShowAsync(); } protected override async void OnNavigatedTo(NavigationEventArgs e) { await Authenticate(); RefreshTodoItems(); }
  • 11. See results on Windows 8 app
  • 12. Enable authenication private MobileServiceUser user; private async Task Authenticate() { user = await App.MobileService.LoginAsync(MobileServiceAuthenticationProvider.Facebook); var message = string.Format("You are now logged in - {0}", user.UserId); var dialog = new MessageDialog(message); dialog.Commands.Add(new UICommand("OK")); await dialog.ShowAsync(); } protected override async void OnNavigatedTo(NavigationEventArgs e) { await Authenticate(); RefreshTodoItems(); }
  • 13. Authentication with groups on client private FacebookSessionClient FacebookSessionClient = new FacebookSessionClient("1434104456805487"); private FacebookSession fbSession; private MobileServiceUser user; private async Task Authenticate() { fbSession = await FacebookSessionClient.LoginAsync("user_groups,user_likes,email"); var client = new FacebookClient(fbSession.AccessToken); var token = JObject.FromObject(new { access_token = fbSession.AccessToken}); user = await App.MobileService.LoginAsync(MobileServiceAuthenticationProvider.Facebook, token); } protected override async void OnNavigatedTo(NavigationEventArgs e) { await Authenticate(); RefreshTodoItems(); }
  • 14. CRUD • Create • Read • Update • Delete
  • 15. Read operation function read(query, user, request) { request.execute(); }
  • 16. Read operation with filtering function read(query, user, request) { var identities = user.getIdentities(); var req = require('request'); var fbAccessToken = identities.facebook.accessToken; var url = 'https://graph.facebook.com/me?fields=groups.fields(id)&access_token=' + fbAccessToken; req(url, function (err, resp, body) { var userData = JSON.parse(body); var groups = userData.groups.data; for(var i=0;i<groups.length;i++){ if (groups[i].id == "304013539633881") { request.execute(); return; } } query.take(2); request.execute(); }); }
  • 17. Major features of data handling • Dynamic schema • Windows Azure SQL Database
  • 18. Changing table model public class TodoItem { public string Id { get; set; } [JsonProperty(PropertyName = "text")] public string Text { get; set; } [JsonProperty(PropertyName = "complete")] public bool Complete { get; set; } public string Platfrom { get; set; } }
  • 19. Changing handling logic private async void UpdateCheckedTodoItem(TodoItem item) { if (item.Platfrom == null) { item.Platfrom = "Windows 8"; } await todoTable.UpdateAsync(item); items.Remove(item); } private void ButtonSave_Click(object sender, RoutedEventArgs e) { var todoItem = new TodoItem { Text = TextInput.Text, Platfrom = "Windows 8" }; InsertTodoItem(todoItem); }
  • 20. Data at portal
  • 21. Data at SQL explorer
  • 22. Notifications • Windows Phone • Android • iPhone • Windows 8
  • 23. Adding notifications to Windows 8
  • 24. Visual Studio wizard
  • 25. Reserve application name
  • 26. Choose used mobile service
  • 27. Notification is done! App start and send channel to mobile service 2. Mobile service saves that into database and sends notification 1.
  • 28. Client implementation 2.0 public async static void UploadChannel(MobileServiceUser user) { var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); var token = HardwareIdentification.GetPackageSpecificToken(null); string installationId = CryptographicBuffer.EncodeToBase64String(token.Id); var ch = new Jobject { {"channelUri", channel.Uri}, {"installationId", installationId}, {"userId", user.UserId.Substring(9)} }; await App.MobileService.GetTable("channels").InsertAsync(ch); } private MobileServiceUser user; protected override async void OnNavigatedTo(NavigationEventArgs e) { await Authenticate(); cloudbrewtapanila.cloudbrewtapanilaPush.UploadChannel(user); RefreshTodoItems(); }
  • 29. TodoItem Insert function insert(item, user, request) { var identities = user.getIdentities(); var fbUserId = identities.facebook.userId; var ct = tables.getTable("channels"); ct.where({ userId: fbUserId }).read({ success: function (results) { if (results.length > 0) { sendNotifications(results[0].channelUri,item); } } }); function sendNotifications(uri,todoItem) { push.wns.sendToastText01(uri, { text1: "You have just inserted new todo " + todoItem.text }, { success: function (pushResponse) { console.log("Sent push:", pushResponse); } }); } request.execute(); }
  • 30. Enable from portal
  • 31. Git repository
  • 32. Clone your git repository
  • 33. Folder structure
  • 34. NPM install
  • 35. Sendgrid
  • 36. Sending email var req = require('request'); var fbAccessToken = identities.facebook.accessToken; var url = 'https://graph.facebook.com/me?fields=email&access_token=' + fbAccessToken; req(url, function (err, resp, body) { var userData = JSON.parse(body); var userEmail = userData.email; var sendgrid = require('sendgrid')("TapanilaCloudBrew", "password"); sendgrid.send({ to: userEmail, from: 'teemu@tapanila.net', subject: ‘New todoitem added', text: ‘You added new todoitem ‘ + todoItem.text }); });
  • 37. Creating scheduler job
  • 38. BrewCloud function BrewCloud() { var td = tables.getTable("TodoItem"); td.where({ complete: false }).read({ success: function (results) { if (results.length > 0) { var sendgrid = require('sendgrid')("TapanilaCloudBrew", "password"); sendgrid.send({ to: "teemu@tapanila.net", from: 'teemu@tapanila.net', subject: 'Status of brewing cloud', text: 'There is ' + results.length + " items left“ }); } } }); }
  • 39. Log on portal
  • 40. Log on Visual Studio
  • 41. What is Mobile Services?
  • 42. The Cloud for Modern Business Grab your benefit aka.ms/azuretry Deploy fast in the cloud, scale elastically and minimize test cost Activate your Windows Azure MSDN benefit at no additional charge aka.ms/msdnsubs cr

×