640 likes | 856 Views
Windows Azure and SQL Data Services. Eric Nelson Developer & Platform Group Microsoft Ltd eric.nelson@microsoft.com http://geekswithblogs.net/IUpdateable http://twitter.com/ericnel. SQL Data Services. Eric Nelson Developer & Platform Group Microsoft Ltd eric.nelson@microsoft.com
E N D
Windows Azure andSQL Data Services Eric Nelson Developer & Platform Group Microsoft Ltd eric.nelson@microsoft.com http://geekswithblogs.net/IUpdateable http://twitter.com/ericnel
SQL Data Services Eric Nelson Developer & Platform Group Microsoft Ltd eric.nelson@microsoft.com http://geekswithblogs.net/IUpdateable http://twitter.com/ericnel
Windows Azure andSQL Data Services Eric Nelson Developer & Platform Group Microsoft Ltd eric.nelson@microsoft.com http://geekswithblogs.net/IUpdateable http://twitter.com/ericnel
Windows Azure and a little SQL Data Services Eric Nelson Developer & Platform Group Microsoft Ltd eric.nelson@microsoft.com http://geekswithblogs.net/IUpdateable http://twitter.com/ericnel
The new plan... • Cloud • 101 • Microsoft and Cloud • Azure Services Platform • Storage in the Cloud • Windows Azure Storage + SQL Data Services • Windows Azure • Overview • Focus on storage • SQL Data Services • Futures
{ Simple Walkthough} demo It is not that hard
Cloud Computing 101 • SaaS = Software as a Service • Aka “On Demand” vs “On Premise” software • Many customers hate “On Premise” hassle • Independent Software Vendors (ISVs) explored • SalesForce.com championed this model – “No Software” • Single tenant vs Multi tenant etc • S+S = Software + Services • Microsoft marketing department documenting reality • Powerful client software working with powerful cloud based services • Think Xbox Live, Itunes, Skype, Messenger • SalesForce.com really do this... • Cloud Computing • Run/Store stuff in the cloud - • Somebody else has the data center • Amazon.com key role in Cloud Computing • Amazon S3 (Simple Storage Service) – objects • Amazon EC2 (Elastic Compute Cloud) – virtual machines • WebServices and RESTfulWebServices
RESTful 101 listAllUsers() vshttp://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/eric/computers/ users HTTP Request eric URL GET bill VERB POST Payload PUT sarah JSON JSON XML XML DELETE tim HTTP Response Status Payload
2008 and 2009 – exciting for Cloud Computing with Microsoft • 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) • Windows Azure “O.S. for the Cloud” • SQL Services • + more
Azure Services Platform Azure™ Services Platform
Azure Services Platform • Azure Services Platform – marketing name • Brings together many products from many teams • Windows Azure – Operating System • Compute • Storage • SQL Services • SQL Data Services (SDS) • Formally SSDS • SQL Labs – more on that later • .NET Services – Enterprise focus • Access Control • Service Bus • Workflow Service • Live Services – Consumer focus • Live Mesh,...
Azure Services Platform • Azure Services Platform – marketing name • Brings together many products from many teams • Windows Azure – Operating System • Compute • Storage • SQL Services • SQL Data Services (SDS) • Formally SSDS • SQL Labs – more on that later • .NET Services – Enterprise focus • Access Control • Service Bus • Workflow Service • Live Services – Consumer focus • Live Mesh,... 2 3
The future of storage in the Cloud • 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
Getting started 1/2 • 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 • http://www.programmerfish.com/how-to-create-and-deploy-a-simple-hello-world-application-on-windows-azure
Getting started 2/2 • Install the SDK • Samples • Development Fabric • Install the Visual Studio 2008 plug-in • Project Templates • Run as Admin • Optional • Get an account www.azure.com • Enroll, wait, get invite(token), start deploying
Three key design points • Many is better than one • Loose coupling • Simple stores scale
A A A B B C D E E E E F G G G G G H I J K L M N O O O P Q R S T U Q Q Q
A B D C
Tight coupling : Default.aspx.cs • publicpartialclass_Default : System.Web.UI.Page • { • protectedvoid Button1_Click(objectsender,EventArgs e) • { • var order = txtOrder.Text; • ProcessOrder(order); • } • protectedvoidProcessOrder(string order) • { • //Make some coffee! ... • } • }
Web Role Worker Role LB Default.aspx(Take Order) Worker.cs(Process Order) Windows Azure Queues
Loose coupling : Default.aspx.cs • publicpartialclass_Default : System.Web.UI.Page • { • protectedvoid Button1_Click(objectsender,EventArgs e) • { • var order = txtOrder.Text; • QueueStorageqStore = QueueStorage.Create(_account); • MessageQueueorderQ = qStore.GetQueue("OrderQueue"); • orderQ.PutMessage(newMessage(order)); • } • }
Loose coupling : WorkerRole.cs • public class WorkerRole : RoleEntryPoint • { • public override void Start() • { • QueueStorageqStore = QueueStorage.Create(_account); • MessageQueueorderQ = qStore.GetQueue("OrderQueue"); • while (true) • { • Message msg=orderQ.GetMessage(); • if( msg != null) • ProcessOrder(msg.ContentAsString()); • } • } • protected void ProcessOrder(string order) • { • //Make some coffee! ... • }
Azure Application = WebRole + Worker Role + Storage n m Worker Role Web Role LB SQL Data Services Azure Storage (blob, table, queue)
Windows Azure Storage • Storage that is • Durable, Scalable, Highly Available, Secure, Performant • Rich Data Abstractions • Service communication: queues, locks, … • Large user data items: blobs, blocks, … • Service state: tables, caches, … • Simple and Familiar Programming Interfaces • REST Accessible and ADO.NET
Windows Azure Data Storage Concepts Container Blobs Account • Table Entities http://<account>.blob.core.windows.net/<container> Queue Messages http://<account>.table.core.windows.net/<table> http://<account>.queue.core.windows.net/<queue>
Windows Azure Tables • Massively Scalable Tables • Billions of entities (rows) and TBs of data • 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 Data Model • 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 Example Partition 1 Partition 2 • Table Partition - all entities in table with same partition key value • Application controls granularity of partition
Example Table Definition • 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 DateTimeCustomerSince { get; set; } public double Rating{ get; set; } public string Occupation { get; set; } }
Create Customers Table • 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; } } // serviceUri is “http://<Account>.table.core.windows.net/” DataServiceContextcontext = new DataServiceContext(serviceUri); TableStorageTabletable = new TableStorageTable("Customers"); context.AddObject("Tables", table); DataServiceResponseresponse = context.SaveChanges();
Create And Insert Entity • Create a new Customer and Insert into Table • Customer cust =new Customer( • “Lee”, // Partition Key = Last Name • “Geddy”, // Row Key = First NameDateTime.UtcNow, // Customer Since • 2.0, // Rating • “Engineer”// Occupation); // Service Uri is “http://<Account>.table.core.windows.net/” DataServiceContextcontext = new DataServiceContext(serviceUri); context.AddObject(“Customers”, cust); DataServiceResponseresponse = context.SaveChanges();
Query A Table • LINQ // Service Uri is “http://<Account>.table.core.windows.net/” DataServiceContextcontext = new DataServiceContext(serviceUri); varcustomers = from o in context.CreateQuery<Customer>(“Customers”) where o.PartitionKey == “Lee” select o; foreach(Customer customerin customers) { } • REST GET http://<Account>.table.core.windows.net/Customers? $filter= PartitionKeyeq ‘Lee’