Azure Start VM operation takes more than 80 mins to complete. Invoked using Go SDK

Tushar Tarkas 26 Reputation points

We have a use case to programmatically start an existing virtual machine and execute disk attach/detach commands on it. While I cannot spell the exact use case of why we are doing it, the sequence of operations is as below.

  1. Power-On an existing VM. Check for it's running status.
  2. Once found running, attach an existing disk to it.
  3. Perform certain operations inside the VM.
  4. Detach the disk.
  5. Power-off the VM.

We are using following GoLang SDK methods to execute these operations. The code is simplified for reading but has internal checks for error conditions.

Source Code

// Power On VM
armcompute.NewVirtualMachinesClient(subscriptionID, azureCred, nil).BeginStart(ctx, resourceGroupName, vmName, nil)
// Check running status
armcompute.NewVirtualMachinesClient(subscriptionID, azureCred, nil).InstanceView(ctx, resourceGroupName, vmName, nil).
VirtualMachineInstanceView.status.code == "PowerState/Running"
// Attach disk
disk := &armcompute.DataDisk{
			Lun:          to.Ptr(lunID),
			CreateOption: &armcompute.PossibleDiskCreateOptionTypesValues()[0], // 0 - attach disk
			ManagedDisk: &armcompute.ManagedDiskParameters{
				ID: to.Ptr(diskID),
			Caching: &armcompute.PossibleCachingTypesValues()[1], // 1 is read only recommended for data disk
		vm.Properties.StorageProfile.DataDisks = append(vm.Properties.StorageProfile.DataDisks, disk)
vmClient := armcompute.NewVirtualMachinesClient(subscriptionID, azureCred, nil)
// Prepare VM object to update
vmParams := armcompute.VirtualMachineUpdate{
		Identity:   vm.Identity,
		Properties: vm.Properties,
		Tags:       vm.Tags,
		Zones:      vm.Zones,
// Update VM with new disk	
vmPoller, err := vmClient.BeginUpdate(ctx, resourceGroupName, vmName, vmParams, nil)
// Poller wait till the time operation completes
resp, err := vmPoller.PollUntilDone(ctx, nil)

Virtual Machine Activity Logs from Azure Console

When viewed in the VM's Activity logs, it shows that the "Start Virtual Machine" Operation takes about 90 mins to complete and after that the "Create or Update Virtual Machine" Operation completes.

Below are the snippets from the Activity Logs for the Start Virtual Machine. This behavior is seen even when the virtual machine is accessible and available within 2-3 mins of power-on action.

Start VM Activity Logs:User's imageUser's image

Notice the correlation id is same for the operations, and the operation started on 12:52:34 & succeeded on 14:23:04

The VM is a Windows 2016 server with machine size B2MS.

The event logs within the Windows operating system shows that the boot process was completed around 12:54 itself. Thus, the VM should be available around that time itself.

The question is, why does the Azure wait for around 90 mins to succeed in the power on operation?

The disk attach operation executes immediately after the power-on completes.

This behavior of Power-On operation is slowing the overall operations a lot. And it is getting reproduced consistently in customer environment.

Any guidance to troubleshoot the issue will be extremely helpful here.

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,738 questions
{count} votes