Basics of TFS Build System and Integrating it With Azure Cloud Services

This document discusses the basics of the TFS build system and guidance as well as a troubleshooting procedure to integrate the build system with Azure cloud services for continuous deployments.


Table of Contents

  • Basics of Build System

    • Builds
    • Build Servers
    • Build Controllers
    • Build Agents
    • Build Definitions
    • Typical Build System Topology

  • Configurations
  • Troubleshooting 

Builds in Azure cloud services

A Build is nothing but the output of a solution. In the case of Azure projects, you generally get the file with a .cspkg extension that means a Cloud Service Package is used for the deployment of your cloud services.

Build Servers

In layman's terms a build server acts as the machine where you put your deployment packages.

Technically speaking, it is the system on which the Team Foundation Server's Build Service is configured and running.

To use Team Foundation Build, you must have at least one build machine. This machine can be a physical machine or a virtual machine.

In the case an Azure deployment, you need to have a build server configured against your project collection in TFS.

For more details on how to install a Build Foundation Service, please refer to this article.

Build Controllers

Build Controllers are the element in the build system that accepts the build requests from any project inside the team project collection. Each build controller is dedicated to a single-team project collection. So there is a one-to-one relationship between a team project collection and a build controller.

The Build controller then forwards the build requests to one or more build agents. This is like passing on the more computational work or processor-intensive work to other systems.

A Build controller follows a workflow to deploy your packages to target systems. You can modify the workflow or have your own workflow associated with the build controller.

Build Agents

Build agents are elements in the build system that does more processor-intensive work. Each build agent is controlled by a single build controller. So there is a one-to-many relationship between a build controller and build agents.

Build Definitions

A Build definition is nothing but the process that the build controller using to deploy your packages to a target site. Using Team Explorer you should be able to create a new build definition where you will need to associate the build controller and define process as well as trigger a point for the definition.

Once the build definition is in place, you will be able to queue new builds using it.

Typical Build System Topology

Typical Build System Topology

Integration of build system with Azure cloud services

Let's not duplicate the contents about integration of TFS build services for continuous deployment on Azure cloud services because there is marvelously neat and clean step-by-step documentation already available on MSDN, so I will simply point you guys to it. Read it, follow it and you are done. It's quite straight forward to implement and you will be ready with your first Team Foundation Server build definition to deploy your builds on your Azure cloud services: Continuous Delivery for Cloud Services in Azure.

Note: In this documentation you will need to follow only Step 1, Step 3 and Step 5.

Troubleshooting

Once you are done with the configurations, everything should work fine but there are a few cases when you will encounter some errors (at least I did).

Error: File cannot be loaded because the execution of scripts is disabled on this system.

Solution

Be sure that you have kept the execution policy as unrestricted on your build machine.

  • Log in to the build machine and open a Windows PowerShell prompt.

  • Type in the command:
    Get-ExecutionPolicy

  • This should return the result as unrestricted.

  • If it is not set to unrestricted then run this command:
    Set-ExecutionPolicy Unrestricted

  • Also make sure that you do it using both Windows PowerShell prompts, x86 and ax64.

Follow this link for more details: File cannot be loaded because the execution of scripts is disabled on this system.

Error: The specified module "Azure" was not loaded because no valid module file was found in any module directory

Solution

  • Open the URL: PublishCloudService.ps1.

  • On the build server open your PowerShell file PublishCloudService.ps1.

  • Find the line:
    Import-Module Azure.

  • Add the following line above Import-Module Azure:
    $env:PSModulePath=$env:PSModulePath+";"+"C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell".
  • Save the file.

Error: Import-AzurePublishSettingsFile: Access to the Azure Subscription file is denied

Solution:

  • Log in to the build machine.

  • Make sure that your subscription XML file (.publishsettings) is not blocked. (Using file properties.)

  • If the error still occurs then download and replace your subscription file. Use this link to download the file: Publish Profile.

Error: Set-AzureDeployment: Could not find file C:\drops\app.publish\ContactManager.Azure.cspkg.

Solution

  • Open and edit your build definition.
  • Go to the process tab.
  • Under the Misc section, check the Package Location.
  • Make sure that you have the correct package name.

Up Next
    Ebook Download
    View all
    Learn
    View all