1

I have a scale set with 1 VM. I want to set the hostname of the VM to a static-hostname. I have tried to change the hostname using a custom extension. The hostname is changed, but it is not reachable from other VMs, unless it is rebooted.

Can the hostname be changed and be reachable without a reboot?

Pradeep
  • 1,198
  • 3
  • 12
  • 22

3 Answers3

0

No it cannot. A reboot is required for the changes to take. This is the same if you change the computer name of you local machine. The changes will not be live until the machine is rebooted.

micahmckittrick
  • 1,476
  • 8
  • 11
0

I added the following command and the end of my custom extension script and it worked.

'dhclient'

Pradeep
  • 1,198
  • 3
  • 12
  • 22
0

If you are relying on Azure provided DNS, you can simply set the hostname on the machine. Azure DNS automatically takes the VM hostname and sets matching A records in DNS resolvable within the same virtual network. This means, yes you can change the name of a VM in a scaleset and it will be resolvable from other computers in that vnet. This doesn't require a reboot but may take a couple minutes to reflect.

You can read more here: https://learn.microsoft.com/en-us/azure/virtual-network/virtual-networks-name-resolution-for-vms-and-role-instances#azure-provided-name-resolution

The command is as simple as this:

hostnamectl set-hostname foo

You can do this from within the startup scripts provided to the scaleset, and the hosts will automatically change names after they boot up for the first time. You would need some logic in the script to figure out what to change the name to, though.

giraffesyo
  • 4,860
  • 1
  • 29
  • 39