With the new upcoming version of TFS, you will have to possibility to have your own TFS instance running on Windows Azure, called “TFS Preview”. One of the cool things about this is the fact that you’re not responsible anymore for the TFS infrastructure. You don’t have to invest in some decent hardware, everything you want is there for your, on Windows Azure.
The one thing you need to have ‘on premise’ is a build server, as TFS Preview does not give you any options to use a cloud-based build server. Which is in fact understandable, because a build server can generate lots of load and needs to be monitored precisely. But, shouldn’t it be cool to have ‘everything’ in the cloud? Well, actually you can: TFS Build Service on Windows Azure using the VM Role
In this post, I’ll take you trough the steps to setup your own build service and host it on Windows Azure.
1. Azure account
Because you will be hosting your build service on Azure, I suppose you already have your an Azure account. If not, you might already have access using your MSDN subscription (there is some good information on this blog post). The next thing you have to do is signup for the VM role beta program. You can do this on windows.azure.com and then select “Beta Programs”.
2. Base VM Role Image setup
The next thing you have to do is create your VM Role Image, which you will use to upload on Windows Azure. In fact, this virtual image will be configured like an on-premise build service. This image contain an operation system (off course) and a TFS 11 build controller with one (or more) build agents.
- To get started, open Hyper-V manager on a Windows 2008 (R2) machine, and select the option to create a new Virtual Machine.
- Follow the wizard, and set the amount of memory to 2048 MB. Also be sure to select the ‘Virtual Network’ connection.
- Create a new virtual disk called “baseimage.vhd” and set the size to 30GB (when you select this size, you can deploy the VM in a “small” role, take a look at the pricing for more info)
- Finish the wizard, boot your new virtual machine and install your operation system (windows 2008R2 for example).
- There is a special requirement for a valid VM Role image. You have to allocate the entire virtual hard disk file to a single partition where you install the operating system. To avoid creating a recovery partition during the installation, follow these steps:
- Choose the Custom (advanced) installation type to select the partition where you will install Windows.
- Press Shift + F10 to open a command prompt during GUI-mode setup.
- At the command prompt, enter the following commands:
- diskpart
- select disk 0
- create partition primary
- exit
- Close the command prompt window.
- Install Windows in the newly created partition.
3. TFS 11 Build Controller
- Next step is to install the TFS build controller on the VM, but do NOT configure it yet. We will configure it when the VM role is online on Windows Azure.
- To do this, run the TFS 11 beta installation (you can download the beta using MSDN or this link.)
- When the installation is finished, close the Configuration screen.
Tip: When you are planning to build more than some ‘basic’ applications, be sure to also install Visual Studio!
4. Windows Azure VM Role Integration Components
The next part is the installation of the VM Role Integration Components. The integration components must be installed on the machine before base image is uploaded to the Azure. The integration components start each time the OS starts. It handles the integration between the role instance and Azure environment. Follow these steps:
- In the Virtual Machine Connection window, in the Media menu, point to DVD Drive and then select Insert Disk. In the Open dialog, browse to the location of the ISO file for the VM Role Integration Components, wavmroleic.iso, and then click Open. The wavmroleic.iso is located at ‘C:\Program Files\Windows Azure SDK\v1.6\iso\’
- In the Operating System Configuration step, enter an Administrator Password, confirm it, and then click Next.
- Follow the wizard and once the installation of the components has finished, you will be prompted to restart the system. Click Yes to continue.
- Wait for the system to restart and log in to the guest machine once again. Now, inside the VM, open the Start menu, type %windir%\system32\sysprep\sysprep.exe and then press Enter to launch the System Preparation Tool. Set the System Cleanup Action to“Enter System Out-of-Box Experience (OOBE)”, check the option labeled Generalize, set the Shutdown Options to Shutdown, and then press OK. This tool will prepare the image by cleaning up various user and machine settings and log files, as well as removing any hardware-dependent information.
- Wait for the system to completely shutdown. Your image is now ready for deployment.
5. Uploading the VM to Windows Azure
Now we have a VM image ready for deployment. Next step is to upload this image. To do this, we will use the ‘csupload‘ command from the Windows Azure Command Prompt. Follow this steps:
- Open the Windows Azure SDK Command Prompt as administrator
- Type the following command to link the context to your current subscription:
- csupload Add-VMImage -Connection “SubscriptionId=[SubscriptionId]; CertificateThumbprint=[ThumbPrint]” -Description “TFS Build Service” -LiteralPath “C:\baseimage.vhd” -Name baseimage.vhd -Location “West-Europe”
- The subscription id can be found on the management portal in the property grid, when you select your subscription.
- The certificate thumbprint is a private certificate that is installed on the local machine and that is linked to the management certificates on the Azure portal. Uou can easily copy the thumbprint from the property grid in the Azure Portal
- Be sure to change the LiteralPath to the location of where your VHD is located.
- The location (data center) needs to be defined where the storage will be created. You can use friendly names like “West-Europe”
- Now the upload will start. The first step in the process is the preparation
- After preparation, it will start uploading. When the upload starts, you can see your new vhd on the Windows Azure portal as ‘Pending’
- Wait for the upload to complete. This can take several hours, depending on the upload speed of your Internet Connection. When finished, you should see:
6. Creating the Service Model
After completing the previous step, you now have a VM image deployed to your Windows Azure account. In this task, we will create a service model and configure it to reference this image.
- In Visual Studio, create a new Windows Azure Project. In the New Windows Azure Project dialog, click OK without adding any roles. You will create a Virtual Machine role in the following steps.
- When the solution is created, right-click the Solution folder and select New Virtual Machine Role. This option is ONLY available when you are in the VM Role beta program. When your request was accepted, you should have received an email with a link to enable the VM Role option in Visual Studio. If you lost this mail, you can use this link (32bit or 64bit), it’s a small change to the Windows Register.
- You should see a the properties of the new VM Role. In the ‘Virtual Hard Disk‘ section, select your Azure subscription and select the the image we have just uploaded
- In the ‘Endpoints’ section of the wizard, add a port for the build-controller. A TFS Build Controller uses 9191
- Save your settings and close the window. Next step is to publish your VMRole and meanwhile enable Remote Desktop. You can do this by right-click on the solution, and select ‘Publish’. In this window, follow the Wizard and enable ‘Remote Desktop’.
- Now you can Publish this solution. You can follow the status of your deployment using the Windows Azure Activity Log screen.
- The roles take the following statuses
- Initializing
- Waiting for host
- Setting up Windows for first use
- Starting Windows
- Starting Traffic
- Ready
- When finished you can see your Hosted Service using the Azure Portal. Now you can also connect to the VM using Remote Desktop. Click on the Remote Desktop icon and log in using your account (defined in the Remote Desktop Setup process).
7. Configure your Build Service
Last step is to configure your brand new Build Service. When you are logged-in on the VM using Remote Desktop, launch the TFS Build Controller configuration.
- Click on “Configure Team Foundation Build Service” and then click the Start Wizard button at the bottom.
- On the Project Collection screen, identify your team project collection/account on the hosted service. You can’t type here so just click the Browse button and add your TFS preview/Hosted TFS account. In my case, I already have a build controller running, but I’ll add another one
- Next step is to configure the Build Service. In my case, I already have a build controller, but I will replace it with a new one (the original one is offline). You can also decide to use this machine as a ‘Scale out’ system for an existing Build Service. This existing one will use this new machine as extra agent capacity.
- In the next step, you can configure which account will run the Build Service. This can be network service, or a specific account within your Active Directory (if you use Azure Connect with AD integration). This depends on the installation type. In my case, I’ll just use the network service.
- In the ‘Advanced‘ section, you can define your hosted TFS Service Service Account. Leave this by default. You can also change/manage this using the Administration section of your Hosted TFS account, in my case:
- Verify and confirm the Configuration Settings
- Configuration completed
- That’s it, now your Build Service is up and running, on Windows Azure. Now you can tweak this by adding some agents,… You can manage the Build Controller using Visual Studio 11 (or 2010) by going to the ‘Builds‘ section of your Team Explorer, and click on ‘Actions‘.
8. Conclusion
Now we have our TFS11 Build Service up and running on Windows Azure. Now you can create Build Definitions and queue builds (a failing build in my case)
Good luck with your Build Service and enjoy it!
Thanks for reading.