In Azure DevOps Services
For dynamically assigned pools you'll need to grant the pipeline access to the pool from the pool's configuration instead:

- Navigate to the Project settings
- Expand the Agent Pools blade
- Select the Agent pool you want to authorize
- On the Security tab add the pipeline with the + button
From the docs referenced in the URL that's mentioned in the logs:
Go to the administration experience of the resource. For example, variable groups and secure files are managed in the Library page under Pipelines. Agent pools and service connections are managed in Project settings. Here you can authorize all pipelines to access that resource. This authorization is convenient if you don't have a need to restrict access to a resource - for example, test resources.
In Azure DevOps Server
Unfortunately, this feature hasn't made it into Azure DevOps Server yet (last version checked: 2022.0). I do suspect the REST API exists under the hood.
You could try approving the pipeline by updating the agent pool permissions:
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
Invoke-WebRequest -UseBasicParsing -Uri "https://dev.azure.com/jessehouwing/6484ebc3-af16-4af9-aa66-6b3398db7214/_apis/pipelines/pipelinePermissions/queue/24" `
-Method "PATCH" `
-WebSession $session `
-Headers @{
"method"="PATCH"
"accept"="application/json;api-version=5.1-preview.1;excludeUrls=true;enumsAsNumbers=true;msDateFormat=true;noArrayWrap=true"
"x-vss-reauthenticationaction"="Suppress"
} `
-ContentType "application/json" `
-Body "{`"resource`":{},`"pipelines`":[{`"authorized`":true,`"authorizedBy`":null,`"authorizedOn`":null,`"id`":73}]}"
The id
being passed in is the id
of the pipeline definition.