How many of us started learning something with the "Hello World" example. We've seen "Hello World" travel from a console application to a GUI. Now it's in the cloud.

History

While small test programs existed since the development of programmable computers, the tradition of using the phrase "Hello world!" as a test message was influenced by an example program in the seminal book The C Programming Language. The example program from that book prints "hello, world" (without capital letters or exclamation mark), and was inherited from a 1974 Bell Laboratories internal memorandum by Brian Kernighan, Programming in C: A Tutorial, which contains the first known version:

main() {

printf("hello, world");

}

I learned programming from this very book so I will use all lower caps with a comma.

Why do you nee dthe Windows Azure SDK?

The Windows Azure SDK provides developers with a local runtime environment for building and testing Windows Azure applications. This environment is known as the development fabric. The Windows Azure Tools for Microsoft Visual Studio provide developer tools for building Windows Azure applications that includes building, debugging, and project setup and configuration.

In the New Project dialog, select Cloud Service from the Visual C# project type.

In the Templates list, select Web Cloud Service. Enter the name "RDCompute" and the solution name "Begin", set the location to C:\DevProjects\Azure\Labs\BuildingWindowsAzureServices\, and ensure Create directory for solution is checked. Click OK to create the project.

Code that got generated

RDCompute

ServiceConfiguration.cscfg

ServiceConfiguration.csdef

Both these files allow you to control how the web roles and worker roles get deployed.

The ServiceDefinition.csdef file contains the metadata needed by the Windows Azure fabric to understand the requirements of your application, such as which roles are used.

It will also contain configuration settings that apply to all instances.

These configuration settings can be read using the Windows Azure API as you will see in a later exercise.

The ServiceConfiguration.cscfg file lets you set the values for the configuration settings and the number of instances to run for each role.

The Roles node in the Cloud Services project enables you to configure what roles the services include (Web, worker or both) as well as which projects are used for these roles.

Adding configuring roles through the Roles node will update the ServiceDefinition.csdef and ServiceConfiguration.cscfg files.

RDCompute_WebRole

Default.aspx

Web.config

NOTE: Notice that IIS creates Web Roles based on the ServiceConfiguration files/

A Web role can be implemented using ASP.NET, WCF, or another .NET Framework technology that works with IIS.

As the figure above shows, Windows Azure provides built-in load balancing to spread requests across Web role instances that are part of the same application.

Worker Role

A Worker role instance, by contrast, cannot accept requests directly from the outside world—it's not allowed to have any incoming network connections, and IIS isn't running in its VM.

Instead, it gets its input from a Web role instance, typically via a queue in Windows Azure storage.

The result of its work can be written to Windows Azure storage or sent to the outside world—outgoing network connections are allowed.

Unlike a Web role instance, which is created to handle an incoming HTTP request and shut down when that request has been processed, a Worker role instance can run indefinitely—it's a batch job.

Befitting this generality, a Worker role can be implemented using any .NET technology with a main() method (subject to the limits of Windows Azure trust, as described below)

Task 2 – Build and Execute the Web Site

In this task, you will modify the default.aspx page, then build and execute the site in the development fabric.

Open the Default.aspx page.

Change the contents of the <title> tag to hello, world. Add the <div> tag Welcome to the world of Cloud Computing, Azure Style

Press F5 to execute the service in Windows Azure. The service will build and then launch the local development fabric. To show the development fabric UI, right-click its icon in the system tray and select Show Development Fabric UI.

TaskBar – Development Fabric

Note the Development Fabric instance shows 1 web role.

That is because that is what our ServiceConfiguration.csfg indicated.

Note: This will show you the roles and ports that were requested and issued. If this is the first instance running, you should see a URL of http://*:80 and an IP Address of 127.0.0.1:80. When you execute a Windows Azure service, it will try to allocate the port specified in the ServiceDefinition.csdef file. If this port is not available, the next available port is used.