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
-
Client apps get better UX through
-
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
-
Windows
-
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
-
Provision the Database to use Sync Framework
- Launch the SyncSVCUtilHelper.exe
-
Select the configuration file for the
Synchronization
- Select the Name of the configuration file
- Provide the name of the database
-
Create a Sync Scope
- Define if we enable filtering or not
- Select the Tables/Columns/Rows that you want to define the scope
-
Provision the Database
- Select the configuration file
- Next
-
Code Generation
- Select the Configuration file
- Specify the Side that you want the file to be Generated (Server/Client)
- Specify the Output directory
- Select the Language (CS/VB)
-
Create the Sync Service
- Open VS
- Create a new ASP.NET Project
- Add Reference to Microsoft.Syncronization.Service.dll
- Add the Code generated by the Tool?
-
Provision the Database to use Sync Framework
- 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
-
Data Store
-
On the Client
-
Silverlight Offline Application
- Only this is needed to be developed
- Collections
- Isolated Storage
- Cache Controller
- OData Sync Proxy
- Isolated Storage Provider
-
Silverlight Offline Application
- Support for Silverlight 3 and 4
-
Steps to build a Sync Framework Client
- Create a new Silverlight Application
- Add Reference Microsoft.Synchronization.ClientService.dll
- Add Reference System.ComponentModel.DataAnotation.dll
- Add Reference System.Windows.Controls.Data.dll
- Open the Tool SVCSyncUtilHelper.exe
- Choose the previous Configuration file
- Select the Side you want to generate (Isolated Storage client)
- Select the Language (CS/VB)
- 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
-
OData Protocol & Sync
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