How it works…
To trigger the maintenance schedule in an ad hoc manner, right click the agent pool, from the context menu select queue agent maintenance. When you trigger agent pool maintenance, this queues a new build job, the results of which are published in the build Maintenance history. As per the settings configured, the job only takes the specified percentage of agents out for maintenance, so the pool can still be used for builds and releases:

Since azure-pipeline-agent is open source on GitHub, you can see the code of the product. The RunMaintenanceOperation function in the BuildDirectoryManager class (https://github.com/Microsoft/azure-pipeline-agent/blob/f9e5bb7337fb51ace995cafeeaa8665cad638a84/src/Agent.Worker/Build/BuildDirectoryManager.cs ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access