Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Set Up a Private Agent in Visual Studio Team Services

DZone's Guide to

How to Set Up a Private Agent in Visual Studio Team Services

Learn how to install and set up a private agent to build and deploy your project with Visual Studio Team Services in this tutorial.

· DevOps Zone ·
Free Resource

Do you need to strengthen the security of the mobile apps you build? Discover more than 50 secure mobile development coding practices to make your apps more secure.

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

In this tutorial, we'll  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 set up our dedicated agent, and that's the topic of this post.

1. Set Up the Agent Machine

The first step we need to do is to set up the machine where we'll install the VS agent. By this, I mean we need to install 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 into the Agent Pools section of VSTS from the browser in the machine where we want to install the agent.

From here, we click the Download Agent button.

We choose our operating system and then click download.

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.

3. Install the Agent

Now we run the config bat file.

The installation procedure asks us our server URL of VSTS.

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.

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.

Here, 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 simplicity, we set "All Scopes," but we prefer to give the minimum set of functionalities for our production/business purposes.

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.

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

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.

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

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

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:

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

TL; DR

The installation of a private agent is quick and simple. This enables 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.

Check out tips for blazing the way from agile to DevSecOps with security built into your mobile app toolchain.

Topics:
devops ,visual studio ,vsts ,deployment

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}