Advanced Web and Worker Roles
Overview

Collapse All Expand All Language Filter: All Language Filter: Multiple Language Filter: Visual Basic Language Filter: C#

Visual Basic Usage
C#

When Windows Azure was first released, there were a few, but significant restrictions in the programming model. Things like Full Trust, Administrative Access, and the full IIS feature-set were initially restricted for security reasons. This impacted the types of applications that could be created in Windows Azure because even small changes to things like configuration settings were often blocked by lack of administrative control over the VM Instances. Over time, those restrictions were lifted – first Full Trust, and now the ultimate control: Administrative access and Full IIS support.

With the latest SDK release, you can choose to run your web sites under IIS7, not in Hosted Web Core as in the past, but in full IIS. This means you can use all the facilities of IIS now like custom modules, multiple websites, VDIR support, application pool isolation, and more.

Additionally, you can now choose two different ways to exercise your administrative control. You can bootstrap the machine as an administrator using something called “Startup Tasks” shown in this lab. This temporarily raises your permissions to administrative and allows you perform small setups, update configuration settings, or other bootstrapping tasks. Once completed, your code will run as a normal, unprivileged user. The second method is that you can now configure your role to simply run as an administrator the entire time. In most cases, the Startup Tasks are the right choice as running your role with administrative permissions the entire time has security implications.

This lab introduces these new capabilities that are unlocked in Windows Azure and allow more advanced application scenarios.

# Objectives

In this hands-on lab, you will learn how to:

- Use advanced service model features that enable hosting a Web role in IIS.
- Host multiple sites in a Web role and bind them to the same endpoint using host headers.
- Create virtual applications and map them to selected sites.
- Utilize user virtual directories to share common content between sites.
- Set up the role environment by executing start-up tasks to register a COM.
- Install complex components required by a web role, such as a scripting language's binary files.

Note:
This lab shows advanced features of Web and Worker roles in Windows Azure; it assumes that you have sufficient knowledge of Windows Azure. If you are beginner in Windows Azure, see the Introduction to Windows Azure lab in this training kit first.

# Prerequisites

The following is required to complete this hands-on lab:

- IIS 7 (with ASP.NET, WCF HTTP Activation)
- Microsoft .NET Framework 4.0
- Microsoft Visual Studio 2010
  - Microsoft Visual C++ 2010 (required for Exercise 2 of the lab)
- Windows Azure Tools for Microsoft Visual Studio 1.5
- SQL Server 2005 Express Edition (or later)

# Setup

In order to execute the exercises in this hands-on lab you need to set up your environment.

1. Open a Windows Explorer window and browse to the lab’s Source folder.
2. Double-click the Setup.cmd file in this folder to launch the setup process that will configure your environment and install the Visual Studio code snippets for this lab.
3. If the User Account Control dialog is shown, confirm the action to proceed.

Note:
Make sure you have checked all the dependencies for this lab before running the setup.

# Using the Code Snippets

Throughout the lab document, you will be instructed to insert code blocks. For your convenience, most of that code is provided as Visual Studio Code Snippets, which you can use from within Visual Studio 2010 to avoid having to add it manually.

If you are not familiar with the Visual Studio Code Snippets, and want to learn how to use them, you can refer to the Setup.docx document in the Assets folder of the training kit, which contains a section describing how to use them.

# Exercises

This hands-on lab includes the following exercises:

- Registering Sites, Applications, and Virtual Directories
- Using Start-Up Tasks to Register a COM Component
- Using Start-Up Tasks to Install PHP with the Web Platform Installer

Estimated time to complete this lab: 60 minutes.

Note:
When you first start Visual Studio, you must select one of the predefined settings collections. Every predefined collection is designed to match a particular development style and determines window layouts, editor behavior, IntelliSense code snippets, and dialog box options. The procedures in this lab describe the actions necessary to accomplish a given task in Visual Studio when using the General Development Settings collection. If you choose a different settings collection for your development environment, there may be differences in these procedures that you need to take into account.