First of all setup your environment by following next instruction Chef-development-environment-and-VSTS-account-setup
When your environment is ready you need to create a new cookbook which will install build tools and a VSTS build agent. You can use example cookbook as a reference.
git clone https://github.com/ivadim/windows-build-server-cookbook
If needed change recipes to your needs. And then upload the cookbook to the chef server using command
chef exec berks upload
Example cookbook uses VSTS credentials through Chef Data Bags.
To create a new data bag with appropriate data please use a next command
knife data bag create users vsts
And when you are asked input next json and save a data bag (replace url, user and token with appropriate values)
{
"id": "vsts",
"vsts_url": "YourVSTSAccount.visualstudio.com",
"vsts_user": "YourVSTSUser",
"vsts_token": "Your_PAT",
}
Now everything is ready to bootstrap a first VSTS build agent using Chef. To do this just run a command
knife azure server create --azure-dns-name w81build --azure-vm-size Medium -I 03f55de797f546a1b29d1b8d66be687a__VS-2015-Ent-AzureSDK-2.8-Cordova-Win8.1-N-x64 --azure-service-location 'West US' --winrm-user USERNAME --winrm-password PASSWORD -r 'recipe[vsts_build_agent_wrapper]'
The command creates a 'Medium' 'w81build' node from a "VS-2015-Ent-AzureSDK-2.8-Cordova-Win8.1-N-x64" template in a 'West US' region. In most cases it's prefer to use template which already contains Visual Studio installation inside.
Re-run the command with a different dns name will scale your build agents number.