How to setup a Private Agent in Visual Studio Team Services

In the last post about VSTS (Visual Studio Team Services) we setup the foundations for a project.

In this we install a private agent to build and deploy our project.

VSTS provides hosted agents to build and deploy. When we use a hosted agent, Microsoft takes care of the maintenance and upgrades. So for many teams this is the simplest way. Every agent has a set of capabilities that indicate what it can do. Capabilities are name-value pairs that are either automatically discovered by the agent software, in which case they are called system capabilities, or those that you define, in which case they are called user capabilities.
If the hosted agents do not suit our needs we can setup our dedicated agent and that’s the topic of this post.

1. Setup the agent machine

The first step we need to do is to setup the machine where we’ll install the VS agent. With this I mean we need to install all the SDK, libraries, packages, etc that our project needs to build. After that we install the VS agent.

2. Download the VS agent

First we need to go in the Agent Pools section of VSTS from browser in the machine where we want to install the agent.

Immagine

From here we click the Download Agent button.

Immagine

We choose our operating system and then click download.

Immagine

When the download completes we can follow the instructions provided by MS in the same page or we can extract the content of the zip folder with the Windows user interface. We unzip the folder in a dedicated directory, for example C:\vs-agent.

Immagine

3. Install the agent

Now we run the config bat file.

The installation procedure asks us our server URL of VSTS.

Screenshot_5

Then it asks the authentication type to communicate with VSTS. We’ll use a Personal Access Token (PAT). So we simply press enter because it is the default value.

Screenshot_6

Now we need to go back to VSTS to generate a PAT.

From our profile icon in the top-right corner we access the Security section.

1

Where we create a new token. We choose a name, the validity time and the reference account. We specify the authorized scopes, too. In this example for semplicity we set “All Scopes” but we prefer to give the minimum set of functionalities for our production/business purposes.

Screenshot_2

When we click on Create Token, VSTS will show us our token that we must save in a safe place right now because we won’t be able to see it anymore in the future.

Screenshot_3

With the token in our clipboard we ho back to the installation of the agent and right-click with the command prompt to paste the token and press Enter.

Screenshot_7

The agent tries to connect and if the test is OK we need to specify the Agent Pool name where the agent will be inserted. If we want to create a new Agent Pool we go back to VSTS in the Agent Pool section and create a new Pool.

Screenshot_9Screenshot_10

Now we can write the name in the prompt. (MadLab)

Screenshot_8

And now we give our agent a name (VsAgent1).

Screenshot_11

For the other options we’ll always choose the default option by pressing Enter when needed. At the end the process will like something like the following picture.

Screenshot_12

If we go back to VSTS we can see that agent has been recognized with all its capabilities.

Screenshot_13.png

TL; DR

The installation of a private agent is quick and simple. This enable us to avoid the limitations of the hosted agent if our project has particular needs of SDKs, libraries and so on.

For this example I installed the agent into an Azure VM with Windows Server 2016.

7 thoughts on “How to setup a Private Agent in Visual Studio Team Services

  1. In step 1, does “we need to install all the SDK, libraries, packages, etc that our project needs to build” mean that Visual Studio, Node.js, etc. need to be installed on the target machine?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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