azure-pipelines-agent: Multiple agents on same machine - error due to same Windows service name

The Registration script for the VSTS agent that is shown on when adding a new machine to a Deployment Group doesn’t account for adding multiple agents to the same machine. It contains the following line:

.\config.cmd --deploymentgroup --agent $env:COMPUTERNAME --runasservice ...

Where $env:COMPUTERNAME is used to name the VSTS Windows service. However, adding additional agents results in an error because they all try to register a Windows service with the same name.

A fix is:

.\config.cmd --deploymentgroup --agent $env:COMPUTERNAME-$destFolder --runasservice ...

Where the folder name for the agent, such as “A1”, “A2”, “A3” is appended to the computer name when naming the service. That way, you can have multiple services.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 24 (13 by maintainers)

Most upvoted comments

@NickMRamirez sharing deployment groups across team projects is coming in a future update.

@chrisrpatterson In my case, I am installing multiple agents per machine, but each of these agents is in a different team project. So if you were to look at just one of the projects, its Deployment Group would only show one agent and the machine would only be in one Group.

It’s the downside to that you can’t share agents between team projects. If we could do that, we wouldn’t need to install the agent multiple times. As it stands, to deploy Team A and Team B projects, each team must register a different agent.

But in any case, my solution would allow it to support multiple agents. I’ve been using my custom script successfully. If I could find where that script is kept in github, I’d open a pull request.

@cilerler - Sharing of deployment group targets is work in progress. Tentatively it will be available early next year (2018).

I need to deploy 2 sites on 1 machine and hit the same wall 😞 If it will be deployed soon, I won’t try to figure out a workaround.

As a workaround, you can install additional agents on the machine by providing unique agent names in your registration script.