0

I'm trying to grab the name of the Azure VM scale set from the computer's name. I'm able to get close, but not reliably so. I've found this article which mentions the (vmss name)(base 36 instance id) format which I found to be fairly accurate, although with VMSS names under 9 characters, I seem to get random extra characters added to my computer name which don't show up in Azure.

Ex: (in Azure Portal)

VMSS name = "win10"

Instance ID = 2

Computer name = "win10_2"

Therefore, I'd expect the machine name to be "win10000002", however, whenever I remote into the VM and look at the computer name, it shows "win10bc5n000002", note the extra "bc5n" added into it. Does anyone know why this happens or a way to reliably predict it so I can programmatically remove it when I grab the computer name on the machine? The length of my VMSS names won't be consistent, so I can't reliably split the string to remove the 4 extra chars.

EDIT: here's some screen shots of the Portal vs Computer name: enter image description here enter image description here

Norrec
  • 531
  • 4
  • 17

1 Answers1

3

As you say that there is an unexcepted string "bc5n" in your Windows 10 VM name. But as I test that the computer name just consists of the scale set virtual machine name and a six-length number with the instance ID. The screenshot of the result which I test in the Azure portal here:

enter image description here enter image description here

And I think the random extra characters could be added yourself which you forget.

Update

The result is exactly as you say if the computer name is less than 9 characters. But it's the default setting if you do not change.

You can check in your existing Scale Set template on Azure Portal.

enter image description here

If you want to create an Azure Scale Set with an exact computer name, you can achieve that through the template. And set the property "computerNamePrefix" just with the name you input.

I have tested and the result below:

enter image description here

Charles Xu
  • 29,862
  • 2
  • 22
  • 39
  • Nope, not added by me. I confirmed with multiple separate scale sets. your scale set name is exactly 9 characters, and combined with the 6 digit instance id gives the exact 15 character limit for the computer name. Try a scale set name that is less than 9 characters and it should repro 100% of the time. – Norrec Sep 21 '18 at 15:28
  • @Norrec See my update, it's possible to achieve that which you want. – Charles Xu Sep 25 '18 at 08:48
  • Thanks, that clarifies things a bit. Can this only be set at creation time and only via the template method? I tried creating via the portal and doesn't seem to have that option, and I also tried updating the template on https://resources.azure.com but that errors and says the field cannot be updated – Norrec Sep 25 '18 at 16:20
  • It seems you just can do that at creation time and via the template as I know. Maybe you can try about terraform. But you can not do that on the Azure portal. There is no option for that. – Charles Xu Sep 26 '18 at 00:59