You can download the ARM template from here.
Now login to https://dev.azure.com/<your project> and upload the following file to the Repos-
>>You have Agent pool created. The build agent will be added to this Agent pool.
>>Make sure InstallVSTSAgent.ps1 is uploaded to blob storage and the path added to azuredeploy.json file.
>> Now go to Pipelines–>Builds –> New Pipeline (select classic editor). Select the source, Team Project, Repository and continue
>>On Select a Template –> Start with an empty job
>>Now add a task – Publish Build Artifacts
>>In the task “Publish Artifact:drop“, change the “Path to Publish” to point to template folder
>>Save & queue to generate the build.
>>Once build is completed. On Summary tab, you can see the templates are published in drop artifact.
>>Now go to Pipelines–>Releases–>New Pipeline. Select empty job template. Select Add Artifacts and provide the values
>>Then add a stage to create the Windows build agent. Add a task Azure Resource group deployment and provide subscription (authorize it), resource group, location, template, “Override template parameters” etc and save.
“Override template parameters”
>>Create these parameters and assign values in Variables tab.
>>Create release to provision the VM and build agent.
>>Once completed you will see the VM and the agent in the pool as below-