I have a Win 10 Pro specialized image in a Shared Image Gallery I'm using as a base for a Scale Set. Everything works well except all the VM's Win computer name are the same which confuses the server app I'm using.
How do I configure a Scale Set to auto set the computer (not resource) name of each VM?
When creating a Scale Set, you only provide the computer name of the Scale Set itself. Each instance will have a base-36 computer name based on the Scale Set name provided.
You also need to consider that scaling Scale Sets work with sysprepped Images. If you're seeing the same name for each instance, it's definitely because of the specialised image you're using. Even when using specialised images with normal Virtual Machines, Azure recommends to immediately login to the subsequent VMs and change the computer name to avoid issues.
I suspect the same thing to be happening with VMSS - in fact I'm surprised Azure does not mention this in any of the documentation about using specialised images with Scale Sets.
If it's not possible for you to sysprep/generalise your image, consider the following:
Setup an Azure Private DNS and link it with your VNET with auto-registration enabled.
Have a PowerShell script that runs at start-up on your base image, that will:
(a) Use Az Cli to query the Azure Private DNS and retrieve existing entries (previous Scale Sets instances).
(b) Generate a new computer name based on a predefined logic.
(c) Assign this new computer name to the Scale Set and restart the machine.
Some background information as to why this is happening:
Computer names (NetBios name) in Azure rely on Azure's internal DNS (internal.cloudapp.net) to resolve to each machine. Only one machine with that name can be registered in the cloudapp DNS. If new machines are created, with the same computer name, the old one will be unregistered and the new one's IP will take over the DNS entry.
Read more: Considerations when using specialised images