Azure Windows VM Deprovision not working

18 views
Skip to first unread message

Ádám Takács

unread,
May 20, 2020, 2:40:39 AM5/20/20
to Packer
Hi.

I am unable to properly create Windows images on Azure, because the deprovision step is stuck in an infinite loop.

The error:

1589606815,,ui,error,==> azure-arm: Get-Service : Cannot find any service with service name 'WindowsAzureTelemetryService'. 

1589606815,,ui,error,==> azure-arm: At C:\Windows\Temp\script-5ebf7849-741e-b3ca-88f5-82f1f7d320aa.ps1:3 char:11 

1589606815,,ui,error,==> azure-arm: + while ((Get-Service WindowsAzureTelemetryService).Status -ne 'Runni ... 



The deprovision step (as you can see in the documentation):
{
  "provisioners": [
    {
      "type": "powershell",
      "inline": [
        " # NOTE: the following *3* lines are only needed if the you have installed the Guest Agent.",
        "  while ((Get-Service RdAgent).Status -ne 'Running') { Start-Sleep -s 5 }",
        "  while ((Get-Service WindowsAzureTelemetryService).Status -ne 'Running') { Start-Sleep -s 5 }",
        "  while ((Get-Service WindowsAzureGuestAgent).Status -ne 'Running') { Start-Sleep -s 5 }",

        "& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit /mode:vm",
        "while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 10  } else { break } }"
      ]
    }
  ]
}

 
I started a Windows VM, logged in and the WindowsAzureTelemetryService is not running, but we didn't change anything.
If we remove the line with the WindowsAzureTelemetryService it just fails with other errors.

Anyone else seen this issue?
Any ideas how to solve it?

Regards,

Adam
Reply all
Reply to author
Forward
0 new messages