Your SlideShare is downloading. ×

Mobile services on windows azure (part2)

568

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
568
On Slideshare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
5
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
  • COM
  • COM
  • COM
  • COM
  • COM
  • COM
  • COM
  • COM
  • COM
  • COM
  • COM
  • COM
  • COM
  • COM
  • Transcript

    • 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: JavaScriptfunction insert(item, user, request) { if (item.name == "Tom") { request.respond(statusCodes.BAD_REQUEST, Tom name cannot beadded); } 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 scriptsCatch the exception on the clienttry{ 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 datafunction 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 dataApp.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. THE END Radu Vunvulea vunvulear@gmail.com http://vunvulearadu.blogspot.com

    ×