SlideShare a Scribd company logo
1 of 18
Mobile Services
 Data Storage



                            Radu Vunvulea
                     vunvulear@gmail.com
         http://vunvulearadu.blogspot.com
Who am I?
        {
            ā€œnameā€ : ā€œRadu Vunvulea,
            ā€œcompanyā€ : ā€œiQuestā€,
            ā€œuserTypeā€ : ā€œenthusiasticā€
            ā€œtechnologiesā€ : [ ā€œ.NETā€, ā€œJSā€, ā€œAzureā€, ā€œWebā€,
                ā€œMobileā€, ā€œSLā€ ],
            ā€œw8experienceā€ : [ ā€œ2 LoB Appā€, ā€œ1 Travel Appā€],
            ā€œblogā€ : ā€œvunvulearadu.blogspot.comā€,
            ā€œemailā€ : ā€vunvulear@gmail.comā€,
            ā€œsocialMediaā€ :
                {
                         ā€œtwitterā€ : ā€œ@RaduVunvuleaā€,
                         ā€œfbā€ : ā€œradu.vunvuleaā€
                }
        }
Windows Azure Mobile Services
ā€¢ This is the topic for today meeting
Agenda
ā€¢   Features
ā€¢   Pricing
ā€¢   Account setup
ā€¢   Account configuration for storing data
ā€¢   What kind of data can be added
ā€¢   Custom scripts
ā€¢   Authentication
ā€¢   Available API
ā€¢   Demo
Features of Mobile Services
ā€¢ User authentication
    ā€¢   Windows Live
    ā€¢   Facebook
    ā€¢   Google
    ā€¢   Twitter
ā€¢ Store data in the cloud
    ā€¢   Windows Azure Storage
ā€¢ Push notification infrastructure
    ā€¢   All the service is build in in Windows Azure
Pricing of Mobile Services
ā€¢ Free package in the 90 days trial:
    ā€¢   Outbound traffic included 165MB
    ā€¢   Maximum 10 mobile services
ā€¢ Reserved instance model:
    ā€¢   3 dedicated servers (small instances, pay-as-you-go model)
    ā€¢   100 mobile services
    ā€¢   Outbound data transfer will be paid




ā€¢ Price available during preview can change in the final release
Pricing of Mobile Services
ā€¢ Free package in the 90 days trial:
    ā€¢   Outbound traffic included 165MB
    ā€¢   Maximum 10 mobile services
ā€¢ Reserved instance model:
    ā€¢   3 dedicated servers (small instances, pay-as-you-go model)
    ā€¢   100 mobile services
    ā€¢   Outbound data transfer will be paid




ā€¢ Price available during preview can change in the final release
Setup your account
ā€¢ Create a new mobile service from the ā€œNew/Mobile Service/Createā€
ā€¢ A unique name of the mobile service need to be created
ā€¢ If we need a fresh database can be created or an existing one can be
  used (if is in the same region)
    ā€¢   After creating the database, we can use it as a normal database
ā€¢ The service can be active for one of the following platform:
    ā€¢   IOS
    ā€¢   Windows Phone 8
    ā€¢   Windows Store
ā€¢ For each of the platform, after creating the mobile service, we can
  download the project that contains all the configurations
Configure environment to store data
ā€¢ From the management portal each service contains a tab named
  ā€œDataā€
ā€¢ We can managed all the tables that we have
    ā€¢   Create/Edit/Delete each table
    ā€¢   See the content of each table
ā€¢ For each table, we can set the rights of each user of the given table:
    ā€¢   Anybody with the application key
    ā€¢   Everyone
    ā€¢   Only authenticate user
    ā€¢   Only scripts and admin
ā€¢ This rights can be different for CRUD operations
What kind of data can be added?
ā€¢ Any kind of serializable data
ā€¢ Each entity have to be decorated with DataContract and
   DataMember attributes
ā€¢ It is recomanded to use the Name field of DataMember
[DataContract]
public class MyFoo
{
         public int Id { get;set;}

       [DataMember(Name = "Name"]
       public string Name { get;set;}
}
The ā€œIdā€ field donā€™t need to be decorated with DataMember attribute
Custom scripts
ā€¢ Each CRUD operation can contain a custom script that is executed
   on the server side
ā€¢ This scripts can be for validation purposes or to add/set custom
   fields
ā€¢ Language: JavaScript
function insert(item, user, request) {
  if (item.name == "Tom") {
      request.respond(statusCodes.BAD_REQUEST, 'Tom name cannot be
added');
  } else {
      request.execute();
  }
}
ā€¢ When this kind of error appear, the client need to catch
   ā€œMobileServiceInvalidOperationExceptionā€ exception
Custom scripts
ā€¢ Each script can have helper functions
ā€¢ Base action that need to be done by a script
    ā€¢   execute ā€“ execute the given action
    ā€¢   respond ā€“ send a response back to the client
ā€¢ We cannot define global variable, each call is executed in a separate
  request
ā€¢ Some of the base modules are from node.js
    ā€¢ Example: we can make a request to another web-service to check data
    function insert(item, user, request) {
      var request = require('request');
      request('http://myFoo.com/Services/validate', function(err, response, body) {
      ...
      });
    }
Custom scripts
Catch the exception on the client
try
{
     await myTable.InsertAsync(item);
     items.Add(item);
}
catch (MobileServiceInvalidOperationException e)
{
        Trace.Write("Error: " + e.Reponse.Content);
}
Control user access to data
ā€¢ Define custom scripts that check if the given user id has rights to
  access his data

function insert(item, user, request) {
  item.userId = user.userId;
  request.execute();
}
function read(query, user, request) {
   query.where({ userId: user.userId });
   request.execute();
}
ā€¢ We need to store the user id.
ā€¢ Each user will have a unique user id
ā€¢ The user id is generated automatically by the system
ā€¢ ļŒ We cannot store this scripts in our source control system
How to work with data
ā€¢ Define custom scripts that check if the given user id has rights to
  access his data
App.MobileService.GetTable<MyEntity>()
ā€¢ Before this we need to create a table with the same name
ā€¢ Update: table.UpdateAsync(entity)
ā€¢ Delete: table.DeleteAsync(entity)
ā€¢ Insert: table.InsertAsync(entity)
ā€¢ Fetch with data:
    ā€¢   Where
    ā€¢   Take
    ā€¢   Skip
    ā€¢   OrderBy
    ā€¢   Select
    ā€¢   ThenBy
    ā€¢   ToListAsync
Demo
THE END




                        Radu Vunvulea
                 vunvulear@gmail.com
     http://vunvulearadu.blogspot.com

More Related Content

What's hot

Introduction to j query
Introduction to j queryIntroduction to j query
Introduction to j query
thewarlog
Ā 
Building your First MEAN App
Building your First MEAN AppBuilding your First MEAN App
Building your First MEAN App
MongoDB
Ā 

What's hot (12)

Working with GIT
Working with GITWorking with GIT
Working with GIT
Ā 
Offline Html5 3days
Offline Html5 3daysOffline Html5 3days
Offline Html5 3days
Ā 
JavaOne 2016 - Reactive Microservices with Java and Java EE
JavaOne 2016 - Reactive Microservices with Java and Java EEJavaOne 2016 - Reactive Microservices with Java and Java EE
JavaOne 2016 - Reactive Microservices with Java and Java EE
Ā 
Introduction to j query
Introduction to j queryIntroduction to j query
Introduction to j query
Ā 
Introduction to j_query
Introduction to j_queryIntroduction to j_query
Introduction to j_query
Ā 
Getting Started with Javascript
Getting Started with JavascriptGetting Started with Javascript
Getting Started with Javascript
Ā 
Streaming Data Pipelines with MongoDB and Kafka at ao.com
Streaming Data Pipelines with MongoDB and Kafka at ao.comStreaming Data Pipelines with MongoDB and Kafka at ao.com
Streaming Data Pipelines with MongoDB and Kafka at ao.com
Ā 
Thinkin' Tags - Rapid Prototyping of CSS Layouts
Thinkin' Tags - Rapid Prototyping of CSS LayoutsThinkin' Tags - Rapid Prototyping of CSS Layouts
Thinkin' Tags - Rapid Prototyping of CSS Layouts
Ā 
Drupal migrate-june2015
Drupal migrate-june2015Drupal migrate-june2015
Drupal migrate-june2015
Ā 
Building Rich Internet Apps with Silverlight 2
Building Rich Internet Apps with Silverlight 2Building Rich Internet Apps with Silverlight 2
Building Rich Internet Apps with Silverlight 2
Ā 
JavaCro'15 - Service Discovery in OSGi Beyond the JVM using Docker and Consul...
JavaCro'15 - Service Discovery in OSGi Beyond the JVM using Docker and Consul...JavaCro'15 - Service Discovery in OSGi Beyond the JVM using Docker and Consul...
JavaCro'15 - Service Discovery in OSGi Beyond the JVM using Docker and Consul...
Ā 
Building your First MEAN App
Building your First MEAN AppBuilding your First MEAN App
Building your First MEAN App
Ā 

Similar to Mobile services on windows azure (part2)

Mobile services on windows azure (part3)
Mobile services on windows azure (part3)Mobile services on windows azure (part3)
Mobile services on windows azure (part3)
Radu Vunvulea
Ā 
Codemotion Berlin-Mobile Services
Codemotion Berlin-Mobile ServicesCodemotion Berlin-Mobile Services
Codemotion Berlin-Mobile Services
Mike Benkovich
Ā 
Mobile services on windows azure (part1)
Mobile services on windows azure (part1)Mobile services on windows azure (part1)
Mobile services on windows azure (part1)
Radu Vunvulea
Ā 
An Introduction to webOS
An Introduction to webOSAn Introduction to webOS
An Introduction to webOS
Kevin Decker
Ā 
What's New for the Windows Azure Developer? Lots! (July 2013)
What's New for the Windows Azure Developer?  Lots! (July 2013)What's New for the Windows Azure Developer?  Lots! (July 2013)
What's New for the Windows Azure Developer? Lots! (July 2013)
Michael Collier
Ā 

Similar to Mobile services on windows azure (part2) (20)

Mobile services on windows azure (part3)
Mobile services on windows azure (part3)Mobile services on windows azure (part3)
Mobile services on windows azure (part3)
Ā 
Codemotion Berlin-Mobile Services
Codemotion Berlin-Mobile ServicesCodemotion Berlin-Mobile Services
Codemotion Berlin-Mobile Services
Ā 
Scalability in cloud applications
Scalability in cloud applicationsScalability in cloud applications
Scalability in cloud applications
Ā 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB Stitch
Ā 
MongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
MongoDB.local Sydney: Evolving your Data Access with MongoDB StitchMongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
MongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
Ā 
Cnam cours azure zecloud mobile services
Cnam cours azure zecloud mobile servicesCnam cours azure zecloud mobile services
Cnam cours azure zecloud mobile services
Ā 
Cloud Powered Mobile Apps with Azure
Cloud Powered Mobile Apps with AzureCloud Powered Mobile Apps with Azure
Cloud Powered Mobile Apps with Azure
Ā 
World Azure Day Mobile Services Presentation
World Azure Day Mobile Services PresentationWorld Azure Day Mobile Services Presentation
World Azure Day Mobile Services Presentation
Ā 
Mobile services on windows azure (part1)
Mobile services on windows azure (part1)Mobile services on windows azure (part1)
Mobile services on windows azure (part1)
Ā 
AWS re:Invent 2016: Content and Data Platforms at Vevo: Rebuilding and Scalin...
AWS re:Invent 2016: Content and Data Platforms at Vevo: Rebuilding and Scalin...AWS re:Invent 2016: Content and Data Platforms at Vevo: Rebuilding and Scalin...
AWS re:Invent 2016: Content and Data Platforms at Vevo: Rebuilding and Scalin...
Ā 
Medium TechTalk ā€”Ā iOS
Medium TechTalk ā€”Ā iOSMedium TechTalk ā€”Ā iOS
Medium TechTalk ā€”Ā iOS
Ā 
Cloud Powered Mobile Apps with Azure
Cloud Powered Mobile Apps  with AzureCloud Powered Mobile Apps  with Azure
Cloud Powered Mobile Apps with Azure
Ā 
An Introduction to webOS
An Introduction to webOSAn Introduction to webOS
An Introduction to webOS
Ā 
2015.04.23 Azure Mobile Services
2015.04.23 Azure Mobile Services2015.04.23 Azure Mobile Services
2015.04.23 Azure Mobile Services
Ā 
Tutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchTutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB Stitch
Ā 
Android lessons you won't learn in school
Android lessons you won't learn in schoolAndroid lessons you won't learn in school
Android lessons you won't learn in school
Ā 
Windows Azure mobile services - Kolkata - 28 June 2015
Windows Azure mobile services - Kolkata - 28 June 2015Windows Azure mobile services - Kolkata - 28 June 2015
Windows Azure mobile services - Kolkata - 28 June 2015
Ā 
What's New for the Windows Azure Developer? Lots! (July 2013)
What's New for the Windows Azure Developer?  Lots! (July 2013)What's New for the Windows Azure Developer?  Lots! (July 2013)
What's New for the Windows Azure Developer? Lots! (July 2013)
Ā 
AWS IoT Deep Dive
AWS IoT Deep DiveAWS IoT Deep Dive
AWS IoT Deep Dive
Ā 
ŠŠ½Ń‚Š¾Š½ Š‘Š¾Š¹ŠŗŠ¾ (Microsoft Azure MVP, Ukrainian Azure Community Founder) Ā«Azure M...
ŠŠ½Ń‚Š¾Š½ Š‘Š¾Š¹ŠŗŠ¾ (Microsoft Azure MVP, Ukrainian Azure Community Founder) Ā«Azure M...ŠŠ½Ń‚Š¾Š½ Š‘Š¾Š¹ŠŗŠ¾ (Microsoft Azure MVP, Ukrainian Azure Community Founder) Ā«Azure M...
ŠŠ½Ń‚Š¾Š½ Š‘Š¾Š¹ŠŗŠ¾ (Microsoft Azure MVP, Ukrainian Azure Community Founder) Ā«Azure M...
Ā 

Mobile services on windows azure (part2)

  • 1. Mobile Services Data Storage Radu Vunvulea vunvulear@gmail.com http://vunvulearadu.blogspot.com
  • 2. Who am I? { ā€œnameā€ : ā€œRadu Vunvulea, ā€œcompanyā€ : ā€œiQuestā€, ā€œuserTypeā€ : ā€œenthusiasticā€ ā€œtechnologiesā€ : [ ā€œ.NETā€, ā€œJSā€, ā€œAzureā€, ā€œWebā€, ā€œMobileā€, ā€œSLā€ ], ā€œw8experienceā€ : [ ā€œ2 LoB Appā€, ā€œ1 Travel Appā€], ā€œblogā€ : ā€œvunvulearadu.blogspot.comā€, ā€œemailā€ : ā€vunvulear@gmail.comā€, ā€œsocialMediaā€ : { ā€œtwitterā€ : ā€œ@RaduVunvuleaā€, ā€œfbā€ : ā€œradu.vunvuleaā€ } }
  • 3. Windows Azure Mobile Services ā€¢ This is the topic for today meeting
  • 4. Agenda ā€¢ Features ā€¢ Pricing ā€¢ Account setup ā€¢ Account configuration for storing data ā€¢ What kind of data can be added ā€¢ Custom scripts ā€¢ Authentication ā€¢ Available API ā€¢ Demo
  • 5. Features of Mobile Services ā€¢ User authentication ā€¢ Windows Live ā€¢ Facebook ā€¢ Google ā€¢ Twitter ā€¢ Store data in the cloud ā€¢ Windows Azure Storage ā€¢ Push notification infrastructure ā€¢ All the service is build in in Windows Azure
  • 6. Pricing of Mobile Services ā€¢ Free package in the 90 days trial: ā€¢ Outbound traffic included 165MB ā€¢ Maximum 10 mobile services ā€¢ Reserved instance model: ā€¢ 3 dedicated servers (small instances, pay-as-you-go model) ā€¢ 100 mobile services ā€¢ Outbound data transfer will be paid ā€¢ Price available during preview can change in the final release
  • 7. Pricing of Mobile Services ā€¢ Free package in the 90 days trial: ā€¢ Outbound traffic included 165MB ā€¢ Maximum 10 mobile services ā€¢ Reserved instance model: ā€¢ 3 dedicated servers (small instances, pay-as-you-go model) ā€¢ 100 mobile services ā€¢ Outbound data transfer will be paid ā€¢ Price available during preview can change in the final release
  • 8. Setup your account ā€¢ Create a new mobile service from the ā€œNew/Mobile Service/Createā€ ā€¢ A unique name of the mobile service need to be created ā€¢ If we need a fresh database can be created or an existing one can be used (if is in the same region) ā€¢ After creating the database, we can use it as a normal database ā€¢ The service can be active for one of the following platform: ā€¢ IOS ā€¢ Windows Phone 8 ā€¢ Windows Store ā€¢ For each of the platform, after creating the mobile service, we can download the project that contains all the configurations
  • 9. Configure environment to store data ā€¢ From the management portal each service contains a tab named ā€œDataā€ ā€¢ We can managed all the tables that we have ā€¢ Create/Edit/Delete each table ā€¢ See the content of each table ā€¢ For each table, we can set the rights of each user of the given table: ā€¢ Anybody with the application key ā€¢ Everyone ā€¢ Only authenticate user ā€¢ Only scripts and admin ā€¢ This rights can be different for CRUD operations
  • 10. What kind of data can be added? ā€¢ Any kind of serializable data ā€¢ Each entity have to be decorated with DataContract and DataMember attributes ā€¢ It is recomanded to use the Name field of DataMember [DataContract] public class MyFoo { public int Id { get;set;} [DataMember(Name = "Name"] public string Name { get;set;} } The ā€œIdā€ field donā€™t need to be decorated with DataMember attribute
  • 11. Custom scripts ā€¢ Each CRUD operation can contain a custom script that is executed on the server side ā€¢ This scripts can be for validation purposes or to add/set custom fields ā€¢ Language: JavaScript function insert(item, user, request) { if (item.name == "Tom") { request.respond(statusCodes.BAD_REQUEST, 'Tom name cannot be added'); } else { request.execute(); } } ā€¢ When this kind of error appear, the client need to catch ā€œMobileServiceInvalidOperationExceptionā€ exception
  • 12. Custom scripts ā€¢ Each script can have helper functions ā€¢ Base action that need to be done by a script ā€¢ execute ā€“ execute the given action ā€¢ respond ā€“ send a response back to the client ā€¢ We cannot define global variable, each call is executed in a separate request ā€¢ Some of the base modules are from node.js ā€¢ Example: we can make a request to another web-service to check data function insert(item, user, request) { var request = require('request'); request('http://myFoo.com/Services/validate', function(err, response, body) { ... }); }
  • 13. Custom scripts Catch the exception on the client try { await myTable.InsertAsync(item); items.Add(item); } catch (MobileServiceInvalidOperationException e) { Trace.Write("Error: " + e.Reponse.Content); }
  • 14. Control user access to data ā€¢ Define custom scripts that check if the given user id has rights to access his data function insert(item, user, request) { item.userId = user.userId; request.execute(); } function read(query, user, request) { query.where({ userId: user.userId }); request.execute(); } ā€¢ We need to store the user id. ā€¢ Each user will have a unique user id ā€¢ The user id is generated automatically by the system ā€¢ ļŒ We cannot store this scripts in our source control system
  • 15. How to work with data ā€¢ Define custom scripts that check if the given user id has rights to access his data App.MobileService.GetTable<MyEntity>() ā€¢ Before this we need to create a table with the same name ā€¢ Update: table.UpdateAsync(entity) ā€¢ Delete: table.DeleteAsync(entity) ā€¢ Insert: table.InsertAsync(entity) ā€¢ Fetch with data: ā€¢ Where ā€¢ Take ā€¢ Skip ā€¢ OrderBy ā€¢ Select ā€¢ ThenBy ā€¢ ToListAsync
  • 16. Demo
  • 17.
  • 18. THE END Radu Vunvulea vunvulear@gmail.com http://vunvulearadu.blogspot.com

Editor's Notes

  1. COM
  2. COM
  3. COM
  4. COM
  5. COM
  6. COM
  7. COM
  8. COM
  9. COM
  10. COM
  11. COM
  12. COM
  13. COM
  14. COM