Persist Azure Linux VM’s hostname

Persist Azure Linux virtual machine’s hostname

To persist Azure Linux virtual machine’s hostname permanently for an Azure Linux Virtual Machine, you need to ensure that, you have an Azure Linux agent installed in this machine. To install WA Linux Agent in your virtual machine, please refer the link

Once the WA Linux Agent or WAAGENT is installed in your machine, you may need to modify the WAAGENT configuration to monitor hostname changes and update the network. To save or persist your hostname permanently, edit the file /etc/waagent.conf and modify the below line,


vi /etc/waagent.conf

Once done, please proceed to restart the WAAGENT service.

For Ubuntu,please execute the below command,

sudo service walinuxagent restart

For CoreOS, please execute the command,

sudo systemctl restart waagent

If the above steps does not work, you may need to try to install the service by executing the below command,

sudo waagent -install

Now you can change the hostname and it will be updated, both locally and and also at the Azure Portal.

You can execute the below command to change your machine’s hostname.

sudo hostname

The command to change the hostname is mentioned in the doc –

Even after executing the above steps, if the hostname change is not persisting, you may need to edit the file /var/lib/waagent/ovf-env.xml and update the hostname.

viĀ /var/lib/waagent/ovf-env.xml

Then look for the below line and change your hostname.


Sample File is pasted below ,





Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.