You can download the ARM template from here.

Now login to<your project> and upload the following file to the Repos-

  1. azuredeploy.json
  2. azuredeploy.parameters.json
  3. InstallVSTSAgent.ps1


>>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

-vmName "$(vmName)"  -vmAdminUserName "$(vmAdminUserName)"  -vmAdminPassword "$(vmAdminPassword)" -VSTSAccount "$(VSTSAccount)" -PersonalAccessToken "$(PersonalAccessToken)" -poolName "$(poolName)" -virtualNetworkNewOrExisting  "$(virtualNetworkNewOrExisting)" -existingVirtualNetworkName "$(existingVirtualNetworkName)" -existingSubnetName "$(existingSubnetName)" -existingVirtualNetworkResourceGroupName "$(existingVirtualNetworkResourceGroupName)" -vmSize "$(vmSize)" -enableAutologon "$(enableAutologon)"


>>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-