"Installing extensions on virtual machine..." does not complete on Azure VM

When creating a VM you may see that although provisioning completes successfully and the VM reaches the Running state, Installing extensions on virtual machine... does not complete.

This may occur if internet name resolution is not working in the VM, which can be a result of invalid DNS settings on a virtual network or the DNS server itself not resolving internet addresses. Internet name resolution is necessary for the VM agent to download the VM agent extension files from Azure storage as well as to report VM health.

Note that the VM may be accessible (for example via RDP with a remote desktop connection) because provisioning has completed successfully, but the VM agent has not been able to install extensions (for example, the BGInfo extension that is installed by default on Windows VMs to display VM details on the desktop background wallpaper).

When viewing the GuestAgentStatus with Azure PowerShell, you may see GuestAgentVersion is Unknown and Status is NotReady.

(Get-AzureVM -ServiceName cljun18ws12r2a -Name cljun18ws12r2a).GuestAgentStatus | Format-List GuestAgentVersion,Status

GuestAgentVersion: Unknown
Status : NotReady

Looking at the C:\WindowsAzure\Logs\WaAppAgent.log file in the VM may show the following as evidence of the name resolution issue:

Writing the aggregate status file to blob storage failed with error: The remote name could not be resolved: '<storageaccountname>.blob.core.windows.net'

If the VM was deployed into a virtual network, check the DNS settings on the virtual network to make sure the DNS servers you are specifying are correct and able to provide name resolution. You can also specify a public DNS service as a test to confirm if name resolution is the issue.

If the VM was not deployed to a virtual network, the VM will be given DNS settings from Azure's internal DNS service. In that scenario it is unlikely that the extensions would fail to install for this reason.