Wednesday, October 26, 2016

Missing ComputerName Field in Azure (ARM)

Have you noticed that some of your VMs in Azure ARM is missing a ComputerName field? All you get is a dash "-", like:


It turns out that you probably uploaded a non-generalized VHD (aka - it was not sysprepped). In Microsoft terms, this is also known as "specialized" VHD.

According to Microsoft, this is because the "OSProfile" field is missing, which is by design because this is a specialized image. One can only specify the OSProfile field when creating VMs using a generalized image.

Resolution: This is unfortunately a known issue and there is no way around it.

With a VM created from a specialized image the OSProfile field is set using the command "Set-AzureRMVMOperatingSystem". For example, to set it Windows, the following command is run:

Set-AzureRmVMOperatingSystem -VM $vmConfig -Windows

For more information about specialized image and generalized images in Azure:

https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-create-vm-generalized/

https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-create-vm-specialized/

2 comments:

Walter said...

Thanks for posting about this issue. I recently encountered it when creating an ARM VM from classic VHD's. Are there any other problems with having a missing osProfile field? I noticed in other "normal" ARM VM's that the osProfile contains information about WindowsConfiguration.

"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}

iInvent said...

We run into this issue quite frequently. Anything from a misnamed resource (that deviates from our naming standard) to the need to change availability set membership will cause use to try to recreate a VM. The biggest issue this causes for us is now the VM may not participate in receiving secrets from KeyVault, say an X.509 cert for a website. Set-AzureRmVMOperatingSystem does not work for a specialized osDisk. If OSProfile is anything but (null) in the call to New-AzureRmVM, the call fails with "New-AzureRmVm : Parameter 'osProfile' is not allowed."

No viable workaround we have found yet.