66
Windows Azure Developing and deploying your first Cloud Service Eric Nelson Developer & Platform Group Microsoft Ltd [email protected] http://geekswithblogs.net/IUpdateable http://twitter.com/ericnel

Windows Azure Overview

Embed Size (px)

Citation preview

Page 1: Windows Azure Overview

Windows AzureDeveloping and deploying your first Cloud Service

Eric NelsonDeveloper & Platform GroupMicrosoft [email protected] http://geekswithblogs.net/IUpdateable http://twitter.com/ericnel

Page 2: Windows Azure Overview

The plan...

Cloud101Microsoft and CloudAzure Services Platform

Windows AzureOverviewMany vs “the one”Web RoleWorker Role

Storage in the CloudWindows Azure Storage + a little on SQL Data Services

Page 3: Windows Azure Overview

{ Simple Walkthough }

It is not that hard

demo

Page 4: Windows Azure Overview

Cloud?

Page 5: Windows Azure Overview

Cloud Computing 101

Cloud ComputingRun/Store stuff in the cloud -

Somebody else has the data center/headaches

Amazon.com key role in Cloud ComputingAmazon S3 (Simple Storage Service) – objectsAmazon EC2 (Elastic Compute Cloud) – virtual machines

WebServices and RESTful WebServices

Page 6: Windows Azure Overview

2008 and 2009 – exciting for Cloud Computing with MicrosoftSQL 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 RESTUsed by Windows AzureBeing explored by SQL Data Services

Azure Services Platform – announced at PDC 08 (October 2008)

Windows Azure “O.S. for the Cloud”SQL Services+ more

Page 7: Windows Azure Overview

Azure Services Platform

ServiceBus

AccessControl

Workflow

Database

Reporting

Analytics

Compute Storage Manage

Identity

Devices

Contacts

Your Applications

An internet-scale cloud services platform hosted in Microsoft data centers, which provides an operating system and a set

of developer services that can be used individually or together.

Page 8: Windows Azure Overview

Windows Azure

Page 9: Windows Azure Overview

It is an operating system for the cloudIt is designed for utility computingIt provides facilities to:

Write your apps (developer experience)Host your apps (compute)Manage your apps (service management)Store your data (storage)

What Is Windows Azure?

Page 10: Windows Azure Overview

Getting started 1/2

Pre-requisitesVista 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

Page 11: Windows Azure Overview

Getting started 2/2

Install the SDK SamplesDevelopment Fabric

Install the Visual Studio 2008 plug-inProject Templates

Run as AdminOptional

Get an account www.azure.com Enroll, wait, get invite(token), start deploying

Page 12: Windows Azure Overview

Three key design points

Many is better than oneLoose couplingSimple stores scale

Page 13: Windows Azure Overview

Big, reliable, expensiv

e machine

Page 14: Windows Azure Overview

Tech Preview offers one type of VMPlatform: 64-bit Windows Server 2008CPU: 1.5-1.7 GHz x64 equivalentMemory: 1.7 GBNetwork: 100 MbpsTransient local storage: 250 GB

Page 15: Windows Azure Overview

A A A B B C

F G G G G G

M N O O O P

D E E E

H I J K

Q R S T

E

L

U

Q Q Q

Page 16: Windows Azure Overview

A B

CD

Page 17: Windows Azure Overview

Load

Servers

Add some Web Servers

Buy bigger SQL Box

Rearchitect Database to

scale out

Buy more of everything

Unusedcapacity

Page 18: Windows Azure Overview
Page 19: Windows Azure Overview

Default.aspx(Take Order + Process

Order)

LB

Page 20: Windows Azure Overview

Tight coupling : Default.aspx.cs

public partial class _Default : System.Web.UI.Page    {                 protected void Button1_Click(object sender,EventArgs e)        {            var order = txtOrder.Text;            ProcessOrder(order);        }

protected void ProcessOrder(string order)        {  //Make some coffee!

...        }

     }

Page 21: Windows Azure Overview

Default.aspx(Take Order)

Windows Azure Queues

LB

Worker.cs(Process Order)

Page 22: Windows Azure Overview

Loose coupling : Default.aspx.cs

public partial class _Default : System.Web.UI.Page    {                 protected void Button1_Click(object sender,EventArgs e)        {            var order = txtOrder.Text;

            QueueStorage qStore = QueueStorage.Create(_account);

            MessageQueue orderQ = qStore.GetQueue("OrderQueue");

            orderQ.PutMessage(new Message(order));         }

     }

Page 23: Windows Azure Overview

Loose coupling : WorkerRole.cs

public class WorkerRole : RoleEntryPoint    {        public override void Start()        {

            QueueStorage qStore = QueueStorage.Create(_account);            MessageQueue orderQ = qStore.GetQueue("OrderQueue");            while (true)            {                Message msg = orderQ.GetMessage();

if( msg != null)                 ProcessOrder(msg.ContentAsString());            }        }               protected void ProcessOrder(string order)        {

//Make some coffee! ...

        }

Page 24: Windows Azure Overview

{Revisit, Instances and Workers}

demo

Page 25: Windows Azure Overview

Storage in the Cloud

Page 26: Windows Azure Overview

Azure Services Platform

ServiceBus

AccessControl

Workflow

Database

SQL Data Services

Reporting

Analytics

Compute Storage Manage

Identity

Devices

Contacts

Your Applications

23

Page 27: Windows Azure Overview

Windows Azure Datacenter

Your Service

Azure Application = WebRole + Worker Role + Storage

LB

Internet

Web Site(ASPX, ASMX,

WCF)

Web Site(ASPX, ASMX,

WCF)Web Role

(ASPX, WCF)

Worker Service

Worker Role

LB

StorageTables Blobs

Queue

SQ

L D

ata

Serv

ices

Page 28: Windows Azure Overview

Windows Azure and SDS

Azure Storage SQL Data Services

Vision

Access

Relational? (today)

Relational? (tomorrow)

Analogy

Page 29: Windows Azure Overview

Windows Azure and SDS

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? (tomorrow)

No

Analogy

Page 30: Windows Azure Overview

Windows Azure and SDS

Azure Storage SQL Data Services

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

SqlClient + TSQL(Use Azure Web Role + ADO.NET Data Services if REST is required)

Relational? (today)

No Yes – but with some limitations

Relational? (tomorrow)

No Yes – with less and less limitations

Analogy

Page 31: Windows Azure Overview

Windows Azure and SDS

Azure Storage SQL Data Services

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

SqlClient + TSQL(Use Azure Web Role + ADO.NET Data Services if REST is required)

Relational? (today)

No Yes – but with some limitations

Relational? (tomorrow)

No Yes – with less and less limitations

Analogy File System RDBMS – as it is

Page 32: Windows Azure Overview

Windows Azure Datacenter

Your Service

Azure Application = WebRole + Worker Role + Storage

LB

Internet

Web Site(ASPX, ASMX,

WCF)

Web Site(ASPX, ASMX,

WCF)Web Role

(ASPX, WCF)

Worker Service

Worker Role

LB

StorageTables Blobs

Queue

SQ

L D

ata

Serv

ices

Easy

Trickier

Page 33: Windows Azure Overview

Windows Azure Storage

Storage that isDurable, Scalable, Highly Available, Secure, Performant

Rich Data AbstractionsService communication: queues, locks, …Large user data items: blobs, blocks, …Service state: tables, caches, …

Simple and Familiar Programming Interfaces

REST Accessible and ADO.NET

Page 34: Windows Azure Overview

Account

Container Blobs

Table Entities

Queue Messages

Windows Azure Data Storage Concepts

http://<account>.blob.core.windows.net/<container>

http://<account>.table.core.windows.net/<table>

http://<account>.queue.core.windows.net/<queue>

Page 35: Windows Azure Overview

Windows Azure Tables

Massively Scalable TablesBillions of entities (rows) and TBs of dataAutomatically scales to thousands of servers as traffic grows

Highly AvailableCan always access your data

DurableData is replicated at least 3 times

Page 36: Windows Azure Overview

Tables - CapabilitiesWhat tables don’t do

Not relationalNo Referential Integrity

No JoinsLimited Queries

No Group byNo AggregationsNo TransactionsNo Transactions

What tables can do

CheapVery Scalable

FlexibleDurable

If these are important to you, use SQL Data Services Store LOTS of stuff

Page 37: Windows Azure Overview

Table Data Model

Data stored in TablesA Table is a set of Entities (rows)An Entity is a set of Properties (columns)

Entity has:PartitionKey – enables scalabilityRowKey – unique id within the partition

the only indexed property Timestamp – for optimistic concurrency255 properties totalMax size of 1MB

Page 38: Windows Azure Overview

Partition KeyDocument Name

Row KeyVersion

Property 3Modification Time

…..

Property NDescription

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 Example

Partition 1

Partition 2

Table Partition - all entities in table with same partition key value

Application controls granularity of partition

Page 39: Windows Azure Overview

Working with Tables

Vessel Position Reporting System – SQL Server

VesselId

xxx-xx1

Time

10:15 14 Nov

Latitude

01.23

Longitude

53.24

Speed

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 PosRptsorder by [Time] DESCwhere VesselId = ???

Page 40: Windows Azure Overview

Working with Tables

Solving this the Azure wayPartitionKey

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 01.23 51.23 1010:15 14 Nov

PartitionKey

VesselId

Page 41: Windows Azure Overview

Working with Tables

PartitionKey

RowKey Latitude Longitude Speed

xxx-xx1

10:15 14 Nov 01.23 53.24 0

10:05 14 Nov 04.45 54.32 5

09:55 14 Nov 02.32 52.34 4

RowKey needs to be a string

2521756430999999999

2521756436999999999

2521756442999999999

(DateTime.MaxValue – time).Ticks.ToString ()

Stored in-order:Just need to do a

top on the partition

time.Ticks.ToString ()

Makes it descending

Page 42: Windows Azure Overview

Programming Model

ADO.NET Data ServicesClient

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

Page 43: Windows Azure Overview

Example using ADO.NET Data Services Table Entities are represented as Class Objects

Example Table Definition

[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; }}

Page 44: Windows Azure Overview

Create Customers Table

Every Account has a master table called “Tables”It is used to keep track of the tables in your accountTo 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);

Page 45: Windows Azure Overview

Create And Insert Entity

Create a new Customer and Insert into TableCustomer 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);

Page 46: Windows Azure Overview

Query A Table

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’

REST

Page 47: Windows Azure Overview

Update And Delete Entity

context.DeleteObject(cust); DataServiceResponse response = context.SaveChanges();

cust.Occupation = “Musician”;context.UpdateObject(cust);DataServiceResponse response = context.SaveChanges();

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();

Page 48: Windows Azure Overview

Blob Storage

BlockBlobContainerAccount

Account

pictures

IMG001.JPG

IMG002.JPG

movies MOV1.AVI

Block 1

Block 2

Block 3

Page 49: Windows Azure Overview

Uploading a Blob Via Blocks

Uploading a large blob

10 GB Movie

Windows Azure Storage

Blo

ck I

d 1

Blo

ck I

d 2

Blo

ck I

d 3

Blo

ck I

d N

blobName = “TheBlob.wmv”;PutBlock(blobName, blockId1, block1Bits);PutBlock(blobName, blockId2, block2Bits);…………PutBlock(blobName, blockIdN, blockNBits);PutBlockList(blobName,

blockId1,…,blockIdN);

TheBlob.wmv

TheBlob.wmv

BenefitEfficient continuation and retryParallel and out of order upload of blocks

Page 50: Windows Azure Overview

New @ Mix: Full Trust

Applications are no longer restricted to run in medium trust

P/Invoke any native binaryUse more of the .NET stack, e.g. more of WCF

We support FastCGI, so you canAdd native handlers for languages to your appUse the fastCGI path from IIS to run your appe.g. PHP

Page 51: Windows Azure Overview

New @ Mix: Geo-location

Your “cloud project” consists of applications:

0 or more compute services0 or more storage accounts

Windows Azure is in multiple “locales”You can:

Choose a locale for any of your applicationsCreate an “affinity group” to co-locate a set of applications from your cloud project

Available thru developer portal in April

Page 52: Windows Azure Overview

Azure Services Platform Roadmap

First CTPDeveloper CTP for Services SDKs, and

Tools

Fall 2008 Spring 2009

Updated CTPsEnable Full trust & Fast CGI

Geo-location support.NET Services Open CTP

Live Framework Open CTPSDS Invitation-only CTP

Fall 2009

Commercial AvailabilityWindows Azure.NET ServicesSQL Services

Summer 2009

Pricing and SLA confirmationSDS Public CTP

Page 53: Windows Azure Overview

Windows Azure Summary

Many is better than oneLet Microsoft worry about this

Loose couplingWeb Role and Worker Role

Simple stores scaleTable, Blob, Queue

Page 54: Windows Azure Overview

What next?

•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•Watch the MIX 09 recordings http://live.visitmix.com

2009“Learn”

•Live applications running on Windows Azure•(There already are e.g. http://www.aws.net/services/cloud-services/case-study )

2010“Do”

Page 56: Windows Azure Overview

© 2008 Microsoft Ltd. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the

date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Page 57: Windows Azure Overview

 ServiceDefinition.csdef

<ServiceDefinition name="DemoService">  <WebRole name="WebRole">    <ConfigurationSettings>

      <Setting name="Color"/>

    </ConfigurationSettings>  </WebRole></ServiceDefinition>

ServiceConfiguration.cscfg

<ServiceConfiguration serviceName="DemoService">  <Role name="WebRole">    <ConfigurationSettings>

      <Setting name ="Color" value ="Red"/>

    </ConfigurationSettings>  </Role></ServiceConfiguration>

Configuration files           

Page 58: Windows Azure Overview

  <?xml version="1.0"?><ServiceConfiguration serviceName=“DemoService”>

  <Role name="WebRole">

    <Instances count="1"/>    <ConfigurationSettings>

      <Setting name ="LogLevel" value ="Verbose"/>

    </ConfigurationSettings>  </Role></ServiceConfiguration>

...

Configurable logging           

if (RoleManager.GetConfigurationSetting("LogLevel") == "Verbose")       RoleManager.WriteToLog("Information", "Some log message");

Page 59: Windows Azure Overview
Page 60: Windows Azure Overview
Page 61: Windows Azure Overview
Page 62: Windows Azure Overview
Page 63: Windows Azure Overview

.NET and ADO.NET Perf Tips

Default .NET HTTP connections is set to 2ServicePointManager.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, orUse DataServiceContext.ResolveType to return the type of the entity

Page 64: Windows Azure Overview

Table Tips

Be prepared for partial results from your queries

Check for the continuation tokenStoring different types of entities in same table

Have part of the RowKey represent the kind typeIn a single query can retrieve all of the related objects of different kindsWhen entity group transactions are supported

Can perform transactions across different typed entities in same partition

Page 65: Windows Azure Overview

Cloud Computing 101

SaaS = Software as a ServiceAka “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 etcS+S = Software + Services

Microsoft marketing department documenting reality

Powerful client software working with powerful cloud based servicesThink Xbox Live, Itunes, Skype, Messenger

Page 66: Windows Azure Overview

RESTful 101

users

eric

bill

sarah

tim

HTTP RequestURL

VERB

Payload

HTTP Response

Status

GET

POST

PUT

DELETEXML JSON

Payload

XML JSON

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/