VSTS build or release agent on a self hosted machine in Azure or on premise

You can think of many situations where you would like to create a self hosted machine for Visual Studio team services (VSTS). Installing and configuring a self hosted machine requires only a few steps.

Before you begin make sure the system meets the pre-requisites:

  • Windows 10 and Beyond (64-bit): No known system prerequisites at this time.
  • Windows 7 to Windows 8.1, Windows Server 2008 R2 SP1 to Windows Server  : PowerShell 3.0 or higher
  • Visual Studio: Not technically required by the agent, but many build scenarios need Visual Studio.

Besides the system pre-requisites there is also an account pre-requisite:

  • Account with Personal Access Token.

Create a Personal access token

Creating a Personal Access Token (PAT) requires the following steps:

  1. Navigate to the VSTS tenant were you want to add an agent.
  2. In the top bar click on your icon and click on “Security”.

Account options

  1. Within the security window click on Personal Access Token.

Personal Access Token

  1. Click on “Add”  to generate a new personal access token and make sure you select the following scopes:
    • Agent Pools (read, manage)
    • Deployment group (read, manage)

Personal Access Token Creation

  1. Save the generated token.

 

Install VSTS agent

With all the pre-requisites in place we can start with the agent itself.

  1. Logon to the server that will be the self hosted machine.
  2. Navigate to the VSTS tenant were you want to add an agent.
  3. Go to Setting –> Agent Pools  and click on “Create new Pool”

The pool is a logical container for the agents that you add to VSTS. You can name the pool after the company of define another logical name.

 

New Pool

 

  1. Create a folder on the server to install the agent.

It is a good practice to keep the folder naming as short as possible (D:\a or D:\agent).

  1. Download the agent and extract it to the folder you created.

Agent Folder

  1. Open a PowerShell window as administrator and navigate to the created folder.
  2. Run the below command:
.\config.cmd
  1. During the execution you need to fill in specific information about your tenant.

Agent Configuration

 

At the end of the script the agent is started. The installed agent should now be visible within the agent pool in VSTS.

image

One Reply to “VSTS build or release agent on a self hosted machine in Azure or on premise”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.