Azure Pipelines deploy from multiple projects to same environment

There is a problem in Azure Pipelines when trying to deploy to the same target environment from multiple Azure DevOps projects (within the same organization). Even though Azure DevOps allows provisioning a single “deployment pool” to multiple projects, you still need to install one Azure Agent for each project on the same target machine.

The problem here is that the generated script (which you need to copy to the clipboard and run in an administrator PowerShell on the target machine) generates a conflict on the generated Windows service name. This will not only fail during installation of the 2nd agent on the target machine, it will also break an already running agent on the same machine.

As a workaround you need to patch the --agent $env:COMPUTERNAME part of the generated script, e.g. by appending the name of the 2nd project. Example:

--agent $env:COMPUTERNAME-MyOtherProject

See Azure DevOps: How to manage VM agents when multiple projects deploy to the same virtual machine (Stack Overflow) for more details.

Leave a comment