Windows Azure programming patterns for Start-ups - Riccardo Becker - E-Book

Windows Azure programming patterns for Start-ups E-Book

Riccardo Becker

0,0
34,79 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Leverage different Windows Azure components together with your existing Microsoft .NET skills to fully take advantage of the power of Windows Azure. Use this book to start small and end big by creating and using storage, cloud services, sql databases, networking, caching and other innovative technology to realize your first top-class Windows Azure service!
"Windows Azure for Start-ups" is an incremental guide that will take you from the essentials of the Windows Azure platform up to the realization of your own cloud services running on the platform. You will learn how to apply different technologies of the Windows Azure platform with the help of examples all focusing on one single fictitious start-up scenario.
This book is centred around a fictitious company called Geotopia that wants to build a brand new social network by using the Windows Azure platform. It will take the reader from the theory and rationale behind Windows Azure right to building services and coding C#.
The books starts by outlining the concepts of Windows Azure. It then demonstrates how to set up a development environment and how to build your application by using different storage mechanisms, applying different features from the Windows Azure platform and ending with the newest features explained from the latest release.
Windows Azure for Startups will help you take full advantage of the Windows Azure platform and bring your new service online as quickly as possible.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 333

Veröffentlichungsjahr: 2012

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Windows Azure Programming Patterns for Start-ups
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Instant Updates on New Packt Books
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Errata
Piracy
Questions
1. The Concepts of Windows Azure
Red Dog
Windows Azure announcement
A quick start on Windows Azure
How it works internally
First steps
Creating and deploying a website on Windows Azure
First deployment
Upgrade domains
Fault domains
Fabric Controller
Internals of a node
Deployment steps
Core components of Windows Azure
Compute
Web roles
Worker roles
Virtual machine roles
Database
SQL Database
Data Sync
Storage
Binary Large Object
Table Storage
Queue
Windows Azure drive
Business analytics
Service Bus
Content delivery network
Caching
Virtual network
Windows Azure Connect
Windows Azure Traffic Manager
Windows Azure Active Directory
Marketplace
Summary
2. A Startup Scenario
Introduction
BizSpark
Program roles
Enrolling into the program
Geotopia's goals
Geotopia prototype
TFS in the cloud
Connecting to TFS Preview
Querying Tasks
Summary
3. Create Your Solution
Solution structure
Organizing a solution in VS 2010
Compute and storage emulators
Bing Maps
Adding Silverlight to cloud
Embedding Bing Maps
Setting up TFS preview
Connecting with TFS Preview
Publishing to Windows Azure
Summary
4. Storing Your Data
Storage
What is Windows Azure storage?
Blobs
Table storage
Queues
Inside storage
Storage architecture
Storage availability
Fault domains
Upgrade domains
Replication
Partitioning
Storage metrics
Table storage usage
A closer look at tables
Choose the right key
Keys for scaling
Keys for transactions
Geotopia data model
Adding an entity
Querying
Continuation tokens
Best practices
Table storage summary
Queue usage
A closer look at the queue
Creating a queue
Inserting a message
Retrieving a message
Queue operations
Idempotency
Using blobs
File transfer
Uploading a file
Downloading the file
Storage best practices
Use exponential backoff
Summary
5. SQL Database
Overview
Setting up SQL databases
Guidelines
Best practices
Encryption and security
Encryption demo
Data Sync
Supported datatypes in Data Sync
Securing Data Sync
Authentication
Setting up a Data Sync environment
Summary
6. Key Features Explained
Service Bus
Getting started
Queues
Working with queues
A sample scenario
Preparing the project
Sending messages
Receiving messages
Cross-domain communication
Comparison
Background information
Topics and subscriptions
Preparing the project
Using filters
Windows Azure Caching
Caching capabilities
Setting it up
Caching examples
Adding items to the cache
Session state and output caching
Windows Azure Connect
Setting it up
Enabling a web role with Connect
Managing Connect
Testing connectivity
Other Connect capabilities
Access Control Service
Getting started
Adding an identity provider
Adding a relying party
Application integration
Integrating with Facebook
Using FederatedAuthentication
Displaying information about me
Traffic Manager
Setting it up
Round robin
Performance
Failover
Testing the policies
Failover scenario
Summary
7. The Billing Aspects of Windows Azure
Basic billing details
Compute
Windows Azure SQL databases
Storage
Bandwidth
Content delivery network
Cache
Service Bus
Access Control Service
Pricing
Calculator
Purchase options
Member offers
MSDN subscribers
MPN members
Cloud Essentials
Cloud Accelerate
BizSpark members
How much we use
Bandwidth
What is counted as a transaction
How to reduce the number of transactions
When are transactions billed
Estimate capacity
Implementing your own billing tracker
Enabling analytics
Request logging
Example transactions
Blob capacity
Summary
8. Windows Azure Patterns
Enterprise Library for Windows Azure
EntLib and Azure compatibility
EntLib Integration Pack
Autoscaling
Transient fault handling
Blob configuration
PowerShell Cmdlets
Protected configuration provider
Windows Azure autoscaling
Growth model
Applying WASABi
Key concepts of WASABi
Configure autoscaling
Worker host
Setting rules
Constraint rules
Reactive rules
Throttling
Service information store
Metronome
Data collection
Data points store
Rule evaluation
Conflicting rules
The scaler
The tracker
The stabilizer
Customizing WASABi
Blob configuration
PowerShell cmdlets
Transient fault handling
The Transient Fault Handling Application Block
Applying transient fault handling
The Gatekeeper pattern
The KeyMaster
Summary
9. Application Lifecycle Management
ALM overview
Governance
Development
Operations
ALM tooling
Planning and tracking
Writing, unit testing, debugging, analyzing, and profiling
Build
Defining a Build
Queue build
Review build
Application Lifecycle Management on Windows Azure
Step 1: Team development
Step 2: Build, Unit test, Deploy, UItest flow, and manual test
Step 3: Release drop
Step 4: Operations
Summary
10. Windows Azure Security
Security development lifecycle
Security roles
Security maturity
Security activities
Training
Requirements
Design
Implementation
Verification
Release
SDL in Windows Azure
Requirements
Design
Implementation
Verification
Release
Microsoft Global Foundation Services
Certifications
Privacy
Platform security
Adding more security
Summary
11. What's New in Windows Azure
Overview
Virtual machines
Creating a virtual machine
Connecting to the VM
Setting up a VHD
Virtual network
Creating a virtual network
Management portal
Media services
Setting it up
Using media services
An example displaying the use of media services
Uploading
Converting
Iterating
Downloading
Summary
Index

Windows Azure Programming Patterns for Start-ups

Windows Azure Programming Patterns for Start-ups

Copyright © 2012 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: October 2012

Production Reference: 1161012

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-84968-560-3

www.packtpub.com

Cover Image by Sandeep Babu (<[email protected]>)

Credits

Author

Riccardo Becker

Reviewers

Michael Collier

Neil Mackenzie

Acquisition Editor

Dilip Venkatesh

Lead Technical Editor

Unnati Shah

Technical Editors

Devdutt Kulkarni

Arun Nadar

Rohit Rajgor

Azharuddin Sheikh

Copy Editor

Brandt D'Mello

Project Coordinator

Sai Gamare

Anugya Khurana

Proofreader

Maria Gould

Indexer

Rekha Nair

Graphics

Valentina D'Silva

Production Coordinator

Nitesh Thakur

Cover Work

Nitesh Thakur

About the Author

Riccardo Becker works full-time as a Principal IT Architect for Logica, in the Netherlands. He holds several certifications, and his background in computing goes way back to 1998, when he started working with good old' Visual Basic 5.0 (or was it 6.0?). Ever since, he fulfilled several roles, such as Developer, Lead Developer, Architect, Project Leader, Practice Manager, and recently, he decided to accept the role of Principal IT Architect, in which he focuses on innovation, cutting-edge technology, and specifically on Windows Azure and cloud computing in general.

In 2007, he joined the Microsoft LEAP program, where he got a peek at the move Microsoft was about to make on their road to the cloud. Pat Helland gave him that insight, and since the first release of Windows Azure on PDC 2008, he started to focus on it, keeping track of the progress and the maturity of the platform. In the past few years, he has also done a lot of work on incubation with his employer, raising awareness on cloud computing in general and Windows Azure.

I would like to thank all my colleagues who were counterparts with me on various subjects in the world of Azure. Special thanks to my dear colleague and friend, Raymond Binnendijk en Rémon ter 
Haar, who helped me out throughout the whole project.



I also would like to thank the folks from Packt Publishing, especially Sai Gamare, who helped me keep on track and on schedule, despite some obstacles and some changes that I made to the original outline.



Special thanks to my employer Logica for all the opportunities that have helped me in realizing this book. It is thanks to the daily job and to getting the opportunity to focus on these subjects that I have come to this point of having enough substance to write this book.

About the Reviewers

Michael Collier is a Windows Azure MVP and serves as a National Architect for a Microsoft SI partner that specializes in Windows Azure. He has nearly 11 years of experience building Microsoft-based applications for a wide range of clients. Michael spends his days serving as a developer or architect, helping clients succeed with the Microsoft development platform. He also enjoys speaking about Windows Azure at local user groups as well as at regional and national conferences. Michael is also the founder of CloudDevelop as well as of the Central Ohio Cloud Computing User Group in Columbus, OH. You can follow Michael on Twitter at www.twitter.com/MichaelCollier and on his blog at www.MichaelSCollier.com.

Neil Mackenzie has been kicking the tires of Windows Azure since PDC 2008. He works for Satory Global, helping companies use the Windows Azure platform. Neil wrote the Microsoft Windows Azure Development Cookbook for Packt Publishing. He is a Microsoft MVP for Windows Azure. Neil tweets occasionally on @mknz.

www.PacktPub.com

Support files, eBooks, discount offers and more

You might want to visit www.PacktPub.com for support files and downloads related to your book.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

http://PacktLib.PacktPub.com

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. 

Why Subscribe?

Fully searchable across every book published by PacktCopy and paste, print and bookmark contentOn demand and accessible via web browser

Free Access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.

Instant Updates on New Packt Books

Get notified! Find out when new books are published by following @PacktEnterprise on Twitter, or the Packt Enterprise Facebook page.

Preface

Windows Azure was officially announced at PDC 2008, but looking back, I had a quick look in the kitchen of Windows Azure in 2007 while I was visiting Redmond during the Lead Enterprise Architect Program (LEAP) sessions. Pat Helland, a senior architect at Microsoft, gave a talk on The irresistible forces meet the movable objects.

Pat described the nature of the forces where he pitted big servers and fast CPUs against commodity hardware (ordinary machines you can buy everywhere). Moore's Law, (The number of transistors on circuits doubles every year) is applicable to many hardware components. Though still accurate, it is getting more and more expensive to double CPU speed. Increasing CPU speed is still possible, but at a price. The costs for scaling out a single server are generally higher than scaling up to multiple processors or servers. If we look solely at the speed of the CPU, we can conclude that the growth is flattening. Parallel computing is cheaper than scaling out single servers.

Looking back at the history of Windows Azure, Pat Helland actually stated that there should be something like low-cost, highly-available, high-bandwidth, high-storage, and high computing power-based datacenters, all around the world, that can run both existing and new applications.

Guess what? The concept envisioned was officially announced at PDC 2008! Windows Azure was born, and this very first release of the platform actually contained everything that was envisioned during this talk on LEAP 2007. Lots of cheap hardware runs in datacenters all around the globe that offer massive computing power, storage, and bandwidth. All these components are available like electricity; you start paying from the moment you start using it. Operational expenses (OpEx) instead of capital expenses (CapEx) enable you to experiment more easily, since you do not need to buy hardware but just take it from Windows Azure. When your experiment is successful and you need more computing power or storage to serve all your customers, you can easily scale up.

This book elaborates on different features from the Windows Azure platform. The central theme of the book is a fictitious company, Geotopia. This company decided to build its own social network by leveraging the abilities of the Windows Azure platform.

What this book covers

Chapter 1, The Concepts of Windows Azure, introduces Windows Azure, the cloud offering from Microsoft. It describes the author's first contact with the"cloud" in general and how Microsoft decided to put a great amount of effort into realizing Windows Azure.

Chapter 2, A Startup Scenario, shows how a brand new, ambitious company just opened its doors. Geotopia consists of enthusiastic developers and architects who jointly created a new view on social networking. It is not a basic user interface where plain text dominates but a compelling map interface, offering users the ability to treat it as their social canvas and drop video and images, and create messages based on their location or on the location of their interest. Users can recommend locations, shops, or other points of interest by adding comments or multimedia and tell their friends about it. This chapter describes the requirements for Geotopia.

Chapter3, Create Your Solution, teaches us how to create an organized Windows Azure solution with Visual Studio 2010. Both a web and a worker role are created together, with a Silverlight client acting as the Geotopia canvas, based on Bing Maps technology. We will also learn to run cloud projects locally on our own machine and debug them. As the last step, the initial solution is actually deployed to Windows Azure.

Chapter4, Storing Your Data, is a deep dive into the storage fundamentals of Windows Azure. It outlines the architecture of Windows Azure Storage and its underlying architecture. You will also learn how to operate the different Storage offerings, such as blobs, queues, and tables.

Chapter5, SQL Database, digs deeper into the scalable cloud database service that Microsoft offers and is a part of the Windows Azure platform. The chapter shows how to set up a SQL database and outlines best practices and guidelines. You will also learn how to fully leverage the power of Data Sync.

Chapter6, Key Features Explained, outlines different features from the platform (previously known as AppFabric). You will learn how to make use of Service Bus and how to enable messaging between your applications. Also, key features such as Caching, Windows Azure Connect, Access Control Service, and Windows Azure Traffic Manager are explained in detail, as is how you can benefit from them.

Chapter7, The Billing Aspects of Windows Azure, describes in great detail all the different billing aspects of Windows Azure. You will learn how the different components of the platform are charged and how you can get a good grip on the Windows Azure costs.

Chapter8, Windows Azure Patterns, provides a step-by-step walkthrough on how to make use of the Enterprise Library Integration Pack in your cloud services. It not only provides great detail on autoscaling and how to achieve this, but also drills down on transient fault handling and how to implement a gatekeeper pattern to enhance security in your cloud service.

Chapter9, Application Lifecycle Management, briefly explains Application Lifecycle Management in general and some specifics with respect to ALM on the Windows Azure Platform.

Chapter10, Windows Azure Security, explains how the Security Development Lifecycle (SDL) is applicable for Windows Azure projects. The chapter also depicts some typical security features on the platform.

Chapter11, What's New in Windows Azure, contains a brief overview of new features of Windows Azure, released in June 2012.

What you need for this book

In order to run the code snippets given in the book, you will need:

Visual Studio 2010.Windows Azure SDK, the latest version.Access to Bing Maps and a valid account key. This can be retrieved from http://www.bingmapsportal.com.

Who this book is for

This book is for developers and architects who are experienced with Microsoft .NET technology and web technology in general, but may or may not be experienced with the latest version(s) of the .NET framework. Some general knowledge on cloud computing is preferred, but not mandatory.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title through the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the erratasubmissionform link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at <[email protected]> with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.

Chapter 1. The Concepts of Windows Azure

"The irresistible forces meet the movable objects."

—Pat Helland

In this chapter, we will provide an overview of Windows Azure and also briefly explain the history of the platform, why it was created, and why it is interesting and applicable for startup companies. We will also explore the evolution of Windows Azure from its early days back in 2008 right to where it is today. The internals of Windows Azure and the way Microsoft datacenters work will also be explained from a user experience perspective. It describes exactly what happens under the hood of Windows Azure after a developer deploys an application to the platform. The last sections of the chapter contain brief overviews of key features of the platform.

Red Dog

Ray Ozzie arrived at Microsoft in 2005 and stated that survival of the company hinged on a shift to cloud computing. He wrote a manifesto called The Internet Services Disruption in which he stated that there are three tenets that dramatically shift the whole landscape around computing. From his point of view, it was essential to embrace those tenets in Microsoft's products and services. These tenets are as follows:

Advertisement-supported economic modelsNew delivery and adoption modelDemand for user experience that "just works"

The essence of this manifesto is that he emphasized that the world was changing, the demands of customers were changing, and technology was changing. It was the beginning of a process that finally resulted in the Windows Azure platform.

Note

Cloud computing enabled a move from packaged solutions with fixed license-based models to resilient services with flexible payment options.

After the release of Vista and the new Office suite, a project group was formed with top engineers, and Ray Ozzie asked Amitabh Srivastava to lead the project. Also, David Cutler (writer of VMS and leader of the Windows NT team) was involved with this revolutionary initiative. The codename of Windows Azure used to be Red Dog. Virtual machines on Windows Azure are still named with the prefix Red Dog (RD).

Windows Azure announcement

On October 27, 2008, at the Professional Developers Conference, Ray Ozzie announced Windows Azure and highlighted its capability in delivering services. The first commercially available release in 2010 of the platform contained:

The Cloud OS (confusingly also called Windows Azure) that offers service management and provisioning, storage, computing power, and networking capabilitiesSQL Azure, offering a Database-as-a-Service (currently known as SQL Database)Microsoft .NET Services, containing features such as workflow and access control (currently known as Windows Azure Service Bus, formerly known as AppFabric)

It was the start of a new era that brought us all into the world of services, agility, faster time to market, new ways of monetizing IT assets, operational expenses versus capital expenses and more. Ever since, Windows Azure has evolved into the mature, enterprise-ready platform it is right now, offering more services, with time.

A quick start on Windows Azure

Windows Azure is about cloud computing. Cloud computing, though, is a vague description of different aspects. Windows Azure is actually a platform that is offered to you as a service (PaaS, meaning Platform as a Service). PaaS enables us to fully concentrate on the application itself and leave all the plumbing to the cloud provider, in this case Microsoft. PaaS offers the management of networking, storage, servers, virtualization, OS, databases, and runtimes. The only thing that's left is the actual application, and that is most important for us since the application is our added value.

How it works internally

Windows Azure runs in large datacenters all around the world. A datacenter is filled with containers, and containers have a lot of servers inside (around 2,000).

Windows Azure offers abstraction to the developer by offering computing power (CPU and memory), storage (disk), and bandwidth (networking hardware). This enables us to treat Windows Azure as a black box without bothering about the internals, although we are curious about the way it works! Well, at least I was.

The best way to describe how a cloud application is created and finally deployed onto a machine in the datacenter is to use an example. Back in the early days, when you wanted to deploy an application, you needed to order hardware, be patient, and install operating systems, database servers, runtimes, and other bits. In the new world of cloud computing, you only need a credit card and a Live ID.

First steps

From a developer's perspective, the main entrance to Windows Azure is through the Windows Azure portal (or through the Service Management API, but I'll cover that later in this book). Operators can look at Windows Azure from the Microsoft System Center.

When you go to http://windowsazure.com, you are able to sign up to the Windows Azure Platform. After creating a billing relationship with Microsoft by using your credit card or the invoicing option, you are able to access Windows Azure. The Windows Azure platform portal is your main entrance to massive-scale computing and storage. The following screenshot shows what the portal looks like and how you can access the different features of Windows Azure.

From this portal, you can create applications (hosted services, as per June 2012, called cloud services), enable storage, create databases, and access other offerings from the Windows Azure platform. Let's have a close look at theNew Hosted Service option and actually create your first Windows Azure application. Let's prepare the next step by creating a logical area on Windows Azure for your first application.

Click on New Hosted Service, and fill out the Create a New Hosted Service screen, as shown in the following screenshot:

You need to pick another name, since the URL prefix needs to be globally unique, and of course, your subscription will be a different one. After clicking on OK, the environment is created for you, and the DNS name entered in the URL textbox is reserved. If you choose the Do not deploy option, only the DNS name will be reserved and you will not get a bill yet, but you can also decide to create the hosted service together with deployment, if you have your binaries and configuration files ready. Hosted services that you create can easily be deleted, and the DNS name will be available again for others.

Creating and deploying a website on Windows Azure

In order to get your application running on Windows Azure, you need to follow a few initial steps.

Perform the following steps to create and deploy a website:

Install the prerequisites on your machine (you can find them at http://www.microsoft.com/download/en/details.aspx?id=15658). After downloading and installing both the Windows Azure SDK and Windows Azure Tools for Microsoft Visual Studio 2010, you are able to create your first web application, which can be deployed to Windows Azure.Start Visual Studio 2010 (make sure you select Run as administrator), go to File | New | Project, and select Cloud from the Installed Templates tab. Name it MyFirstAzureProject and click on OK. The following screen appears:

As you can see, creating a Windows Azure service does not mean that you need to learn new skills or new tools; you can leverage your existing .NET skills.

Select ASP.NET MVC3 Web Role and name it MyFirstAzureMVC3Website. A Web Role is in fact a Windows 2008 virtual machine with Internet Information Services enabled. This enables the Web Role to be accessible through the Internet. By picking the MVC3 Web Role, we can again benefit from the already available knowledge on MVC3. After clicking on OK, you need to pick what project template is used to create the MVC3 Website. For now, it's ok to select the Internet Applicationand leave the rest of the options at their default values.Now click on OK, and the solution is created for you:

Your solution looks like an ordinary Visual Studio 2010 solution, but with a few additions to it. As it is a cloud project, not only is the MVC3 project created, but also a cloud project. In the MVC3 project, you will see a class file named WebRole.cs. This standard MVC3 website is ready to be deployed to Windows Azure. The website will run, but some default settings point to local development storage; these will cause the application to crash if somebody tries to reach the deployed website. We will get back to that later on.

To demonstrate upgrade and fault domains, change the ServiceConfiguration.Cloud.cscfg file, and change the Instances count to 2:
<Instances count="2" />
This causes two instances of your web role to be deployed on Windows Azure. They are identical, with the same binaries, but having two instances of the same web role running increases availability and enables the website to handle more traffic.

This configuration spins up two servers, has your application deployed onto them, and also creates a load balancer on top of them. Try to imagine how much work this is in a traditional datacenter.

First deployment

This section will guide you through the deployment of your Windows Azure project.

Right-click on the MyFirstAzureProject node in your solution and select Package.A new popup window appears, but for now it is sufficient to click on the Package button.Windows Azure Tools will now build your project, zip the binaries, and create the service configuration file.A Windows Explorer window is opened, and you will see the result of the "packaging" action—a large binary package (.cspkg) and the configuration file. Copy the location of this folder.Go back to the Windows Azure portal and select the recently created hosted service.Right-click on the Hosted Service entry and select New Production Deployment.Name your deployment, select the recently created files in the Package location and Configuration file textboxes, and click on OK.

Note

A warning appears, telling you that you need to create at least two instances to guarantee the 99.95 percent uptime the Windows Azure Compute service-level agreement (SLA) offers.

An SLA is a service contract in which the level of service is formally defined. Please go to http://www.windowsazure.com/en-us/support/legal/sla/ to get details about the SLA.

When two or more instances of a role are running in different fault and upgrade domains, Microsoft can offer at least a 99.95 percent (of the time) Internet connectivity of the designated roles. An availability of 99.95 percent means that your service is guaranteed less than 5 minutes down per week, inside the Fabric.

In the previous section, we deployed our Windows Azure project by using the Windows Azure portal and the Package option in Visual Studio. But what actually happened after uploading the package?

Upgrade domains

Upgrade domains are groups of nodes that are updated consecutively when there is a new Windows Azure OS version available or when you update your role. As stated before, the Windows Azure SLA is based on having two instances of each distinctive role run in at least two upgrade domains. You can choose to have only one instance of your role running, but this means that on every upgrade (OS, patch, security fix, or role upgrade) that causes a reboot your service will be unreachable.

Organizing your roles in more than one upgrade domain prevents your service from being offline because when one instance is down because of the update, the other one is still running, since it's in a different upgrade domain. The number of upgrade domains your role instances are put in is configurable in the service definition file (ServiceDefinition.csdef) in your solution. By default, the number is five, but you can change this at any time. After redeploying your service, your roles will be distributed among the number of upgrade domains you defined using the Fabric Controller. The capacity of your service during an OS upgrade is one, divided by the number of update domains. So, when you have five role instances running in five upgrade domains, your service capacity will be reduced by 20 percent during the whole upgrade process.

Note

Upgrade domains enable availability of your services during a Windows Azure OS update.

Fault domains

A fault domain is a physical unit of failure and can be mapped to physical infrastructure. A fault domain can be a complete rack or a single computer depending on the organization of the datacenter. Fault domains are meant to enhance fault tolerance of services. Keep your service running at all times, even during a hardware failure in the datacenter. Deploying your services into more than one fault domain will keep your service running, even when, for example, a top rack switch breaks down. Fault domains are physically grouped hardware areas inside the datacenter.

Note

The purpose of fault domains is to avoid single point of failure for your services and to maintain availability.

Fabric Controller

The Fabric Controller(FC) acts like the "kernel" for the datacenters. It has two major tasks:

Resource allocation and provisioning of described hardware and network resources (datacenter hardware)Service lifecycle and health management based on applied service model and binaries (Windows Azure services)

The FC itself is an application running across different fault domains (just like your services) to ensure its availability. The FC runs on several nodes, and only one instance is the primary FC. All other instances are running in sync with the primary one.

Internals of a node

The FC is in charge of all the hardware inside the datacenter.

Note

Servers are placed in racks, racks are organized in clusters, and all the clusters together form the datacenter. A cluster contains approximately 1,000 servers.

Before being able to deploy your service on a single (or several) node(s), the FC actually turns on a node. After that the following process takes place:

The node boots from the network using Preboot Execution Environment (PEX). A maintenance OS image is downloaded to the node and boots into it. The maintenance OS contains a fabric agent, and the FC communicates directly with this host agent.The maintenance OS downloads a VHD with the operating system for the host partition. This OS contains an FC host agent. The maintenance OS then restarts the node and boots onto the operating system for the host partition.The FC tells the FC host agent how many partitions need to be set up, depending on the "deployment" request. If a user wants to deploy a multicore VM size, this automatically means that the node can contain fewer instances, since fewer CPUs are available. On the partition, there is a base VHD and a differencing disk. This works in a similar way with Hyper-V technology, since the OS is a version of Hyper-V, written for Windows Azure. The guest VHD contains a modified Windows 2008 Server version, so that it can integrate with the Windows Azure hypervisor.

The following figure presents what a node looks like after the partitioning and provisioning of the guest OSs, including the agents that are needed to enable communication between the FC and the guest OSs.

After these steps, the FC can deploy the MVC3 website we created in previous sections.

Deployment steps

The FC processes the service model you provided during the deployment step. In this case, we told the FC to deploy two instances of our MyFirstAzureMVC3Website node. The VM size is Small, by default. This means 1 CPU core, 1.75 GB of memory, about 230 GB of local storage, and reserved bandwidth of 100 Mbps.

Note

For more information on the characteristics of VM sizes, please visit http://msdn.microsoft.com/en-us/library/windowsazure/ee814754.aspx.

The FCs create two guest partitions, as described in the previous sections, located in two different upgrade and fault domains. The FC then pushes the package (containing the binaries and the configuration file) to the target host agents. The host agents both create a guest partition that fulfills the service model we provided and starts the guest partitions. The guest agents both start the web role we created and call the role entry point, which is located in WebRole.cs. From this point, the role reports the heartbeats back to the host agent, so that the FC can monitor and maintain the health of roles. A role without a heartbeat for a period of time is considered unhealthy and is restarted.

The final step is that the FC programs a load balancer (LB) that routes the traffic to our website and divides it to the two role instances. Windows Azure equally spreads traffic across web role instances that are part of the same deployment. Having multiple instances of the same web role enables your website to handle more user traffic. The following figure shows where the instances are copied and run inside the datacenter, bearing in mind the upgrade and fault domains.

Our website is running now, has an uptime of 99.95 percent, and remains available, even in case of hardware failure or OS updates initiated by Windows Azure.

Core components of Windows Azure

Windows Azure is often referred to as a platform, but what is actually inside that platform? As you have seen in the previous sections, Windows Azure offers a place where you can run your website, but during the evolution of the platform, more and more features were added. Beside running a client-facing Internet application, it also offers a place where you can run your application code that has no user interface at all (long-running computations or asynchronous tasks), It even offers the possibility of deploying a Windows Server 2008 R2 image to migrate your legacy applications to the cloud and offer the same level of scalability and availability. The underlying infrastructure of every type of role (web, worker, or VM) is a virtual machine that is handled by Windows Azure and that takes care of load balancing and failover. The pricing for every role type is similar and is based on the size of the underlying virtual machine. The details of the pricing models are described in Chapter 7, The Billing Aspect of Windows Azure.

Compute

The Windows Azure platform offers three different types of roles:

Web roles Worker roles VM roles

This section explains the differences between these different role types.

Web roles

Web roles run an Internet Information Services web server that can be used to host your frontend web application. It is easy to deploy a web role, and load balancing is included in the offering. You can use both the HTTP and HTTPS protocols.

Worker roles

A worker role is typically used for long-running or asynchronous tasks that require no user input. A common application scenario is a configuration that consists of both web and worker roles, where the web roles are as thin as possible, only handling traffic and being highly responsive to the user. The worker roles take care of the actual work (placing an order, performing a workflow). Queuing mechanisms enable loose coupling and offer you the ability to achieve fine-grained scaling (for example, only scale up your web roles to enhance).

Virtual machine roles

Virtual Machine (VM) roles allow you to deploy your own Windows Server 2008 R2 image to Windows Azure and host it in a hosted service, just like you do with a web or worker role. Applicable scenarios are applications that require OS customizations or native applications running in a standalone fashion. The VM role allows full control of the application environment (for example, registry settings or the old-fashioned .ini files) and enables you to migrate existing applications quickly to Windows Azure and benefit from the PaaS abilities the platform offers. Applications that take a long time to install or that require user input, or applications that are stateless, are suitable candidates to deploy as a VM role. A VM role gives you control over the virtual machine and allows you to build a suitable image from scratch, upload it to Windows Azure, and get it running. You can install software on the VM image and then upload it.