Can we change the name of an Azure Virtual Machine in the Azure portal? I am sure we cannot change it via portal, do we have any PowerShell cmdlet to change the virtual machine name??
Note: I am not referring to VM name inside the VM, but the name that is displayed in the Azure Portal.
In this article, you have learned how to rename an Azure virtual machine using PowerShell. We first back up the VM configuration and export it to an (. XML) file for later reference, then delete a VM, package a new VM configuration, attach all disks and network profile, and finally creating the new VM.
Set the hostname with cloud-init By default, the hostname is the same as the VM name when you create a new virtual machine in Azure. To run a cloud-init script to change this default hostname when you create a VM in Azure with az vm create, specify the cloud-init file with the --custom-data switch.
You can download the service configuration file for a deployed service from the Configure blade of the service in the Azure portal. You can then look for the vmName attribute for the Role name element to see the host name. Keep in mind that this host name is used as a base for the host name of each role instance.
Resource names for virtual machines are immutable. So, you will need to redeploy your virtual machine.
Best way to do this is to delete the current one, maintaining the disks, and then create a new one with the correct name pointing to those disks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With