Avoid Hostname Collisions With Specialized ScaleSets in Azure Devops

Viewed 101

I created a Scale Set within Azure from a specialized Windows 10 image with some custom software stack installed.

When I try to run pipeline jobs on this, all seem to work fine until suddenly the agent gets killed as unhealthy by Azure Devops. While I tried several things out, I observed, that this arbitrary kills are somehow correlated to running a second job on the scale set. My guess is, that Azure Devops can't handle multiple agents with the same computer name, which is - by default - the case when I create a ScaleSet from a specialized Azure VM image.

Is there any workaround or does Azure Devops only supports ScaleSets from generalized VMs? I actually tried to change the hostname with a custom script extension to the VMSS, but I didn't get it to work.

1 Answers

As @JohnHanley mentioned, you will need to run the sysprep command before imaging the VM. You can use the non-generalized image, but as you noted, it also contains the machine name and doesn't apply the prefix.

As the last step before you stop the VM and image it, run this in PowerShell

$sysprepPath = $env:windir + "\system32\sysprep\sysprep.exe"
Start-Process -FilePath $sysprepPath -ArgumentList "/generalize /oobe /quit /quiet" -Verb RunAs -Wait  
Related