azureazure-devopsdeploymentdevopspipeline

I already have an Azure Devops pipeline agent on my self-hosted Windows server, can I use that agent to register the VM in my environment?


I'm trying to setup a basic Azure Devops pipeline that will listen for commits on a repo then build an ASP.NET Core app and deploy it to a self-hosted Windows IIS server. I have already installed the Devops Pipeline agent on the IIS server and it appears to work as expected. However now I am trying to follow the steps to create an "Environment" and add the server to it in my project and in order to register it as a resource I am provided with a script that appears to be installing yet another identical agent on the machine.

Do I actually need to install another copy of the same agent just to register the server in my environment? Or is it possible to use the existing agent for that purpose?

I searched the Microsoft docs and the internet at large but I couldn't find an answer. I did find something to the effect that it's bad practice to have several Azure agents on a self-hosted server, hence my question.


Solution

  • Do I actually need to install another copy of the same agent just to register the server in my environment?

    It depends on your actual requirements. Currently, you are using a self-hosted agent in Agent Pool. And from the doc you shared, it is related to registering targets in the Deployment Group.

    Here are the differences related to Agent Pool and Deployment Pool:

    If you only have one server machine you are going to deploy to. You can actually using Self-hosted agent in Agent Pool( installing a self-hosted agent on the server machine). You can build and deploy your app using this self-hosted agent in the Agent Pool. But if you have multiple server machines you need to deploy to. You'd better use deployment groups.

    Here is a doc about deployment group: Provision deployment groups

    A deployment group is a logical set of deployment target machines that have agents installed on each one. Deployment groups represent the physical environments; for example, "Dev", "Test", "UAT", and "Production". In effect, a deployment group is just another grouping of agents, much like an agent pool.

    The main difference of Deployment groups and Agent Pools is where they can be used in the azure pipeline.

    Deployment groups can only be used in the Deployment group job in Classic release pipelines.

    For example:

    enter image description here

    Agent pools are available in both the release pipelines and build pipelines, but can be used in normal agent job(not Deployment group job).

    In summary, you can determine whether you need to use Deployment Group based on your actual deployment requirements.

    Or is it possible to use the existing agent for that purpose?

    The answer is NO. Self-hosted agents cannot be shared between Agent Pools and Deployment Groups.

    To registry the targets in the deployment group, you need to copy the registry script and install a new agent on your server.