hashicorp / hashicorp/packer-plugin-azure

Error while capturing windows vhd builds (any)

Open
#560 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
63
Forks
103
PR merge metrics
No merged PRs in 30d

Description

#### Overview of the Issue

We are unable to capture/build windows vhd using packer with azure plugin version `2.5.1`. Works fine in `2.5.0`

#### Reproduction Steps

Try building Windows VHD builds any version/flavour using 2.5.1. Here is the following error produced by packer

```
2025/12/19 19:38:21 packer-provisioner-powershell plugin: Opening vhdbuilder/packer/windows/sysprep.ps1 for reading
2025/12/19 19:38:21 packer-provisioner-powershell plugin: Uploading env vars to c:/Windows/Temp/packer-ps-env-vars-6945a4db-1f59-c78d-69ef-c93748b28386.ps1
2025/12/19 19:38:21 packer-provisioner-powershell plugin: [INFO] 74 bytes written for 'uploadData'
2025/12/19 19:38:21 [INFO] 74 bytes written for 'uploadData'
2025/12/19 19:38:21 packer-plugin-azure_v2.5.1_x5.0_linux_amd64 plugin: 2025/12/19 19:38:21 Uploading file to 'c:/Windows/Temp/packer-ps-env-vars-6945a4db-1f59-c78d-69ef-c93748b28386.ps1'
2025/12/19 19:38:23 packer-provisioner-powershell plugin: Building elevated command wrapper for: powershell -executionpolicy bypass "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};. c:/Windows/Temp/packer-ps-env-vars-6945a4db-1f59-c78d-69ef-c93748b28386.ps1; &'c:/Windows/Temp/script-6945a4db-cf9e-bc62-f569-c2f28579c67b.ps1'; exit $LastExitCode }"
2025/12/19 19:38:23 packer-provisioner-powershell plugin: Command [powershell -executionpolicy bypass "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};. c:/Windows/Temp/packer-ps-env-vars-6945a4db-1f59-c78d-69ef-c93748b28386.ps1; &'c:/Windows/Temp/script-6945a4db-cf9e-bc62-f569-c2f28579c67b.ps1'; exit $LastExitCode }" > %SYSTEMROOT%/Temp/packer-6945a9af-1796-743a-92b2-6207cd7d5396.out 2>&1] converted to [powershell -executionpolicy bypass "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};. c:/Windows/Temp/packer-ps-env-vars-6945a4db-1f59-c78d-69ef-c93748b28386.ps1; &'c:/Windows/Temp/script-6945a4db-cf9e-bc62-f569-c2f28579c67b.ps1'; exit $LastExitCode }" > %SYSTEMROOT%/Temp/packer-6945a9af-1796-743a-92b2-6207cd7d5396.out 2>&1] for use in XML string
2025/12/19 19:38:23 packer-provisioner-powershell plugin: Uploading elevated shell wrapper for command [powershell -executionpolicy bypass "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};. c:/Windows/Temp/packer-ps-env-vars-6945a4db-1f59-c78d-69ef-c93748b28386.ps1; &'c:/Windows/Temp/script-6945a4db-cf9e-bc62-f569-c2f28579c67b.ps1'; exit $LastExitCode }" > %SYSTEMROOT%/Temp/packer-6945a9af-1796-743a-92b2-6207cd7d5396.out 2>&1] to [C:/Windows/Temp/packer-elevated-shell-6945a9af-f9f7-cd91-021b-607af7c43b9e.ps1]
2025/12/19 19:38:23 packer-provisioner-powershell plugin: [INFO] 3522 bytes written for 'uploadData'
2025/12/19 19:38:23 [INFO] 3522 bytes written for 'uploadData'
2025/12/19 19:38:23 packer-plugin-azure_v2.5.1_x5.0_linux_amd64 plugin: 2025/12/19 19:38:23 Uploading file to 'C:/Windows/Temp/packer-elevated-shell-6945a9af-f9f7-cd91-021b-607af7c43b9e.ps1'
2025/12/19 19:38:24 packer-provisioner-powershell plugin: [INFO] 2087 bytes written for 'uploadData'
2025/12/19 19:38:24 [INFO] 2087 bytes written for 'uploadData'
2025/12/19 19:38:24 packer-plugin-azure_v2.5.1_x5.0_linux_amd64 plugin: 2025/12/19 19:38:24 Uploading file to 'c:/Windows/Temp/script-6945a4db-cf9e-bc62-f569-c2f28579c67b.ps1'
2025/12/19 19:38:25 packer-plugin-azure_v2.5.1_x5.0_linux_amd64 plugin: 2025/12/19 19:38:25 [INFO] starting remote command: powershell -executionpolicy bypass -file "C:/Windows/Temp/packer-elevated-shell-6945a9af-f9f7-cd91-021b-607af7c43b9e.ps1"
2025-12-19T19:38:26Z: ==> azure-arm: WindowsAzureGuestAgent is still running, trying to stop now.
2025-12-19T19:38:28Z: ==> azure-arm: WARNING: Waiting for service 'Windows Azure Guest Agent (WindowsAzureGuestAgent)' to stop...
2025-12-19T19:38:30Z: ==> azure-arm: WARNING: Waiting for service 'Windows Azure Guest Agent (WindowsAzureGuestAgent)' to stop...
2025-12-19T19:38:35Z: ==> azure-arm: WARNING: Waiting for service 'RdAgent (RdAgent)' to stop...
2025-12-19T19:38:37Z: ==> azure-arm: WARNING: Waiting for service 'RdAgent (RdAgent)' to stop...
2025-12-19T19:38:37Z: ==> azure-arm: [SC] DeleteService SUCCESS
2025-12-19T19:38:37Z: ==> azure-arm: [SC] DeleteService SUCCESS
2025-12-19T19:38:37Z: ==> azure-arm: Removing 5c6d8a0e-cfe2-4dbb-9db3-bea0640e12a4 - C:\Windows\system32\VMAgentDisabler.dll,SysprepProviderEntryPoint
2025-12-19T19:38:37Z: ==> azure-arm: IMAGE_STATE_COMPLETE
2025/12/19 19:39:47 packer-plugin-azure_v2.5.1_x5.0_linux_amd64 plugin: 2025/12/19 19:39:47 [INFO] command 'powershell -executionpolicy bypass -file "C:/Windows/Temp/packer-elevated-shell-6945a9af-f9f7-cd91-021b-607af7c43b9e.ps1"' exited with code: 0
2025/12/19 19:39:47 [INFO] 566 bytes written for 'stdout'
2025/12/19 19:39:47 [INFO] 0 bytes written for 'stderr'
2025/12/19 19:39:47 packer-provisioner-powershell plugin: [INFO] 566 bytes written for 'stdout'
2025/12/19 19:39:47 packer-provisioner-powershell plugin: Retryable error: unknown error Post "https://172.1.0.10:5986/wsman": read tcp 172.0.0.113:48238->172.1.0.10:5986: read: connection reset by peer
2025/12/19 19:39:47 packer-provisioner-powershell plugin: [INFO] 0 bytes written for 'stderr'
2025/12/19 19:39:49 packer-provisioner-powershell plugin: [INFO] 2087 bytes written for 'uploadData'
2025/12/19 19:39:49 [INFO] 2087 bytes written for 'uploadData'
2025/12/19 19:39:49 packer-plugin-azure_v2.5.1_x5.0_linux_amd64 plugin: 2025/12/19 19:39:49 Uploading file to 'c:/Windows/Temp/script-6945a4db-cf9e-bc62-f569-c2f28579c67b.ps1'
2025/12/19 19:40:19 packer-provisioner-powershell plugin: Retryable error: Error uploading script: Error uploading file to $env:TEMP\winrmcp-07c23f51-0aaa-45ac-66bc-d7182efdc6d7.tmp: Couldn't create shell: unknown error Post "https://172.1.0.10:5986/wsman": dial tcp 172.1.0.10:5986: i/o timeout
2025/12/19 19:40:21 packer-provisioner-powershell plugin: [INFO] 2087 bytes written for 'uploadData'
2025/12/19 19:40:21 [INFO] 2087 bytes written for 'uploadData'
```

### Plugin and Packer version
Packer version: `Packer v1.14.3`
Plugin azure: `2.5.1`

Works fine with `2.5.0`, unable to figure out if anything changed here in building windows VHD https://github.com/hashicorp/packer-plugin-azure/compare/v2.5.0...v2.5.1

### Simplified Packer Buildfile

Sorry do not have any since our packer file includes PII

### Operating system and Environment details

Ubuntu 22 building a windows VHD

### Log Fragments and crash.log files

Included above

Contributor guide

Open the contributing guide

Research direction

Start by reproducing a Windows VHD build on Ubuntu 22 with Packer v1.14.3 and Azure plugin 2.5.1, using the supplied logs and the known-working 2.5.0 version as a comparison. Inspect the changes between v2.5.0 and v2.5.1 around Windows guest-agent shutdown and WinRM handling; done means 2.5.1 completes the build without the connection reset or timeout.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, go
Domain
cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.