Forum Discussion
arshadbadarkhan
Aug 27, 2023Copper Contributor
How to create an Azure VMSS with configs Microsoft Hosted Agent
Based on this article here
https://github.com/actions/runner-images/blob/main/README.md
I I've successfully created a VHD. But after this i would like to create a VMSS which would be connected to Azure Agent pool.
The files created are creating a osprofile shown below
"image": {
"uri": "https://msftazureblobgstore.blob.core.windows.net/system/Microsoft.Compute/Images/images/packer-osDisk.cfd5eba0-ac4c-4a33-b1eb-4e7f960387a3.vhd"
},
"vhd": {
"uri": "https://msftazureblobgstore.blob.core.windows.net/vmcontainerec417fa8-1f52-46e1-ab32-0e07c37e8b13/osDisk.ec417fa8-1f52-46e1-ab32-0e07c37e8b13.vhd"
},
1 Reply
Take this:
- Upload Your VHD to Azure Storage
Make sure the VHD is in a standard storage account and is accessible for VM creation.
- Create a Managed Image from the VHD
Use Azure CLI or Portal to create a managed image:
az image create \ --resource-group <your-resource-group> \ --name myRunnerImage \ --os-type Linux|Windows \ --source https://<your-storage-account>.blob.core.windows.net/<container>/<your-vhd>.vhd- Create VMSS from the Managed Image
az vmss create \ --resource-group <your-resource-group> \ --name myRunnerVMSS \ --image myRunnerImage \ --upgrade-policy-mode automatic \ --admin-username azureuser \ --generate-ssh-keys \ --instance-count 2 \ --vm-sku Standard_DS2_v2Make sure to configure networking, scaling, and diagnostics as needed.
- Install Azure Pipelines Agent on Startup
Use a custom script extension or cloud-init to install and configure the Azure Pipelines agent on each VM instance:
#!/bin/bash mkdir myagent && cd myagent curl -O https://vstsagentpackage.azureedge.net/agent/3.225.0/vsts-agent-linux-x64-3.225.0.tar.gz tar zxvf vsts-agent-linux-x64-3.225.0.tar.gz ./config.sh --unattended --url https://dev.azure.com/<your-org> \ --auth pat --token <your-PAT> --pool <your-agent-pool> --acceptTeeEula ./svc.sh install ./svc.sh startFor Windows, use PowerShell and the corresponding agent package.