3

I have two questions.

  1. Is there any method to check self hosted agent on Azure VM is busy in running azure pipeline.

  2. and if there is any method available then can we shift that Azure pipeline from self hosted agent to Microsoft Hosted Agent, so that we can use that self hosted agent for other pipeline.

Tabrez Shams
  • 103
  • 2
  • 7

2 Answers2

2

You can use REST API to get list of agents:

GET https://dev.azure.com/{organization}/_apis/distributedtask/pools/{poolId}/agents?api-version=5.1

You will find there:

  • status - whether or not the agent is online.
  • lastCompletedRequest - The last request which was completed by this agent
  • assignedRequest - The request which is currently assigned to this agent

based on this you can easily figure out if your agent is busy or not.

And for your second question. This is not possible at the moment. Please check this two topics:

Please upvote community request to increase a chance of having this implemented!

Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
2

1,You can check the status of self hosted agent directly from Azure Devops UI.

Go the Project Settings--> Agent Pools under Pipelines-->Select the Agent Pool in which the self hosted agent resides--> Click Agents tab of the Agent Pool page--> You will see the current status of each agents. See below screenshot.

enter image description here

2, To shift Azure pipeline from self hosted agent to Microsoft Hosted Agent. Currently you have to manually shift the agent pool/agent from the pipeline definition, so that the pipeline will target a differnt agent pool/agent.

  • To change the agent pool for Classic UI pipeline:

Go the pipeline edit page--> Click Pipeline-->Change the agent pool from the Agent Pool dropdown list. see below screenshot.

enter image description here

Each agent job in the pipeline can select its own agent pool. You can change the agent pool from the agent job's configuration page. see below screenshot.

Noted: the agent pool selected for the Agent job will override the agent pool selected for the Pipeline mentioned in above screenshot.

enter image description here

  • Change agent pool for Yaml pipeline

You need to manually change the pool value in the YAML file. For below example. see document here for more information.

Yaml pipelines also support select agent pool at runtime using runtime parameter. see document here for more information.

pool:
  vmImage: ubuntu-16.04 
Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43
  • 1
    Thanks for the beautiful answer. all those things you mentioned I already know. i want to know any methods which can help in during running pipeline – Tabrez Shams Apr 29 '20 at 11:33