Building Offline Applications using Sync Framework and SQL Azure – PDC10 Session Review

Nina (Ling) Hu – Program Manager @ Sync Framework Team

Key Takeaways:

  • Offline applications  have lots of benefits comparing to online applications especially for mobile devices and cloud services
  • Sync Framework, SQL Azure and Windows Azure provide a data platform that makes it very easy to build offline applications and sync services
  • Sync Framework caters for offline on any client platform, and provides better end-to-end support for Windows, Silverlight and Windows Phone 7 clients.

Why to Build Offline capable Apps?

  • Offline/Cached mode apps enjoy lots of value
    • Client apps get better UX through
      • Lower latency – data access doesn’t  require round-trips
      • Higher availability – App still runs if server is unreachable
    • Network utilization is reduced – most data access is local
    • Servers gain better ability to schedule work asynchronously
  • Benefits of cached mode are magnifies on the internet because
    • Server/service is further away
    • Network is less tuned/reliable
    • Lowers the need of scaling you app

Overview for Sync Framework v4

  • Capabilities where extended to other platforms like:
    • Windows
      • SQL Server Express
      • SQL Compact
    • Silverlight
      • Isolated Storage
      • Other Storage
    • Windows Phone 7
      • Isolated Storage
      • Other Storage
    • Windows Mobile
      • SQL Compact
    • Browser 7 / HTML5
      • HTML5 Stores
    • iPhone / Any Client
      • SQL lite
      • Other Stores
  • How was this achieved?
    • Using a single protocol for doing the communication and Synchronization. ODATA
  • What platforms have Client API support?
    • Windows
    • Silverlight
    • Windows Phone 7
  • All other platforms have minimal client & store requirements
    • Basically there are made available a set of samples to show how to implement those.
    • Over time there will be provided some tools to generate the code needed to integrate with you platform

Offline Applications Architecture

  • On the Server
    • ODATA Sync Framework
    • Sync Logic
    • SQL Azure Provider
    • Business Logic
      • This is the only part needed to be written for our application
    • SQL Azure

 

    • Steps to Build a Sync Service
      1. Provision the Database to use Sync Framework
        1. Launch the SyncSVCUtilHelper.exe
        2. Select the configuration file for the Synchronization
          1. Select the Name of the configuration file
          2. Provide the name of the database
          3. Create a Sync Scope
            • Define if we enable filtering or not
          4. Select the Tables/Columns/Rows that you want to define the scope
        3. Provision the Database
          1. Select the configuration file
          2. Next
        4. Code Generation
          1. Select the Configuration file
          2. Specify the Side that you want the file to be Generated (Server/Client)
          3. Specify the Output directory
          4. Select the Language (CS/VB)
      2. Create the Sync Service
        1. Open VS
        2. Create a new ASP.NET Project
        3. Add Reference to Microsoft.Syncronization.Service.dll
        4. Add the Code generated by the Tool?
    • Note: When you open the Service in the Browser if you add the $diag you’ll get a page with the diagnostics of the service, and see if everything needed is in place

 

    • Overview
      • Data Store
        • Expose data from SQL Azure or SQL Azure
      • Host
        • Hosted on Windows Azure or IIS/Windows Server
        • Exposed using WCF Sync endpoint
      • Protocol
        • Expose data for synchronization via a protocol and allows third-parties to build offline clients
      • Features
        • Support business logic
        • Custom authentication / authorization
        • Filtering
      • Tooling
        • Provide a Tooling wizard experience to configuring server and client

 

  • On the Client
    • Silverlight Offline Application
      • Only this is needed to be developed
    • Collections
    • Isolated Storage
    • Cache Controller
    • OData Sync Proxy
    • Isolated Storage Provider

 

    • Support for Silverlight 3 and 4

 

    • Steps to build a Sync Framework Client
      1. Create a new Silverlight Application
      2. Add Reference Microsoft.Synchronization.ClientService.dll
      3. Add Reference System.ComponentModel.DataAnotation.dll
      4. Add Reference System.Windows.Controls.Data.dll
      5. Open the Tool SVCSyncUtilHelper.exe
      6. Choose the previous Configuration file
      7. Select the Side you want to generate (Isolated Storage client)
      8. Select the Language (CS/VB)
      9. Add the Files generated to your application

 

  • On the Client for other Platforms
    • Track changes on the local storage (samples for common stores)
    • Implement the client-side sync proxy (samples for sync proxies)

 

  • Protocol
    • OData Protocol & Sync
      • Apply the principals of OData to the problem of data-sync
      • Standardize on protocol not components
      • Minimal client sync logic and algorithms
      • Service manages sync keeping client simple
      • Provide samples to how to consume protocol for any platform
      • Provide components for richer experience in Silverlight & Windows Phone 7
      • Full interop details defined in the SDK

Roadmap

  • Sync Framework 4.0 CTP is available now.
  • SQL Azure Data Sync CTP 1 its for the Cloud to Cloud Service
  • SQL Azure Data Sync CTP 2 will support On-premise to Cloud Sync
  • Sync Framework 4.0 RTW will be available on 2011

More resources

No Comments