listAllUsers() vs http://mysite.com/users/ ? addUser() vs POST http://mysite.com/users/ deleteUser() vs DELETE http://mysite.com/users/eric updateUser() vs PUT http://mysite.com/users/eric listUserComputers() vs http http://mysite.com/users/eric/computers/ users eric bill sarah tim HTTP Request URL VERB Payload HTTP Response Status GET POST PUT DELETE XML JSON Payload XML JSON
SQL Server Data Services (SSDS) – announced at MIX 08 (March 2008)
“ SQL Server in the cloud”
ADO.NET Data Services - part of .NET Framework 3.5 SP1(July 2008)
Not just about Cloud but all about REST
Used by Windows Azure
Being explored by SQL Data Services
Azure Services Platform – announced at PDC 08 (October 2008)
Azure Storage SDS Vision Highly scalable, highly available store in the Cloud Access Uses ADO.NET Data Services - REST Relational? (today) No Relational? (tomorrow) No Analogy
Azure Storage SDS Vision Highly scalable, highly available store in the Cloud Highly scalable, highly available relational store in the Cloud Access Uses ADO.NET Data Services - REST Uses custom WCF – REST or SOAP Relational? (today) No Yes – but with many limitations Relational? (tomorrow) No Yes – with less limitations Analogy
Azure Storage SDS Vision Highly scalable, highly available store in the Cloud Highly scalable, highly available relational store in the Cloud Access Uses ADO.NET Data Services - REST Uses custom WCF – REST or SOAP Relational? (today) No Yes – but with many limitations Relational? (tomorrow) No Yes – with less limitations Analogy File System RDBMS
MIX 09 in March is our next major conference
Expect announcements
Windows Azure will go live in 2009?
Will continue to have two storage solutions
Similar to why we have file system and databases
Pre-requisites
Vista or Server 2008
Visual Studio 2008 SP1 or VS Web Express Version
SQL Express 2005 or 2008 (if you already have a full version of SQL Server running, you must install Express as a new instance)
.NET 3.5 SP1
IIS 7 with ASP.NET and WCF HTTP activation enabled
Automatically scales to thousands of servers as traffic grows
Highly Available
Can always access your data
Durable
Data is replicated at least 3 times
Table
A Storage Account can create many tables
Table name is scoped by Account
Data is stored in Tables
A Table is a set of Entities (rows)
An Entity is a set of Properties (columns)
Entity
Two “key” properties that together are the unique ID of the entity in the Table
PartitionKey – enables scalability
RowKey – uniquely identifies the entity within the partition
Partition Key Document Name Row Key Version Property 3 Modification Time … .. Property N Description Examples Doc V1.0 8/2/2007 … .. Committed version Examples Doc V2.0.1 9/28/2007 Alice’s working version FAQ Doc V1.0 5/2/2007 Committed version FAQ Doc V1.0.1 7/6/2007 Alice’s working version FAQ Doc V1.0.2 8/1/2007 Sally’s working version Partition 1 Partition 2
ADO.NET Data Services Client REST Interface .NET Framework 3.5 SP1 Use any HTTP stack Data represented as .NET objects Data represented in Atom (XML) DataServiceContext methods for updates HTTP verbs for updates LINQ to define queries URLs to define queries
Example using ADO.NET Data Services
Table Entities are represented as Class Objects
[ DataServiceKey ( "PartitionKey" , "RowKey" )] public class Customer { // Partition key – Customer Last name public string PartitionKey { get ; set ; } // Row Key – Customer First name public string RowKey { get ; set ; } // User defined properties here public DateTime CustomerSince { get ; set ; } public double Rating { get ; set ; } public string Occupation { get ; set ; } }
Every Account has a master table called “Tables”
It is used to keep track of the tables in your account
To use a table it has to be inserted into “Tables”
[ DataServiceKey ( "TableName" )] public class TableStorageTable { public string TableName { get ; set ; } } TableStorageTable table = new TableStorageTable ( "Customers" ) ; context.AddObject ( "Tables" , table); DataServiceResponse response = context.SaveChanges(); // serviceUri is “http://<Account>.table.core.windows.net/” DataServiceContext context = new DataServiceContext (serviceUri);
Create a new Customer and Insert into Table
Customer cust = new Customer ( “ Lee” , // Partition Key = Last Name “ Geddy” , // Row Key = First Name DateTime .UtcNow, // Customer Since 2.0, // Rating “ Engineer” // Occupation ); context.AddObject( “Customers” , cust); DataServiceResponse response = context.SaveChanges(); // Service Uri is “http://<Account>.table.core.windows.net/” DataServiceContext context = new DataServiceContext (serviceUri);
LINQ
// Service Uri is “http://<Account>.table.core.windows.net/” DataServiceContext context = new DataServiceContext (serviceUri); var customers = from o in context.CreateQuery< Customer >( “Customers” ) where o.PartitionKey == “Lee” select o; foreach ( Customer customer in customers) { } GET http://<Account>.table.core.windows.net/Customers? $filter= PartitionKey eq ‘Lee’
Customer cust = ( from c in context.CreateQuery< Customer > ( “Customers” ) where c. PartitionKey == “Lee” // Partition Key = Last Name && c. RowKey == “Geddy” // Row Key = First Name select c) .FirstOrDefault(); context.DeleteObject(cust); DataServiceResponse response = context.SaveChanges(); cust.Occupation = “Musician” ; context.UpdateObject(cust); DataServiceResponse response = context.SaveChanges();
0 comments
Post a comment