1
votes

[https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/pools/get%20agent%20pools?view=azure-devops-rest-6.0]

The above document indicates that Deployment pools should be included. Unfortunately, they are not returned (although all of the "automation" pools are.

So how does one programmatically list, get (by id) and create/update these pools????

enter image description here

UPDATE....

Capturing network traces while viewing /_settings/deploymentpools?view=pool

has revealed that there is a ReST call to _apis/distributedtask/deploymentPools

which displays the proper information. HOWEVER, continued searching of docs.microsoft.com does not provide any information on this rest call.

UPDATE 2: Returned (sanitized) JSON for call Matt recommended:

enter image description here

JSON from _apis/distributedtask/deploymentPools/deploymentPoolsSummary?expands=2&api-version=6.1-preview.1

enter image description here

As can be seen, the two are not equivalent and so far only the call reverse engineered from the UI shows the same information set (including 2 needed fields related to online and offline counts)

2
Can you include some details about what pools you have (shown from UI) vs. what is returned by the API?Matt
It is difficult as the information is largely properietary.... Groups are OK. dev.azure.com/org/proj/_machinegroup?view=MachineGroupView from the UI... But there does not appear to be a documented analog for the underlying Pools (which are at the org level) and found in the UI @ dev.azure.com/org//_settings/deploymentpools?view=pool Substitude in your own org and project and you can see the relevant pages in the UI.David V. Corbin
It helps if you can show something like "Pool A" is visible from the UI but not visible from the API, here is the API call I made to show it. If you have result differences between the API and the UI, it could be because of security on your PAT vs. your UI login. As it stands, the results of the API match with what I have configured in count and value.Matt
@Matt - Please see update... You will get a match on Deployment Groups, but NOT on Pools.David V. Corbin

2 Answers

1
votes

Given this example Pool configuration:

enter image description here

When utilizing the Pool API without any filters using this script:

$AzureDevOpsAuthenicationHeader = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($AzureDevOpsPAT)")) }

$uri = "https://dev.azure.com/{organization}/_apis/distributedtask/pools?api-version=6.0"

Invoke-RestMethod -Method Get -Uri $uri -Headers $AzureDevOpsAuthenicationHeader | 
    Select-Object -ExpandProperty value | 
    Select-Object name, poolType

Returns:

name                            poolType  
----                            --------  
Default                         automation
Hosted                          automation
Hosted VS2017                   automation
Hosted Windows Container        automation
Hosted macOS                    automation
Hosted Ubuntu 1604              automation
Hosted Windows 2019 with VS2019 automation
Hosted macOS High Sierra        automation
Azure Pipelines                 automation

It seems like the default without filters adds an implied filter for automation poolType as you suggested. Adding a filter targeting deployment pools though I think gets the result you are expecting:

$AzureDevOpsAuthenicationHeader = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($AzureDevOpsPAT)")) }

$uri = "https://dev.azure.com/{organization}/_apis/distributedtask/pools?api-version=6.0&poolType=deployment"

Invoke-RestMethod -Method Get -Uri $uri -Headers $AzureDevOpsAuthenicationHeader | 
    Select-Object -ExpandProperty value | 
    Select-Object name, poolType

Returns:

name        poolType  
----        --------  
ExamplePool deployment
1
votes

including 2 needed fields related to online and offline counts

We can use the Rest API to List Deployment Pools, get the deployment status via field onlineAgentsCount and offlineAgentsCount and get pool ID.

API:

https://dev.azure.com/{Org name}/_apis/distributedtask/deploymentPools/deploymentPoolsSummary?expands=2

Result:

enter image description here

And get the deployment pool detail or update deployment pool via this API

API:

https://dev.azure.com/{Org name}/_apis/distributedtask/pools?poolIds={pool ID}&api-version=6.0

Update1

The Microsoft doc does not list all REST APIs, but we can capture these APIs via F12 or fiddler. In addition, you can also try this API, it will also show Deployment pool info.

In addition, you can raise a new suggestion ticket to the user voice, Microsoft Azure DevOps Teams will check it.