Section 1: Creating a Worker Role and Test Web Role
In this lab, you will build a Worker Role that returns flight status information. This Worker Role will accept jobs through a queue and return flight status information through e-mail. You will then create a Web Role to test the Worker Role.
In this lab, you will:
You must have the following items to complete this lab:
This lab uses a Windows Live account to send flight status information via e-mail. If you do not have a Windows Live account, then proceed to https://signup.live.com.
This lab uses the Bing API to retrieve flight status information. In order to retrieve the flight information, you will need to have a developer application ID. If you do not have a developer application ID, proceed to http://www.bing.com/developers/createapp.aspx and sign up.
The Windows Azure SDK (included in Windows Azure Tools for Visual Studio) installs a simulation environment on your development machine for testing Azure applications locally before deploying them to the cloud. The simulation environment consists of the development fabric to host web and worker roles, and the development storage which simulates cloud blob, table and queue storage locally.
Development storage uses SQL Server as its underlying storage mechanism, and by default the SDK will attempt to configure it to use SQL Server Express. If you do not have SQL Server Express installed before installing the SDK, or you wish to simply use an existing SQL Server instance to host the development storage database, you must run the dsinit command to select the SQL Server instance where the database will be created.
Please see instructions below for how to run dsinit.
Using dsinit to Configure Development Storage
This Hands-On Lab is comprised of the following exercises:
Estimated Time to complete this lab: 45 minutes
Exercise 1: Creating a Worker Role
In this exercise, you will create a Worker Role that e-mails flight information.
Task 1 – Creating The New Worker Role Project
In this task, you will create the new Worker Role project.
Task 2 – Defining Configuration Values
In this task, you will define the configuration values for the Worker Role. The configuration values establish connections to the storage account where the work queue will be created.
Task 3 – Coding The Worker Role
In this task, you will implement the Worker Role. Communication with the Worker Role will be through a queue.
Exercise 2: Creating a Test Web Role
In this exercise, you will create a simple Web Role to test the Worker Role locally before deploying to Azure.
Task 1 – Creating The New Web Role
In this task, you will add the new Web Role to the existing application.
Task 2 – Initializing the Storage Connection
In this task, you initialize the storage connection to gain access to queue storage.
Task 3 – Implementing The Test Web Role
In this task, you will implement the test Web Role. The Web Role will drop a flight request into the queue for the Worker Role to process.
Task 4 – Building and Testing
In this task, you will test the solution locally.
Worker Roles are used in Azure for handling long-running or resource-intensive processes. Once deployed, you can communicate with Worker Roles either directly using endpoints (TCP, HTTP, HTTPS) or indirectly using queues. This lab communicated with a Worker Role using a queue.