Chapter 2. Windows Azure platform Overview

The Windows Azure platform is Microsoft's cloud computing platform and is a key component of Microsoft's overall Software + Services strategy. Gartner Research has identified Cloud Computing as one of the "top 10 disruptive technologies 2008–2012" (http://www.gartner.com/it/page.jsp?id=681107) According to Gartner, a disruptive technology is the one that causes major change in the accepted way of doing things. For enterprise architects and developers, the Windows Azure platform does cause a major change in the accepted way of architecting, developing, and deploying software services.

Software development today typically consists one or more of the following types of applications:

  • Rich client and Internet applications: Examples are Windows Client, Windows Presentation Foundation, and Silverlight.

  • Web services and applications: Examples are ASP.NET, ASP.NET Web Services, and Windows Communications Foundation.

  • Server applications: Examples are Windows Services, WCF, message queuing, and database development.

  • Mobile application: Examples are .NET Compact Framework and placeholder.

Most of these application types are on-premise enterprise applications or consumer applications hosted in data centers. The Windows Azure platform adds a new cloud services type to the list. During planning and architecture phases of a project, architects can now choose to include the Windows Azure platform in the overall service architecture.

The Windows Azure platform supports development and deployment of different types of applications and services, not only in the cloud but also on-premise. It is a collection of building blocks of platform, middleware, enterprise, and consumer services for developers to build cloud services. It provides developers with a cloud operating system called Windows Azure, a cloud database called SQL Azure, infrastructure middleware component called .NET Services and a consumer services component called Live Services. Developers can either build services that span across all these components, or pick and choose the components as needed by the service architecture. The overall concept of Windows Azure platform is to offer developers the flexibility to plug in to the cloud environment as per the architectural requirements of the service.

Note

In this book, I refer to the overall Azure cloud offering from Microsoft that consists of Windows Azure, .NET Services, and SQL Azure as "the Windows Azure platform." Windows Azure is the operating system in the cloud, and it is the core component of the Windows Azure platform. I also use the terms "Azure" and "Windows Azure platform" interchangeably.

Development tools like Visual Studio .NET have matured enough in the past decade to increase developer productivity several folds in application design, development and testing, but there has been little improvement in the infrastructural challenges involved in deploying distributed applications. Organizations frequently require months of planning and coordinated efforts between multiple internal groups like Directory Services, Database Management, Platform Services and Security for deploying distributed enterprise applications. Ultimately, organizations end up spending more time and resources in coordinating activities across multiple groups than the delivery of the application itself.

Windows Azure platform readily provides internet scale infrastructure for deploying distributed applications and services. You can develop a cloud service in Visual Studio .NET and deploy it into the Azure cloud right from on-premise tools. This frees up critical project resources to focus on solution design and delivery instead of managing internal infrastructure dependencies.

In this chapter, I will cover the basics of the Windows Azure platform. I will also cover the development workflows of its components, just enough to get you started with your development environment. At the end of the chapter, I will walk you through a basic Windows Azure example.

Windows Azure Platform Overview

The Windows Azure platform is an end-to-end development and deployment platform for building cloud services. Each component of the Windows Azure platform is designed to provide a specific functionality to cloud services. In this section, we will look at the high-level architecture of the Windows Azure platform.

Windows Azure Platform Architecture

The Windows Azure Platform consists of three main components – Windows Azure, SQL Azure, and .AppFabric. Figure 2-1 shows a simple illustration of the four Windows Azure platform components.

The Windows Azure platform

Figure 2.1. The Windows Azure platform

Warning

When this book was in progress, Microsoft put the Live Framework and Live Services developer community technology preview on hold indefinitely. The Live Mesh was still running and accessible to end-users. I have not included Live Services in this book.

The Windows Azure Operating System

Windows Azure is the underlying operating system for running your cloud services on the Windows Azure platform. Microsoft brands Windows Azure as the Operating System in the cloud, because it provides all the necessary features for hosting your services in the cloud. It provides a runtime environment that includes a web server, computational services, basic storage, queues, management services, and load-balancers. Windows Azure also provides developers with a local development fabric for building and testing services before they are deployed to Windows Azure in the cloud. Figure 2-2 illustrates the three core services of Windows Azure.

Windows Azure core services

Figure 2.2. Windows Azure core services

The three core services of Windows Azure are as follows:

  • Compute: The compute service offers scalable hosting of services on 64-bit Windows Server 2008 platform with Hyper-V support. The platform is virtualized and designed to scale dynamically based on demand. The platform runs Internet Information Server (IIS) version 7 enabled for ASP.NET Web applications. At the time of this writing, the underlying Windows operating system and other infrastructure components like IIS are not available directly to developers. The abstraction is at the operating system layer. Developers can write managed and unmanaged services for hosting in the Windows Azure Compute cloud without worrying about the underlying operating systems infrastructure.

  • Storage: There are three types of storage supported in Windows Azure: tables, blobs, and queues. I will cover these storage types later in the book in detail. These storage types support REST-based direct access through REST APIs. Windows Azure tables are not traditional relational database tables like SQL Server tables. Instead, they provide structured data storage capabilities. They have independent data model popularly known as the entity model. Tables are designed for storing terabytes of highly available data like user profiles in a high-volume ecommerce site. Windows Azure blobs are designed to store large sets of binary data like videos, images, and music in the cloud. The maximum allowable size per blob item is 50GB. Windows Azure queues are the asynchronous communication channels for connecting between services and applications not only in Windows Azure but also from on-premise applications. You can also use queues to communicate across multiple Windows Azure role instances. The queue infrastructure is designed to support unlimited number of messages, but the maximum size of each message cannot exceed 8KB. Any account with access to storage can access tables, blobs, and queues.

  • Management: The management service supports automated infrastructure and service management capabilities to Windows Azure cloud services. These capabilities include automatic commissioning of virtual machines and deploying services in them, as well as configuring switches, access routers, and load balancers for maintaining the user defined state of the service. The management services consist of a fabric controller responsible for maintaining the health of the service. The fabric controller abstracts the underlying virtualized platform infrastructure from the compute and storage services. The fabric controller supports dynamic upgrade of services without incurring any downtime or degradation. Windows Azure management service also supports custom logging and tracing and service usage monitoring.

SQL Azure

SQL Azure is the relational database in the Windows Azure platform. It provides core relational database management system (RDBMS) capabilities as a service, and it is built on the core SQL Server product code base. In the current version (CTP), developers can access SQL Azure using tabular data stream (TDS), which is the standard mechanism for accessing on-premise SQL Server instances through SQL client today. The SQL client can be any client, like ADO.NET, LINQ, ODBC, JDBC, ADO.NET Entity Framework, or ADO.NET Data Services.

Note

ADO.NET Data Services is an independent framework for accessing web-based data services. It can be used not only for consuming web-based data services but also for on-premise data services like SQL Server 2008. For more information on ADO.NET Data Services, please visit the MSDN site http://msdn.microsoft.com/en-us/data/bb931106.aspx.

Figure 2-3 illustrates the core components of SQL Azure.

SQL Azure core components

Figure 2.3. SQL Azure core components

The core services offered by SQL Azure are as follows:

  • Relational Data Storage: The relational data storage engine is the backbone of the SQL Azure and is based on the core SQL Server code base. This component exposes the traditional SQL Server capabilities like the tables, indexes, views, stored procedures, and triggers.

  • Data Sync: The Data Sync capabilities provide the synchronization and aggregation of data to and from SQL Azure to enterprise, workstations, partners and consumers devices using the Microsoft Sync Framework.

    Note

    The Microsoft Sync Framework is included in the SQL Server 2008 product (http://msdn.microsoft.com/en-us/sync/default.aspx).

  • Management: The management component provides automatic provisioning, metering, billing, load-balancing, failover and security capabilities to SQL Azure. Depending on the SLA, each database is replicated to one primary and two secondary servers. In case of a failover, the switching between the primary and the secondary server is automatic without interruptions.

  • Data Access: The Data Access component defines different methods of accessing SQL Azure programmatically. Currently, SQL Azure will support Tabular Data Stream (TDS), which includes ADO.NET, Entity Framework, ADO.NET Data Services, ODBC, JDBC, and LINQ clients. Developers can access SQL Azure either directly from on-premise applications or through cloud services deployed in Windows Azure. You can also locate a Windows Azure compute cluster and a SQL Azure instance together for faster data access. I will discuss SQL Azure in detail later in this book.

.NET Services

.NET Services is the middleware engine of Windows Azure platform providing access control service and service bus.

Note

Later Microsoft may enable Workflow services, which was part of the original AppFabric offering but was discontinued to align it with the Windows Workflow 4.0 release. In this book, I will not cover Workflow Services because its future was uncertain at the time of this writing.

AppFabrichas a service-oriented architecture and allows the creation of federated access control and distributed messaging across clouds and enterprises. I consider AppFabricto be the integration backbone of the Windows Azure platform, because it provides connectivity and messaging capabilities among distributed applications. It also provides capabilities for integrating applications and business processes not only between cloud services but also between cloud services and on-premise applications.

AppFabricalso provides a development environment integrated into Visual Studio .NET 2008 SP1 and beyond. Developers can build WCF-like services in Visual Studio .NET and publish endpoints to the cloud from within Visual Studio .NET design environment. Figure 2-4 illustrates the two core services of .NET Services.

AppFabriccore services

Figure 2.4. AppFabriccore services

The two core services of AppFabricare as follows:

  • Access Control: The access control component provides rules-driven, claims-based access control for distributed applications. You could define claims-based rules and authorization roles in the cloud for accessing on-premise as well as cloud services.

  • Service bus: The service bus is a generic .NET Internet service bus. It is analogous to the Enterprise Service Bus (ESB) popularly seen in large enterprises. Unlike the ESB, the AppFabricServiceBus is designed for Internet scale and messaging with cross-enterprise and cross-cloud scenarios in mind. The service bus provides key messaging patterns like publish/subscribe, point-to-point, and queues for message exchanges across distributed applications in the cloud as well as on-premise.

I will discuss AppFabricin detail later in this book.

Live Services

Microsoft Live Services is a collection of consumer centric applications and frameworks like Identity Management, Search, Geospatial, Communications, Storage, and Synchronization. Live Services and Live Framework are commonly confused for each other. Live Framework is a unified development model for building applications for Live Services. Live Framework provides the capabilities of building synchronization applications called the Mesh Applications for synchronizing data across multiple desktops and mobile devices seamlessly.

Live Framework also provides a local development environment integrated into Visual Studio .Net and a local runtime environment for on-premise development and testing. Figure 2-5 illustrates the core components of Live Services.

Live Services core components

Figure 2.5. Live Services core components

The core components of Live Services are as follows:

  • Mesh services: Mesh services provide programmatic access to users, devices, applications and the data synchronization across them.

    • The users service provides management and sharing of resources across devices and other users.

    • The devices service provides management, access, sharing and security of user devices across the Internet.

    • The applications service provides deployment, configuration, versioning and access control to applications across the Live mesh.

    • The data sync service provides synchronization of data and metadata across multiple devices, applications and the Live mesh cloud.

  • Identity services: the identity service provides identity management and delegated authentication across the Live Services. E.g. Windows Live Identity Provider.

  • Directory Services: The Directory Services manages the relationships and the graphs of the Users, Identities, Devices, Applications and their connected network. E.g. Relationship between users and devices in Live Mesh.

  • Storage: The Storage service manages the storage of transient and persistent data for the Users, Devices and Applications in the Mesh. E.g. Windows Live Skydrive and Live Mesh storage

  • Communications & Presence: The Communication and Presence service provides the communications infrastructure between devices and applications, and manages their presence information for connections and display, for example, Windows Live Messenger and Notifications API.

  • Search: The Search Service provides search capabilities for users, web sites and applications, for example, Bing.

  • Geospatial: The Geospatial Service provides rich geo-mapping, location, routing, search, geocoding and reverse geocoding services to web sites and applications, for example, Bing Maps (or Virtual Earth).

  • Live Framework: Live Framework is a uniform model of programming Live Services across platforms, programming languages and devices. The three core components of the Live Framework are:

    • Live Operating Environment (LOE): The LOE is the uniform runtime environment for Live Services objects in the cloud as well as in the local device environment. Developers can connect to the LOE in the cloud or on the local device. LOE gives offline operational capabilities to the Live Mesh. LOE also enables Live Mesh to synchronize offline operational data with the cloud LOE and other devices.

    • Resource Model: The Live Framework resource model exposes the LOE resource objects like Data, Applications, Communications, Mesh and Identities via open protocols and formats like HTTP, XML, ATOM and RSS. You can use any programming language supporting these protocols to access LOE resources.

    • Live Programming Model: The Live Programming Model provides a common programming model from JavaScript, Silverlight and .NET programming languages. You can build Client, Web and Rich Internet Applications using any of the above mentioned programming languages and deploy them in the Live Mesh. The Live Programming Model provides a uniform resource model across Live Services and exposes these services as REST (Representational State Transfer) resources. The Live Programming model supports open protocols and formats like HTTP, XML, ATOM and RSS for accessing Live Services.

I will discuss Live Services and Live Framework in detail later in this book.

Basic Azure Scenarios

In the previous section, you saw the high-level architectural view of the Windows Azure platform and its core components. In this section, let's take a look at some of the basic scenarios that encompass all of the Windows Azure components. Figure 2-6 illustrates the overall development and runtime architecture of the Windows Azure platform with some embedded scenarios. Let's derive some basic scenarios from this diagram.

The Azure development runtime architecture

Figure 2.6. The Azure development runtime architecture

For the ease of understanding Figure 2-6, let's consider four entities—The Developer, Consumer Devices, the Enterprise and the Cloud (Windows Azure platform); and four scenarios—Windows Azure Software Development, Cross-Enterprise Application Integration, Enterprise Process Offloading and Consumer Services.

Scenario 1: Azure Software Development

In Scenario 1, the developer develops cloud services for Windows Azure, .NET Services, SQL Azure and Live Services on a local development environment and then tests these applications in the local development fabric before deploying them to the Windows Azure platform. The Windows Azure environment can host web as well as background process applications (called Worker) that can communicate with .NET Services, SQL Azure or Live Services depending on the business requirements of the application. Developers can also build services directly targeting each individual Windows Azure platform component. Once the services are deployed in their respective environments in the cloud, enterprises and consumers can start using them. The typical development cycle consists of designing, developing and testing the application in the local development fabric before it is deployed into a cloud staging environment. After testing the application in the cloud staging environment, it is deployed to the cloud production environment for end users to start using it.

Scenario 2: Cross-Enterprise Application Integration

In the Figure 2-6, Enterprise B is a payroll processing company that processes paychecks for Enterprise A. Enterprise A needs to send employee information to Enterprise B for payment processing on a periodic basis. After payment processing, Enterprise B needs to send a consolidated payment report to Enterprise A for accounting purposes. What I want to illustrate here is that there is a two-way financial relationship between the two enterprises and automated data exchange between both the enterprises is a business requirement. Traditionally, to achieve this, the IT departments from both the enterprises would have had to open up Firewall ports for transferring data back and forth from both the enterprises, and create a trust relationship between the directory domains in both the enterprises so the users from one enterprise are recognized in the other.

In the Windows Azure platform, you could achieve this by following these steps:

  1. Register trust between the domains in both the enterprises with the AppFabricAccess Control Service.

  2. Use the single sign-on capabilities of AppFabricto authenticate users across both the enterprises.

  3. Use the ServiceBus network connectivity features to communicate across business applications through the firewall.

  4. Optionally, any of the processing applications from both the enterprises could be hosted in the cloud as Windows Azure applications.

Scenario 3: Enterprise Process Offloading

Enterprise B is a payroll processing company that processes payroll calculations and reporting for more than 500 companies. Enterprise B has to generate consolidated payroll reports for all the 500 organizations at the same time, because the payroll date is the same for all the enterprises. After the payroll is processed, Enterprise B has to electronically send the reports to its customers the following day, due to compliance reasons. As Enterprise B is growing, it is not able to keep up with the computing capacity it needs to process reports for all the 500 organizations in a single day. So, Enterprise B decides to offload report processing to the Windows Azure platform by synchronizing the on-premise SQL Server database with SQL Azure, and running the report processing application on Windows Azure platform. Enterprise B can now scale the report processing application within the cloud, in proportion to the company's growth. Thus, Enterprise B has successfully offloaded a processor intensive application to the Windows Azure platform without worrying about its on-premise infrastructure and processing capacity.

Scenario 4: Consumer Services (Live Mesh Synchronization)

In the fourth scenario, you have a role to play. Assume that in the past decade, the number of devices you and your family owns has increased to seven: one personal computer, three smart phones, and three laptops. Out of these, two laptops are owned by the company you work for.

One day, you decide to write a book on Windows Azure platform, and your company permits you to dedicate 10–15% of your daily time to writing the book. The challenge you are facing is sharing your writings between the enterprise PC at work and home laptop. You also want the ability to write your chapters from the garden next to your house on a perfectly sunny day. You need seamless access to your documents across multiple devices and locations.

You install Live Mesh on all your devices and pick and choose the files that you want to synchronize across them. Now, when you work on the chapters at home, they are automatically synchronized on your work computer. The next day, when you go to work, your work machine is up to date with the new content, and you can start working on the book at work. You can also work on your files from the garden with no network connectivity. When you return home and connect your laptop, Live Mesh automatically synchronizes the documents across all the selected devices for you. Thus, by using Live Mesh, you have created a seamless synchronization network among your own devices for sharing not only documents, but also other artifacts like photos, videos, and files.

Windows Azure Platform for Developers

Windows Azure, SQL Azure, .NET Services, and Live Services all have separate software development kits (SDKs), but Visual Studio .NET and the .NET Framework are the common programming tools used for building applications for all the Windows Azure components. Windows Azure SDK and the Live Framework SDK have local development fabrics that emulate the cloud environment at a miniature scale. Developers can utilize their existing .NET development skills for developing services for Windows Azure platform. In this section, I will cover the developer roles and the technical readiness required for developing Windows Azure platform services.

Developer Roles

The types of developers that may be interested in developing Windows Azure applications follow:

  • Enterprise developers: Enterprise developers typically work either in the IT or Business departments of an enterprise. They are responsible for developing applications that improve business productivity. The business requirements come directly from the business groups within the enterprise or from strategic IT initiatives. Enterprise developers can then create cloud services on Windows Azure platform for consumption either by the local business units or cross-enterprise business units.

  • ISV developers: Independent software vendors (ISVs) develop business solutions on an existing platform. ISVs are more focused in vertical markets like financials, manufacturing, oil, gas, and healthcare. ISVs can leverage the Windows Azure platform for deploying services that are targeted for multiple customers in vertical markets. They can design multitenant architectures on top of Windows Azure platform, specifically dedicated for vertical industries they specialize in.

  • Consumer developers: Consumer developers work for online service companies like MSN Live, Yahoo, Apple, Google, Facebook, and MySpace, and they offer software services like mail, collaboration, social networking, and mobile services directly to the consumers. Consumer developers can build consumer services on Windows Azure platform and offer them to consumers around in the world.

Developer Readiness

Understanding the following technologies and concepts are the primary skills required for developing with Windows Azure:

  • Visual Studio .NET 2008/2010

  • .NET Framework 3.5

  • Windows Communications Foundation

  • ADO.NET

  • ADO.NET Data Services

  • Web services (REST, SOAP)

  • XML

  • ASP.NET

  • .NET security

  • SQL Server database development

Essentially, any proficient .NET developer should be able to develop Windows Azure services comfortably. This book assumes that you are comfortable programming in C# using Visual Studio .Net and .NET Framework. Even though all the examples in this book are written in C#, they could easily be ported to any programming language supported by the .NET Framework.

Getting Started

In this section I will cover the prerequisites required for getting started with the Windows Azure platform. As you know by now, Windows Azure is a cloud platform and runs in Microsoft's data centers. To access a particular service in the Windows Azure platform, you need to sign up for an account with Microsoft. Table 2-1 lists the web sites you can navigate for creating accounts for specific services. You can associate your account with your Windows LiveID.

Table 2.1. Windows Azure Sign-up Links

Service Name

Sign-up Web Site

Windows Azure

https://lx.azure.microsoft.com/

.NET Services

http://portal.ex.azure.microsoft.com/

SQL Azure

http://portal.ex.azure.microsoft.com/

Live Services

https://lx.azure.microsoft.com/

Alternatively, you can visit the Windows Azure platform web site http://www.azure.com, and navigate to the sign in tab to sign-up for Windows Azure, as shown in Figure 2-7.

The Windows Azure sign-in page

Figure 2.7. The Windows Azure sign-in page

On the Windows Azure sign in page, you can sign up for each of the four core services—Windows Azure, SQL Azure, Microsoft .NET Services, and Live Services.

Note

Because Live Services will eventually be part of Windows Live, I will not include it in the portal navigation discussions.

Windows Azure Developer Portal

The Windows Azure developer portal is the primary location for developers interested in developing Windows Azure application. You navigate across all the Windows Azure platform components from the portal and then manage your Windows Azure deployments from the web page. Once you sign in with your account, you will be redirected to the Windows Azure developer portal. Figure 2-8 illustrates the Windows Azure developer portal landing page (Summary section).

The Windows Azure developer portal

Figure 2.8. The Windows Azure developer portal

In the Windows Azure developer portal, there are three top-level navigation options—Summary, Account, and Help. In the Summary page, as shown in Figure 2-8, you can view the list of existing projects that you can administer. If you have not created any projects or are visting the site for the first time, the projects list will be empty. Click one of the listed projects to go to the Windows Azure services list, shown in Figure 2-9.

Windows Azure services list

Figure 2.9. Windows Azure services list

Click the New Service link to go to the Create a New Service page shown in Figure 2-10.

The Create New Service page in the Windows Azure developer portal

Figure 2.10. The Create New Service page in the Windows Azure developer portal

In Figure 2-10, you can create two types of services: Storage Account and Hosted Services Project. I will cover these project types in details in later chapters. You can assume for now that this page is used for creating Windows Azure cloud services. In Figure 2-9, I already have three services created: ProAzure, ProAzure NW Storage, and ProAzureStorage. As the name suggests, ProAzure NW Storage and ProAzure Storage are storage accounts. The ProAzure project is a compute project for hosting web applications and background processing applications. You can click any of the services to go to its respective management page. Figure 2-11 shows the management page for the ProAzureStorage service.

The ProAzureStorage management page

Figure 2.11. The ProAzureStorage management page

The storage service does not run user-specific applications; instead, it provides URL access points to its storage infrastructure. The storage service management page lists the URL endpoints for the blob, queue, and table services. The page also lists the access keys for securely accessing the storage service and the affinity of the storage service towards a particular geolocation. Figure 2-12 shows the management page for the ProAzure compute service.

ProAzure management page

Figure 2.12. ProAzure management page

Unlike storage service, the compute service actually runs your applications, so the management page provides upgrade, run, configure, and delete operations on your compute service. In the preceding example, I have four different roles deployed in production. The numbers next to each role indicate the number of instances of each role. The Web Site URL http://proazure.cloudapp.net is the URL of the web application deployed in this service. The service will run only after I click the Run button. On the compute service management page, you have the option of running your application either in the staging environment or the production environment.

Figure 2-13 shows the staging and production environments management page.

Staging and production environment management

Figure 2.13. Staging and production environment management

The staging environment has nothing deployed, because it was swapped to production during the latest release. In any case, it is always a best practice to first test your cloud service in staging before promoting it to production. The Deploy button takes you to the staging deployment page as shown in Figure 2-14.

The Staging Deployment page

Figure 2.14. The Staging Deployment page

From the deployment page, you can upload your cloud service application package and its associated configuration file. The number of roles and their instances are all contained in the cloud service application package. Later in this chapter, you will build a simple cloud service package for Windows Azure.

Figure 2-15 shows the contents of the Account page of the Windows Azure developer portal.

Windows Azure developer portal Account page

Figure 2.15. Windows Azure developer portal Account page

The Account page is generally used for managing account-related information like the invitation tokes received from Microsoft, X.509 API certificates for the Windows Azure Service Management API, and affinity groups for geolocating your services in Windows Azure.

Figure 2-16 illustrates contents of the Help page of the Windows Azure developer portal.

Windows Azure developer portal Help page

Figure 2.16. Windows Azure developer portal Help page

The Help page is a resource page and provides links to software development kits, Windows Azure product blogs, and articles about Windows Azure. The Help page is also the primary feedback page where users can enter product feedback through forums.

AppFabricDeveloper Portal

To navigate to the AppFabricdeveloper portal, click on the AppFabriclink on the Windows Azure portal. The AppFabricsubscription is included in Windows Azure subscription at the time of this writing. The AppFabriclanding page lists the AppFabricsolutions and links to AppFabricSDK, MSDN resources, and forums, as shown in Figure 2-17.

AppFabricLanding Page

Figure 2.17. AppFabricLanding Page

From the AppFabriclanding page, you can add AppFabricsolutions as shown in Figure 2-17. Each solution consists of a solution name, access control service (ACS), service bus registry, and credentials for accessing ACS and ServiceBus endpoints. Each link (ACS, ServiceBus, and Credentials) takes you to their respective management pages. An ACS is a cloud-based claims-mapping service that can be used in cloud-based as well as on-premise applications that use claims-based identity model. ServiceBus is an Internet message bus for sending and receiving messages across the Internet between applications. The Credentials page lets you manage credentials for accessing ACS and ServiceBus services. Figure 2-18 shows the credentials management page from the AppFabricportal.

AppFabricCredentials Management

Figure 2.18. AppFabricCredentials Management

You can have three types of credentials for accessing AppFabricendpoints: Solution Password, Windows CardSpace Information Card, and X.509 certificates. You can use any one of the credentials for accessing the AppFabric endpoints.

SQL Azure Developer Portal

To navigate to the AppFabric developer portal, click the SQL Azure link on the Windows Azure portal. If you are logging in for the first time, you may need an invitation token to enter before the portal takes you to the SQL Azure developer portal. From the SQL Azure developer portal, you can manage your projects and create/delete databases. Figure 2-19 shows the list of projects I am allowed to administer in my account.

SQL Azure Projects

Figure 2.19. SQL Azure Projects

Clicking the Manage link will take you to the server administration page, where you can create and delete databases. Figure 2-20 shows the server administration page with five databases. The master database is the SQL Server master database you receive with all the SQL Azure instances.

SQL Azure Project management page

Figure 2.20. SQL Azure Project management page

The Create Database and Drop Database buttons let you create a new database or drop an existing database respectively. The Connection Strings button gives you the format of the database connection string you can use for accessing the database from SQL Server clients.

Building the Development Platform

In this section, I will list the software components recommended for building your own development environment for Windows Azure platform.

Note

All SDKs for the Windows Azure platform can be downloaded at http://www.microsoft.com/azure/sdk.mspx.

The following sections list the recommendations for building your own environment for Windows Azure development.

Operating System

You may use Windows Vista SP1 (Home Premium, Enterprise, or Ultimate), Windows 7, or Windows 2008 Server.

Software

I have divided the software requirements for each service into its own section. The "general" section lists the software required for all Windows Azure platform development work.

  • General

  • Visual Studio .NET 2008/2010 SP+

  • .NET Framework 3.5+

  • Windows Azure

  • Windows Azure SDK: Windows Azure SDK (http://www.microsoft.com/azure/sdk.mspx) contains the development fabric, client libraries, tools, samples, and documentation for developing Windows Azure services.

  • Windows Azure Tools for Microsoft Visual Studio: Windows Azure Tools for Visual Studio (http://www.microsoft.com/azure/sdk.mspx) create cloud services project types you can use for creating and deploying Windows Azure cloud services from within Visual Studio.

  • SQL Server 2008 Express or SQL Server 2008 Developer: The development fabric from the Windows Azure SDK depends on SQL Server for creating development storage.

  • SQL Azure

  • SQL Server 2008 Express or SQL Server 2008 Developer: This is needed for connecting to SQL Azure and executing scripts.

  • NET Services

    • Microsoft AppFabric SDK: The AppFabric SDK (http://www.microsoft.com/azure/sdk.mspx) integrates the Visual Studio tools. It contains client libraries, tools, samples, and documentation for creating AppFabric applications.

  • Live Service

    • Live Framework Tools for Visual Studio and SDK: These are available at http://dev.live.com/liveframework/.

    • Live Framework Tools: These are available at http://dev.live.com/resources/downloads.aspx.

The installation of all these software components and SDKs is fairly straightforward. In this chapter, we will use only Windows Azure SDK. In later chapters, you will need the AppFabric and Live Framework SDKs.

Getting Started with Windows Azure Platform Development

In this section, I will cover the basics for getting started with developing Windows Azure services. The objectives of this section are to make you comfortable with the concepts discussed and get you started with hands-on experience in building your own cloud services. This section will cover only the basic concepts discussed in the chapter. Later in this book, you will learn advanced concepts through advanced examples in each chapter.

This example assumes you have installed all the prerequisites required for developing Windows Azure services. If you have already setup your development environment, let's get started with a simple Windows Azure service to get you comfortable with Windows Azure development. In this example, you will develop, build and deploy a simple Windows Azure web role service to the cloud. Initially, we will build the complete service in the development fabric and then deploy it to the cloud.

Note

In this example, you will develop a basic Windows Azure web role service to get started on the core Windows Azure services platform. In the rest of book, you will learn to develop more advanced services using other components of the Windows Azure platform.

Setting the Objectives

The objectives of this example follow:

  • Understanding the integration of Windows Azure with Visual Studio .NET for developing cloud services

  • Exploring different components of a Windows Azure web role

  • Understanding the Windows Azure development environment

  • Understanding the Windows Azure deployment process

Understanding the Service Architecture

The service architecture consists of a simple Windows Azure web role cloud service developed in the local development environment by the developer and then uploaded to the Windows Azure cloud portal. Figure 2-15 illustrates the service architecture for this example. In Figure 2-21, the developer develops the cloud service on-premise and then deploys it to the Windows Azure cloud platform.

HelloService Architecture

Figure 2.21. HelloService Architecture

Note

A web role application is web application you can build in Windows Azure. The cloud service may consist of one or more applications. I will cover the project types in detail in the next chapter. For now, consider a web role as an ASP.NET web application.

Understanding the Developer Workflow

Figure 2-22 illustrates the developer workflow for developing the Windows Azure web role cloud service.

Developer Workflow

Figure 2.22. Developer Workflow

The developer workflow illustrates the steps required to develop, build, and deploy a simple web role cloud service to the cloud.

I have divided the remainder of this example into two separate sections: "Developing the Service" and "Deploying the Service." In the development section, you will develop and test your service locally in the Windows Azure development fabric. In the deployment section, you will deploy the service as a Windows Azure cloud service.

Developing the Service

The step-by-step walkthrough for the Windows Azure Web cloud service example is as follows:

  1. Start Visual Studio 2008/2010

    Note

    If you have Windows Vista and above, I recommend you right-click Visual Studio in the program menu and select Run as administrator.

  2. Select File

    Developing the Service
  3. Create a new cloud service project by selecting Cloud Services Project, naming it HelloService, and clicking OK, as shown in Figure 2-23.

    Create a web cloud services project

    Figure 2.23. Create a web cloud services project

  4. In the New Cloud Service project window, select the ASP.NET Web Role project type from the Roles section, and add it to the Cloud Service solution section. Name the web role HelloAzureCloud, as shown in Figure 2-24.

    Create a new web role

    Figure 2.24. Create a new web role

    The cloud service project creates an ASP.NET project that can be deployed to the Windows Azure cloud. Another type of cloud service template available is the worker role service. The worker role is a background process analogous to a windows service on your personal computer. In the next chapter, you will study each of these Windows Azure roles in detail.

  5. Visual Studio creates a new solution consisting of two projects as shown in Figure 2-25.

Cloud services solution

Figure 2.25. Cloud services solution

The HelloService project is the new cloud services project containing configuration and metadata of the Windows Azure cloud service and reference to the web role project. The Roles folder holds references to all the roles in the cloud service. The HelloAzureCloud project is the ASP.NET web application, which is called a web role in context of the cloud service. On its own, HelloAzureCloud is a regular ASP.NET web application.

The ServiceConfiguration.cscfg file is the configuration file of the cloud service. It contains configuration settings for the service. There are two main sections under the Role element—Instances and ConfigurationSettings, as shown in Listing 2-1.

Example 2.1. ServiceConfiguration.cscfg

<?xml version="1.0"?>
<ServiceConfiguration serviceName="Ch2Solution" xmlns=
"http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
  <Role name="HelloAzureCloud">
    <Instances count="1" />
    <ConfigurationSettings>
      <Setting name="DiagnosticsConnectionString"
value="UseDevelopmentStorage=true" />
    </ConfigurationSettings>
  </Role>
</ServiceConfiguration>

The default configuration setting includes a DiagnosticsConnectionString for instrumentation and logging. For the sake of simplicity, let's not change the default values in the ServiceConfiguration.csfg. The main difference between web.config and ServiceConfiguration.csfg is that Web.config is application specific and ServiceConfiguration.csfg is service specific across multiple instances and roles. The contents of the ServiceConfiguration.csfg can be changed dynamically from the configure section of the deployed cloud service in Windows Azure developer portal.

The ServiceDefinition.csdef contains the metadata information about the service for the Windows Azure Fabric as shown in Listing 2-2.

Example 2.2. ServiceDefinition.csdef

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="Ch2Solution" xmlns="http://schemas.
microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
  <WebRole name="HelloAzureCloud">
    <InputEndpoints>
      <InputEndpoint name="HttpIn" protocol="http" port="80" />
    </InputEndpoints>
    <ConfigurationSettings>
      <Setting name="DiagnosticsConnectionString" />
    </ConfigurationSettings>
  </WebRole>
</ServiceDefinition>

The file contains information like HTTP input endpoints for the service and configuration information that will apply to all the instances of roles launched by Windows Azure. Next, we're going to set up the web controls for the service.

  1. Open Default.aspx in Design mode, and add ASP.NET web controls shown in Listing 2-3.

    Example 2.3. Default.aspx Controls

    <asp:Button ID="btnWhere" runat="server" onclick="btnWhere_Click"
    Text="Where are you?" />
    <br />
    <br />
    <asp:Label ID="lblLocation" runat="server" Font-Bold="True" Font-Size="X-Large"
    ForeColor="Black"></asp:Label>

    Figure 2-26 illustrates the Default.aspx page after adding the ASP.NET Web Controls.

    Default.aspx Controls

    Figure 2.26. Default.aspx Controls

  2. Double-Click btnWhere to open its Click event handler, btnWhere_Click. In the btnWhere_Click function, set the Text property of lblLocation as shown in Listing 2-4. In Listing 2-4, the lblLocation.Text property is set to a static text appended with the server machine name and the host address of the requester.

    Example 2.4. Code Snippet for btnWhere.Click

    protected void btnWhere_Click(object sender, EventArgs e)
    {
               lblLocation.Text = String.Format
    ("I am on Cloud {0}!!. Where are you? {1}",
    HttpContext.Current.Server.MachineName,
    Request.UserHostAddress);
    }
  3. Build the Solution and then right-click Debug

    Code Snippet for btnWhere.Click
    Initialize Development Fabric

    Figure 2.27. Initialize Development Fabric

    Warning

    The development fabric depends on SQL Server. If your SQL Server Express instance is not running, the Development Fabric will not initialize and produce an error message indicating the SQL Server instance could not be found. To fix the error, go to Start

    Initialize Development Fabric
  4. The Default.aspx page from the Web Application is loaded as shown in Figure 2-28. Click the Where Are You? button to interact with the service.

    Run Default.aspx

    Figure 2.28. Run Default.aspx

  5. Open Start

    Run Default.aspx
    Development fabric

    Figure 2.29. Development fabric

    Alternatively, you could start the development fabric by right-clicking the development fabric system tray icon, as shown in figure 2-30.

    System tray development fabric

    Figure 2.30. System tray development fabric

  6. Observe instance 0 under the web role tree node in Figure 2-29. This is the web role instance that is running the ASP.NET web application. The ASP.NET web application is launched in the development fabric with one instance.

  7. Stop the debugging, and open ServiceConfiguration.cscfg file from Solution Explorer. In the Instances node, change the value of the count attribute to 2, as shown in Listing 2-5.

    Example 2.5. Change Instances

    <?xml version="1.0"?>
    <ServiceConfiguration serviceName="HelloService"
    xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
      <Role name="HelloAzureCloud">
        <Instances count="2" />
        <ConfigurationSettings>
        </ConfigurationSettings>
      </Role>
    </ServiceConfiguration>
  8. Run the service again and go to the development fabric application. You will observe, as shown in Figure 2-31, that the development fabric now started two instances of the ASP.NET application as configured in the ServiceConfiguration.cscfg file.

Development Fabric with two instances

Figure 2.31. Development Fabric with two instances

You just started two instances of the same application by just adjusting the Instances count in the ServiceConfiguration.cscfg file. This is a very powerful feature, because it lets you scale the service based on demand, without any infrastructure investments like servers and load-balancers. The Windows Azure Fabric abstracts the infrastructure intricacies from service scalability.

Deploying the Service

So, you have developed and tested your Windows Azure cloud service in the local development fabric. Now, you are ready to deploy the service in the Windows Azure cloud. To do so, you will need to open an account with Windows Azure. In this section, I will show the deployment using my own account, but you should be able to configure the same application using your account details.

  1. Go to Visual Studio

  2. Right-click the HelloService Project, and select Publish as shown in Figure 2-32.

    Publish HelloService

    Figure 2.32. Publish HelloService

    The Publish action compiles and packages the cloud service into a service package to be deployed to Windows Azure. The package contains all the service components and dependencies required by Windows Azure to run the service in the cloud. For the HelloAzureCloud service, Visual Studio .NET creates a HelloAzureCloud.cspkg file and a ServiceConfiguration.cscfg file. The ServiceConfiguration.cscfg file contains the configuration information for the service instance.

    After the publish process is complete, Visual Studio launches a browser window pointing to the Windows Azure developer portal and a Windows Explorer window pointing to the directory containing the service package files, as shown in Figure 2-33.

    Published package files

    Figure 2.33. Published package files

  3. Before navigating to the Windows Azure developer portal, you will be asked to enter your LiveID and password. Enter the same LiveID and password that is associated with the Windows Azure developer portal.

  4. On the Windows Azure developer portal, go to the service management page of the desired project, and click the New Service link to go to the Project Types Page.

    Tip

    Take a moment to read the description of the Hosted Services project type, which is used for deploying Windows Azure services.

  5. Select the Hosted Services service type as shown in Figure 2-34.

    Hosted services project

    Figure 2.34. Hosted services project

  6. On the Service Properties page, type HelloWindowsAzure as the Project Label and add a Project Description, as shown in Figure 2-35. Then, click Next.

    Adding a project label and description

    Figure 2.35. Adding a project label and description

  7. On the Hosted Service page, you specify the hosted service URL of the service. Note that you can only enter a globally unique subdomain service name. The domain name cloudapp.net is constant and cannot be changed. So, your URL http://[servicename].cloudapp.net should be globally unique. You can test the availability of the name by entering your preferred name and then clicking Check Availability button as shown in Figure 2-36. I named the service proazure, and fortunately it was available, but you can choose any name you like as long as it satisfies the URL naming conventions.

    Choosing a hosted service name

    Figure 2.36. Choosing a hosted service name

  8. Click Next to create the service. You will be automatically taken to the service management page, which contains two deployment options, Staging and Production, as shown in Figure 2-37.

    The HelloAzureWorld project page

    Figure 2.37. The HelloAzureWorld project page

  9. In the staging environment, you will typically test the service for production readiness. After testing the service, you can then synchronize it with the production environment. To deploy the service in the staging environment, click the Deploy button in the Staging section of the page.

  10. On the Staging Deployment page, shown in Figure 2-38, browse to the App package that was created when you published the Hello Azure Cloud solution in Visual Studio.

    Deploy App Package

    Figure 2.38. Deploy App Package

  11. Next, browse to the ServiceConfiguration.cscfg file, as shown in Figure 2-39, that was create when you published the Hello Azure Cloud solution in Visual Studio. Typically, it is in the same directory (i.e., binDebugPublish) as the cloud package file in the previous step.

    Deploy Configuration Settings

    Figure 2.39. Deploy Configuration Settings

    Note

    The ServiceConfiguration.cscfg file defines the roles, instances, and configuration information for the cloud service.

  12. Give the deployment a label and click Deploy to deploy the service in the staging environment

The service package is deployed to the staging environment. During the deployment, Windows Azure extracts all the assemblies and files from the package and also reads the service configuration file to keep the package ready to run. When the deployment of the package completes, the staging cube changes its color from gray to light blue. If there is some problem in the package or any errors in the ServiceConfiguration.cscfg file, the deployment may fail changing the cube color to red.

Service package deployed

Figure 2.40. Service package deployed

  1. Once the service is deployed to staging, you have the following options: update, run, configure, delete, or promote to production using the sync button. Click the Configure option to go to the Service Tuning page shown in Figure 2-41.

    Service tuning page

    Figure 2.41. Service tuning page

    On the Service Tuning page, you can edit the service configuration, and thus the number of instances. For the purpose of this example, we will keep the service configuration unchanged with two instances.

  2. Go back to the Service Details page, and click the Run button. When you click the Run button, Windows Azure creates virtual machine instances for each of the role mentioned in the service configuration file. In Figure 2-42, note that there are two allocated instances for the web role because in the service configuration file, you had specified two instances. Once the instances are allocated, the service is deployed across these instances and made available for running.

    Staging allocated instances

    Figure 2.42. Staging allocated instances

When you click the Run button, web role state changes from Allocated to Initializing, and the Run button changes to Suspend button. Initialization may take a few minutes for Windows Azure to configure virtual machines and deploy the service to them. Once the service is initialized, the web role state changes to Started as shown in the Figure 2-43.

Started Staging Application

Figure 2.43. Started Staging Application

Now, you can test your service:

  1. To test the service, click on the Website URL in the Staging section of the project. The Website URL in the Staging section is a temporary URL generated for testing the service. Hello Azure Cloud service starts in a new browser window, as shown in Figure 2-44.

    Hello Azure Cloud in Staging

    Figure 2.44. Hello Azure Cloud in Staging

  2. Even though the Staging environment is for testing, it is still a cloud environment. So, you can compare the testing results with the service deployed in the development fabric. If you are fine with the results of the service testing in the staging environment, you can move the service to production by clicking the Sync button between the Staging and the Production environment. Click the Sync button to promote the service to Production.

    When the service is deployed in production environment successfully, its web role status is set to Started, as shown in Figure 2-45.

    Deployed to production

    Figure 2.45. Deployed to production

  3. In the production environment, note that the Web Site URL is http://proazure.cloudapp.net. The proazure is the subdomain name I chose for the cloud service earlier.

  4. Click the Website URL in the production environment to launch the Hello Azure Cloud service. Congratulations! You are now running the Hello Azure cloud service in Windows Azure Production environment.

You successfully developed, tested, and deployed your first Windows Azure cloud service without purchasing any server or load-balancer hardware.

Example Summary

In this example, you saw how easily an ASP.NET web application can be developed, tested, and deployed to the Windows Azure cloud as a cloud service. You learned to use Visual Studio .NET tools for developing Windows Azure cloud service. You also saw how easy it is to start multiple instances of the same web role application to enhance availability and scalability. Imagine the efforts it would require to create a multi-instance ASP.NET application across multiple machines in your local or an enterprise environment. The key idea to take away from this example is how Windows Azure abstracts the hardware and software complexities of deploying and scaling cloud services in a production environment. The intricacies involved in commissioning servers, network switches, load balancers, and network connectivity are abstracted from application developers. With just a few mouse clicks and XML settings, you can increase or decrease the number of role instances in Windows Azure.

The simplicity of the ASP.NET web application was on purpose to keep the overall solution simple and take you through the entire life cycle of creating Windows Azure cloud service. You can enhance this service by adding more complex features like AJAX and external Web Service Access.

Summary

In this chapter, I gave you an overview of Microsoft's Windows Azure platform for developing cloud applications. You learned the different services offered by the Windows Azure platform and the capabilities of each service. You also saw some basic Windows Azure scenarios for building cloud services.

After that, I gave you an overview of the Windows Azure developer portal for managing Windows Azure, SQL Azure and AppFabric projects. . Finally, you acquired the skills for developing and deploying a Windows Azure cloud service in this chapter's example. The objective of this chapter was to give you a high-level overview of the Windows Azure platform and to get you started with a simple cloud service. In the next chapter, you will learn details about the Windows Azure platform and its components.

Bibliography

Gartner Research. (n.d.). Gartner Identifies Top Ten Disruptive Technologies for 2008 to 2012. Retrieved from Gartner Newsroom: http://www.gartner.com/it/page.jsp?id=681107

Microsoft Corporation. (n.d.). Windows Azure. Retrieved from Windows Azure platform: http://www.azure.com

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.37.136