1. Eric Nelson
Developer & Platform Group
Microsoft Ltd
eric.nelson@microsoft.com
http://geekswithblogs.net/IUpdateable
http://twitter.com/ericnel
2. Cloud
101
Microsoft and Cloud
Azure Services Platform
Windows Azure
Overview
Many vs “the one”
Web Role
Worker Role
Storage in the Cloud
Windows Azure Storage + a little on SQL Data Services
5. Cloud Computing
Run/Store stuff in the cloud -
Somebody else has the data center/headaches
Amazon.com key role in Cloud Computing
Amazon S3 (Simple Storage Service) – objects
Amazon EC2 (Elastic Compute Cloud) – virtual machines
WebServices and RESTful WebServices
6. 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
7.
8.
9. It is an operating system for the cloud
It is designed for utility computing
It provides facilities to:
Write your apps (developer experience)
Host your apps (compute)
Manage your apps (service management)
Store your data (storage)
10. 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
11. 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
12. Many is better than one
Loose coupling
Simple stores scale
14. Tech Preview offers one type of VM
Platform: 64-bit Windows Server 2008
CPU: 1.5-1.7 GHz x64 equivalent
Memory: 1.7 GB
Network: 100 Mbps
Transient local storage: 250 GB
15. 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
27. Web Site
Web Site
Web Role
(ASPX, ASMX,
(ASPX, ASMX,
WCF)
(ASPX, WCF)
WCF)
SQL Data Services
L
B
Worker
Worker
Service
Role
Internet
Your Service
Queue
L
B
Blobs
Tables
Storage
Windows Azure Datacenter
29. Azure Storage SQL Data Services
Vision Highly scalable,
highly available
store in the Cloud
Access Uses ADO.NET
Data Services -
REST
Relational? (today) No
Relational? No
(tomorrow)
Analogy
30. Azure Storage SQL Data Services
Vision Highly scalable, Highly scalable,
highly available highly available
store in the Cloud relational store in
the Cloud
Access Uses ADO.NET SqlClient + TSQL
(Use Azure Web Role + ADO.NET
Data Services - Data Services if REST is required)
REST
Yes – but with some
Relational? (today) No
limitations
Yes – with less and
Relational? No
(tomorrow) less limitations
Analogy
31. Azure Storage SQL Data Services
Vision Highly scalable, Highly scalable,
highly available highly available
store in the Cloud relational store in
the Cloud
Access Uses ADO.NET SqlClient + TSQL
(Use Azure Web Role + ADO.NET
Data Services - Data Services if REST is required)
REST
Yes – but with some
Relational? (today) No
limitations
Yes – with less and
Relational? No
(tomorrow) less limitations
RDBMS – as it is
Analogy File System
32. Web Site
Web Site
Web Role
(ASPX, ASMX,
(ASPX, ASMX,
WCF)
(ASPX, WCF)
WCF)
SQL Data Services
L
Easy
B
Worker
Worker
Service
Role
Internet
Your Service
Queue
L
Trickier
B
Blobs
Tables
Storage
Windows Azure Datacenter
33. 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
35. 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
36. What tables don’t do What tables can do
Not relational Cheap
No Referential Integrity Very Scalable
If theseNo Joins Flexible
are
importantData
Limitedto you,
Queries Durable
use SQL
ServicesGroup by Store LOTS of stuff
No
No Aggregations
No Transactions
No Transactions
37. Data stored in Tables
A Table is a set of Entities (rows)
An Entity is a set of Properties (columns)
Entity has:
PartitionKey – enables scalability
RowKey – unique id within the partition
the only indexed property
Timestamp – for optimistic concurrency
255 properties total
Max size of 1MB
38. …..
Partition Key Row Key Property 3 Property N
Document Version Modification Description
Name Time
…..
Examples Doc V1.0 8/2/2007 Committed version
Partition
Alice’s working version
Examples Doc V2.0.1 9/28/2007 1
FAQ Doc V1.0 5/2/2007 Committed version
Alice’s working version Partition
FAQ Doc V1.0.1 7/6/2007
2
Sally’s working version
FAQ Doc V1.0.2 8/1/2007
39. Vessel Position Reporting System – SQL Server
VesselId Time Latitude Longitude Speed
xxx-xx1 10:15 14 Nov 01.23 53.24 0
xxx-xx1 10:05 14 Nov 04.45 54.32 5
xxx-xx1 09:55 14 Nov 02.32 52.34 4
xxx-xx2 10:15 14 Nov 01.23 51.23 10
To find last pos report for vessel in SQL:
select TOP(1) * from PosRpts
order by [Time] DESC
where VesselId = ???
40. Solving this the Azure way
PartitionKey
VesselId Time Latitude Longitude Speed
xxx-xx1 10:15 14 Nov 01.23 53.24 0
xxx-xx1 10:05 14 Nov 04.45 54.32 5
xxx-xx1 09:55 14 Nov 02.32 52.34 4
xxx-xx2 10:15 14 Nov 01.23 51.23 10
PartitionKey
41. Stored in-order:
RowKey needs to
Just need to do a
be a string
top on the
partition PartitionKey xxx-xx1
RowKey Latitude Longitude Speed
10:15 14 Nov 01.23 53.24 0
2521756430999999999
10:05 14 Nov 04.45 54.32 5
2521756436999999999
Makes it 14 Nov
09:55 02.32 52.34 4
2521756442999999999
descending
(DateTime.MaxValue – time).Ticks.ToString ()
time.Ticks.ToString ()
42. ADO.NET Data Services REST Interface
Client
.NET Framework 3.5 SP1 Use any HTTP stack
Data represented Data represented in Atom
as .NET objects (XML)
DataServiceContext HTTP verbs for updates
methods for updates
LINQ to define queries URLs to define queries
43. Example using ADO.NET Data Services
Table Entities are represented as Class Objects
[DataServiceKey(quot;PartitionKeyquot;, quot;RowKeyquot;)]
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; }
}
44. 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(quot;TableNamequot;)]
public class TableStorageTable
{
public string TableName { get; set; }
}
// serviceUri is ‚http://<Account>.table.core.windows.net/‛
DataServiceContext context = new DataServiceContext(serviceUri);
TableStorageTable table = new TableStorageTable(quot;Customersquot;);
context.AddObject(quot;Tablesquot;, table);
DataServiceResponse response = context.SaveChanges();
45. 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);
// Service Uri is ‚http://<Account>.table.core.windows.net/‛
DataServiceContext context = new DataServiceContext(serviceUri);
context.AddObject(‚Customers‛, cust);
DataServiceResponse response = context.SaveChanges();
46. 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’
47. 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();
cust.Occupation = ‚Musician‛;
context.UpdateObject(cust);
DataServiceResponse response = context.SaveChanges();
context.DeleteObject(cust);
DataServiceResponse response = context.SaveChanges();
49. Uploading a large blob
blobName = “TheBlob.wmv”;
10 GB Movie
PutBlock(blobName, blockId1, block1Bits);
Block Id 2
Block Id N
Block Id 1
Block Id 3
PutBlock(blobName, blockId2, block2Bits);
…………
PutBlock(blobName, blockIdN, blockNBits);
PutBlockList(blobName,
blockId1,…,blockIdN);
TheBlob.wmv Windows Azure
Storage
50. Applications are no longer restricted to run
in medium trust
P/Invoke any native binary
Use more of the .NET stack, e.g. more of WCF
We support FastCGI, so you can
Add native handlers for languages to your app
Use the fastCGI path from IIS to run your app
e.g. PHP
51. Your “cloud project” consists of applications:
0 or more compute services
0 or more storage accounts
Windows Azure is in multiple “locales”
You can:
Choose a locale for any of your applications
Create an “affinity group” to co-locate a set of
applications from your cloud project
Available thru developer portal in April
52. Developer CTP for Enable Full trust & Fast CGI
Geo-location support
Services SDKs, and SDS Public CTP Windows Azure
.NET Services Open CTP
Tools .NET Services
Live Framework Open CTP SQL Services
SDS Invitation-only CTP
53. Many is better than one
Let Microsoft worry about this
Loose coupling
Web Role and Worker Role
Simple stores scale
Table, Blob, Queue
54. 2009 • Play with Windows Azure – http://www.azure.com
• Invest time in ADO.NET Data Services (3.5 SP1)
• Invest time in LINQ
• Understand REST – good and bad practices
“Learn” • Watch the MIX 09 recordings
http://live.visitmix.com
2010 • Live applications running on Windows Azure
• (There already are e.g.
http://www.aws.net/services/cloud-services/case-
“Do” study )
58. <?xml version=quot;1.0quot;?>
<ServiceConfiguration serviceName=‚DemoService‛>
<Role name=quot;WebRolequot;>
<Instances count=quot;1quot;/>
<ConfigurationSettings>
<Setting name =quot;LogLevelquot; value =quot;Verbosequot;/>
</ConfigurationSettings>
</Role>
</ServiceConfiguration>
...
if (RoleManager.GetConfigurationSetting(quot;LogLevelquot;) == quot;Verbosequot;)
RoleManager.WriteToLog(quot;Informationquot;, quot;Some log messagequot;);
59.
60.
61.
62.
63. Default .NET HTTP connections is set to 2
ServicePointManager.DefaultConnectionLimit = X;
Turn off 100-continue (saves one round trip)
ServicePointManager.Expect100Continue = false;
Turn tracking off for query results that are
not going to be modified
MergeOption = MergeOption.NoTracking
To improve performance of ADO.NET
de-serialization
Name the entity class the same
as the table name, or
Use DataServiceContext.ResolveType to return
the type of the entity
64. Be prepared for partial results
from your queries
Check for the continuation token
Storing different types of entities in same
table
Have part of the RowKey represent the kind
type
In a single query can retrieve all of the related
objects of different kinds
When entity group transactions are supported
Can perform transactions across different typed
entities in same partition
65. 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
66. 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
HTTP Request
eric
URL
VERB bill
GET
Payload POST sarah
PUT
tim
XML DELETE
JSON
HTTP Response
Status
Payload
XML JSON