Getting started with Lab Management (Part 1)


Lab management is a new addition to the Visual Studio family with VS2010. The product uses virtualization to build and manage labs in the dev / test environment. The promise of the product is three fold.

  1. Using virtualization, machine utilization and hardware costs of managing labs will be much better than building out and maintaining physical labs.

  2. Increased productivity of the dev/test team – various surveys indicate that test members spend 30 – 50% of their time in setting up their test bed and getting it ready for testing. The product leverages the virtualization to vastly reduce the cost of this bootstrap. Leveraging the rich snapshot / restore models, it allows you to set up a pristine base environment (group of VMs) and then start your testing from there. When you consider the permutations of configurations typical test teams need to test, this will be a huge productivity enhancer. 

  3. Consistent feedback on the quality of the builds – the lab management solution allows you to configure your daily build system to build the product, deploy the application on an environment and execute tests on them. Effectively, this completely automates the daily BVT (Build Verification Tests) setup and provides a strong feedback on the state of quality of the daily builds.

Lab management also nicely plays along with the other VS2010 value propositions like rich data collection for bugs (snapshot the environment). For a developer, it is easy to debug a bug reported on a particular build (restore to the snapshot of the environment for that build) or to do smoke testing of his changes across various test configurations. For a tester, the environment is also a good starting point for exploratory testing, easily venturing into various corners of the product with the knowledge that a tester could always reach back a well known state.

Enough intro. This blog post series will walk you through the automation of the end-to-end workflow using a simple calculator web service and unit tests for the same. At the end of the post, we would see the automated workflow where triggering a build will build an app, deploy it to a VM, run tests on it and report results.

While this example does not use multiple VMs in an environment, the same experience is applicable for multi-tier app testing as well. We can extend the application under test to cover various topologies (from traditional backend / frontend to software NLB to VMs spanning multiple trust boundaries)


  1. One x64 hypervisor enabled machine with 4GB RAM that can act as hosts for the test VMs, as well as the SCVMM server. Note that SCVMM requires to be installed on a machine joined to domain and needs live connection to the domain for authentication. So this cannot be your roaming laptop.

    1. Note that the server should be running x64 OS

    2. Hardware-assisted virtualization and hardware-assisted data execution protection are enabled in the BIOS (if you changed them now, turn off the power of the machine and restart them). This post explains how to verify these settings in bios.

    3. Hypervisor server role is installed

  2. One x86 machine (2GB RAM) that can run TFS, VS and the build and test controllers for managing distributed build and test.

Representing the host configurations pictorially, you can configure your systems to be in either of the configurations below.



Software downloads:

  1. Visual Studio 2010 Team Foundation Server: here

  2. Visual Studio 2010 Team Agents Beta 2: here

  3. Visual Studio 2010 Ultimate: here

  4. System Center Virtual Machine Manager 2008 R2 RTM: here

  5. VM creator tool from Codeplex: here

  6. Windows Server 2008 R2 vhd: here (only needed if you do not have a server VM for OS VMs)

As part of the walk through we will

  1. Configure SCVMM which is the management hub for virtual machines and the test VM (this post) 
  2. Install and configure TFS, the controllers to manage build / test and lab (Part 2)
  3. Build the application under test in VS (Part 3)
  4. Use the virtual lab we built out to automate the build / deploy and test experience (Part 4)
Install and configure SCVMM Server:

On the hypervisor machine (in my case, install both the SCVMM server and the Administrator console. The lab product uses SCVMM as the hub for driving all the VM related operations.

I have done the default installation. As part of the install, I had VMM install SQL Server Express.


VMM installs a SQL server that requires to be updated with some security patches. Use Windows Update to pick up the latest patches for VMM and SQL Server and reboot the machine after the updates are installed.

Launch the admin console, pair to localhost:8100


Select Add host and add the host machine (the same machine where I am running SCVMM)


Add test VM to the host:

Copy the Win2k8 R2 vhd you downloaded before to the library share and create a VM.Join the VMs to domain, giving it right computer names, and any other typical setup you might want on the VM. (Windows update to pick up the latest patches).

In a single host setup (with 8GB configuration), you can host the test VM and the TFS VM on the same host. In this case, make two copies of the VHD and deploy them to the same host. A future post explains how to build out the test VM (and TFS VM as well if you are configuring in a 8GB setup)

Configure the Test VM:

In our example, we will use the test VM as a web server to host our app and test it via unit tests. So let us make sure that ASP.NET is configured. To keep the walk through simple, we will just install all the web server components. Logon to the test VM, and from a elevated command prompt,

 C:\Users\Administrator> servermanagercmd -install Web-Server -a

Servermanagercmd.exe is deprecated, and is not guaranteed to be supported
in future releases of Windows. We recommend that you use the Windows 
PowerShell cmdlets that are available for Server Manager.

Start Installation...
[Installation] Succeeded: [Web Server (IIS)] IIS Hostable Web Core.
[Installation] Succeeded: [Web Server (IIS)] IIS Management Scripts and Tools.
[Installation] Succeeded: [Web Server (IIS)] IIS Management Console.
[Installation] Succeeded: [Web Server (IIS)] Management Service.
[Installation] Succeeded: [Web Server (IIS)] FTP Service.
[Installation] Succeeded: [Web Server (IIS)] Custom Logging.
[Installation] Succeeded: [Web Server (IIS)] IIS 6 Metabase Compatibility.
[Installation] Succeeded: [Web Server (IIS)] Static Content.
[Installation] Succeeded: [Web Server (IIS)] Logging Tools.
[Installation] Succeeded: [Web Server (IIS)] Tracing.
[Installation] Succeeded: [Web Server (IIS)] Request Monitor.
[Installation] Succeeded: [Web Server (IIS)] IP and Domain Restrictions.
[Installation] Succeeded: [Web Server (IIS)] Request Filtering.
[Installation] Succeeded: [Web Server (IIS)] URL Authorization.
[Installation] Succeeded: [Web Server (IIS)] IIS 6 WMI Compatibility.
[Installation] Succeeded: [Web Server (IIS)] Dynamic Content Compression.
[Installation] Succeeded: [Web Server (IIS)] Static Content Compression.
[Installation] Succeeded: [Web Server (IIS)] Windows Authentication.
[Installation] Succeeded: [Web Server (IIS)] Basic Authentication.
[Installation] Succeeded: [Web Server (IIS)] ODBC Logging.
[Installation] Succeeded: [Web Server (IIS)] IIS Client Certificate Mapping Authentication.
[Installation] Succeeded: [Web Server (IIS)] Client Certificate Mapping Authentication.
[Installation] Succeeded: [Web Server (IIS)] Digest Authentication.
[Installation] Succeeded: [Web Server (IIS)] Default Document.
[Installation] Succeeded: [Web Server (IIS)] Directory Browsing.
[Installation] Succeeded: [Web Server (IIS)] ISAPI Filters.
[Installation] Succeeded: [Web Server (IIS)] HTTP Errors.
[Installation] Succeeded: [Web Server (IIS)] HTTP Redirection.
[Installation] Succeeded: [Web Server (IIS)] HTTP Logging.
[Installation] Succeeded: [Web Server (IIS)] ISAPI Extensions.
[Installation] Succeeded: [Web Server (IIS)] Server Side Includes.
[Installation] Succeeded: [Web Server (IIS)] CGI.
[Installation] Succeeded: [Web Server (IIS)] FTP Extensibility.
[Installation] Succeeded: [Web Server (IIS)] IIS 6 Management Console.
[Installation] Succeeded: [Web Server (IIS)] .NET Extensibility.
[Installation] Succeeded: [Web Server (IIS)] WebDAV Publishing.
[Installation] Succeeded: [Web Server (IIS)] IIS 6 Scripting Tools.
[Installation] Succeeded: [Web Server (IIS)] ASP.
[Installation] Succeeded: [Web Server (IIS)] ASP.NET.

Success: Installation succeeded.

Allow the VM to be managed remotely by enabling firewall exception for WMI


The next step will bootstrap the agents (test, build and lab) on the VM to allow the VM to participate in the end to end deployment workflow. As part of the configuration, build agent, test agent and lab agent will be installed and configured on the VM.

On the SCVMM machine, copy the isos of agent, TFS and lab (lab comes from the VMtool that you downloaded from here) to the SCVMM library share

 move VS2010B2TFS1.iso "C:\ProgramData\Virtual Machine Manager Library Files"
move VS2010B2Agent1.iso "C:\ProgramData\Virtual Machine Manager Library Files"
move labmgmt.iso "C:\ProgramData\Virtual Machine Manager Library Files"

Go back to SCVMM Admin console and refresh the library shares and make sure that the new ISOs are visible there.

Now go to the directory where you have extracted the VMTool. Change the Inputfile.xml there to provide the VMMServer, LibraryShare, the admin user name and password for the running test VM and the rest of the information. (If you are using the Win2K8R2 vhds, the admin name is: Administrator, Password is: Pass@word1)

 C:\Users\lmtstlab\Desktop\VMTool> type .\Inputfile.xml 
    <VMAdminUserName>Provide Admin user name for the VM</VMAdminUserName> 
    <VMAdminPassword>Provide password for the admin user on the VM</VMAdminPassword> 

Verify the VM is running and has network connection. Back at the SCVMM host, launch the VMM Powershell as administrator


 Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Windows\system32> set-executionpolicy Unrestricted

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust.
Changing the execution policy might expose you to the security risks described
in the about_Execution_Policies help topic. Do you want to change the execution
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y
PS C:\Windows\system32> cd C:\Users\lmtstlab\Desktop\VMTool
PS C:\Users\lmtstlab\Desktop\VMTool> .\New-TemplateFromVM.ps1 .\InputFile.xml 
-SkipClone -SkipTemplateCreation
                 Connecting to SCVMM Server and initializing state...

At this point the test VM (VaradaB2VM1) is ready to participate as a virtual environment in the lab workflow. Let us store this in the library to be used when creating environments.


Select the default server


and share to save and go.

We now have in the SCVMM library a virtual machine that can be used by the lab software to create test environments. Before you save the VM to library, you could also do any other prerequisite that your system under test might have. In this case, we wanted a web server, and thus we ended up doing nothing more than configuring the web server.

In the next blog in this series, we will work on configuring the VM that will act as the TFS server, the build and test controllers and VS machine.