High Packer.exe CPU load during Build - Builds don't finish anymore
packer { required_plugins { azure = { version = ">= 2.5.0" source = "github.com/hashicorp/azure" } windows-update = { version = ">= 0.17.1" source = "github.com/rgl/windows-update" } } } source "azure-arm" "win11-23h2-avd" { azure_tags = { "Created by" = "ANX-IT/MHN" "Environment" = "Prod" } skip_create_image = true async_resourcegroup_delete = true subscription_id = "${var.azure_subscription_id}" client_id = "${var.azure_client_id}" client_secret = "${var.azure_client_secret}" build_resource_group_name = "rg-pur-packer-build" os_type = "Windows" image_publisher = "MicrosoftWindowsDesktop" image_offer = "Windows-11" image_sku = "win11-23h2-avd" vm_size = "Standard_NC8as_T4_v3" polling_duration_timeout = "30m" virtual_network_resource_group_name = "rg-pur-network" virtual_network_name = "vnet-pur-main" virtual_network_subnet_name = "subnet-pur-citrix" communicator = "winrm" winrm_insecure = true winrm_timeout = "5m" winrm_use_ssl = true winrm_username = "packer" managed_image_name = "packer-win11-23h2-avd" managed_image_os_disk_snapshot_name = "${var.snapshotname}" managed_image_resource_group_name = "rg-pur-packer-images" managed_image_storage_account_type = "Premium_LRS" os_disk_size_gb = "200" } build { sources = ["source.azure-arm.win11-23h2-avd"] provisioner "powershell" { use_pwsh = false inline = [ "while ((Get-Service RdAgent -ErrorAction SilentlyContinue).Status -ne 'Running') { Start-Sleep -s 5 }", "while ((Get-Service WindowsAzureGuestAgent -ErrorAction SilentlyContinue).Status -ne 'Running') { Start-Sleep -s 5 }", "Set-ExecutionPolicy Bypass -Scope Process -Force" ] } provisioner "powershell" { use_pwsh = false environment_vars = [ "downloadcache=${var.downloadcache}", "localuser=${var.localuser}", "localuserpw=${var.localuserpw}" ] scripts = [ "scripts/001_preparation.ps1", "scripts/002_PowerShell-x64.ps1" ] } provisioner "powershell" { use_pwsh = true script = "scripts/003_pwsh-modules.ps1" } provisioner "windows-restart" { restart_timeout = "10m" } provisioner "powershell" { use_pwsh = false script = "scripts/010_language-de-DE.ps1" } provisioner "windows-update" { pause_before = "1m" restart_timeout = "15m" search_criteria = "IsInstalled=0" filters = [ "exclude:$_.Title -like '*Silverlight*'", "exclude:$_.Title -like '*Preview*'", "exclude:$_.Title -like '*Vorschau*'", "exclude:$_.Title -like '*KB5040442*'", "include:$true" ] update_limit = 25 } provisioner "windows-restart" { restart_timeout = "15m" } provisioner "powershell" { use_pwsh = true script = "scripts/osbuild.ps1" } provisioner "powershell" { use_pwsh = false script = "scripts/015_VcRedist.ps1" } provisioner "powershell" { use_pwsh = true environment_vars = [ "storageaccountname=${var.storageaccountname}", "storageaccountcontainer=${var.storageaccountcontainer}", "storagecontainerkey=${var.storagecontainerkey}", "downloadcache=${var.downloadcache}" ] scripts = [ "scripts/107_Microsoft-NET-LTS.ps1", "scripts/108_Microsoft-Sysinternals-PsTools-Suite.ps1", "scripts/109_Microsoft-OLE-DB-Driver-for-SQL-Server.ps1", "scripts/110_Microsoft-ODBC-Driver-for-SQL-Server.ps1" ] } provisioner "windows-restart" { restart_timeout = "15m" } provisioner "powershell" { use_pwsh = true environment_vars = [ "storageaccountname=${var.storageaccountname}", "storageaccountcontainer=${var.storageaccountcontainer}", "storagecontainerkey=${var.storagecontainerkey}", "downloadcache=${var.downloadcache}" ] script = "scripts/020_nvidia.ps1" } provisioner "windows-restart" { restart_timeout = "15m" } provisioner "powershell" { use_pwsh = true environment_vars = [ "storageaccountname=${var.storageaccountname}", "storageaccountcontainer=${var.storageaccountcontainer}", "storagecontainerkey=${var.storagecontainerkey}", "downloadcache=${var.downloadcache}", "localuser=${var.localuser}" ] scripts = [ "scripts/030_Citrix-VDA.ps1", "scripts/039_RDAnalyzer.ps1", "scripts/040_FSLogix-Apps.ps1", "scripts/042_Citrix-WEM-Agent.ps1", "scripts/045_Zabbix agent.ps1", "scripts/050_BIS-F.ps1", "scripts/051_Citrix-Optimizer.ps1", "scripts/052_delprof2.ps1" ] } provisioner "windows-restart" { restart_timeout = "15m" } provisioner "powershell" { use_pwsh = true environment_vars = [ "storageaccountname=${var.storageaccountname}", "storageaccountcontainer=${var.storageaccountcontainer}", "storagecontainerkey=${var.storagecontainerkey}", "downloadcache=${var.downloadcache}" ] scripts = [ "scripts/100_Microsoft-Office365.ps1", "scripts/102_Microsoft-Teams2.ps1", "scripts/103_Microsoft-OneDrive.ps1", "scripts/104_Microsoft-SSMS.ps1", "scripts/105_Microsoft-VSCode.ps1", "scripts/106_Microsoft-Azure-Storage-Explorer.ps1", "scripts/112_Notepad-PlusPlus.ps1", "scripts/113_AdobeAcrobatReaderDC.ps1", "scripts/115_Mozilla-Firefox.ps1", "scripts/116_VideoLanVlcPlayer.ps1", "scripts/121_PDF24.ps1", "scripts/122_PaintNET.ps1", "scripts/124_Greenshot.ps1", "scripts/125_ImageGlass.ps1" ] } provisioner "powershell" { use_pwsh = true elevated_user = "${var.localuser}" elevated_password = "${var.localuserpw}" environment_vars = [ "pdquser=${var.pdquser}", "pdquserpw=${var.pdquserpw}" ] scripts = [ "scripts/PDQ.ps1" ] } provisioner "powershell" { use_pwsh = true elevated_user = "${var.localuser}" elevated_password = "${var.localuserpw}" environment_vars = [ "storageaccountname=${var.storageaccountname}", "storageaccountcontainer=${var.storageaccountcontainer}", "storagecontainerkey=${var.storagecontainerkey}", "downloadcache=${var.downloadcache}" ] scripts = [ "scripts/201_AutoCAD.ps1", "scripts/201_AutoCAD-EN.ps1", "scripts/201_JS_Menu.ps1", "scripts/201_Loopback.ps1", "scripts/210_Autodesk-Navisworks-Freedom-2024-Update-2.ps1", "scripts/203_3DxWare.ps1", "scripts/204_BricsCAD.ps1", "scripts/205_Druckverlust.ps1", "scripts/206_ELiA.ps1", "scripts/207_ProjektPro.ps1", "scripts/208_RedBag.ps1", "scripts/ROHR2.viewer.ps1", "scripts/CONVAL.ps1", "scripts/Microsoft_Edge.ps1", "scripts/Citrix-Workspace-app.ps1", "scripts/Datev-Sicherheitspaket-compact.ps1" ] } provisioner "windows-restart" { restart_timeout = "60m" } provisioner "windows-update" { pause_before = "1m" restart_timeout = "60m" search_criteria = "IsInstalled=0" filters = [ "exclude:$_.Title -like '*Silverlight*'", "exclude:$_.Title -like '*Preview*'", "exclude:$_.Title -like '*Vorschau*'", "include:$true" ] update_limit = 25 } provisioner "windows-restart" { restart_timeout = "60m" } provisioner "file" { direction = "upload" sources = [ "pester/pur-daas.Tests.ps1", "pester/MachineBuild-Config.psd1", "pester/Test-MachineBuild.Tests.ps1" ] destination = "${var.downloadcache}/" } provisioner "powershell" { use_pwsh = true environment_vars = ["downloadcache=${var.downloadcache}"] scripts = [ "pester/Invoke-Pester.ps1", "scripts/991_Get-Installed.ps1" ] } provisioner "file" { direction = "download" source = "${var.downloadcache}/testResults.xml" destination = "pester/testResults.xml" } provisioner "file" { direction = "download" source = "${var.downloadcache}/InstalledSoftware.txt" destination = "./InstalledSoftware.txt" } provisioner "powershell" { use_pwsh = true environment_vars = ["downloadcache=${var.downloadcache}"] script = "pester/Get-TestResults.ps1" } provisioner "powershell" { use_pwsh = true environment_vars = ["downloadcache=${var.downloadcache}"] inline = [ "Write-Verbose 'Remove download cache' -Verbose", "Remove-Item -Path $env:downloadcache -Recurse -Force" ] } provisioner "powershell" { use_pwsh = false script = "scripts/990_Run-BISF.ps1" } }
### Operating system and Environment details Build Server: Windows Server 2019 on-prem. Azure DevOps Agent, Citrix DaaS SDK. Only purpose of the VM is to be triggered be DevOps. OS to build: Azure Windows 11 23H2 Multi User with Citrix LTSR VDA 2507 ### Log Fragments and crash.log files The Packer process always breaks after 3+ hours, during the last Windows Update Restart run. There have been Windows Updates already at the beginning and many restarts in between.2025-09-24T03:20:00+02:00: ==> azure-arm.win11-23h2-avd: Provisioning with powershell script: scripts/Datev-Sicherheitspaket-compact.ps1 -24T03:20:38+02:00: ==> azure-arm.win11-23h2-avd: ##[group]Installation DATEV Sicherheitspaket compact 7.89 2025-09-24T03:21:48+02:00: ==> azure-arm.win11-23h2-avd: Restarting Machine 2025-09-24T03:21:53+02:00: ==> azure-arm.win11-23h2-avd: Waiting for machine to restart... 2025-09-24T03:23:56+02:00: ==> azure-arm.win11-23h2-avd: pkrvmkno7ptxfxp restarted. 2025-09-24T03:24:00+02:00: ==> azure-arm.win11-23h2-avd: Machine successfully restarted, moving on 2025-09-24T03:24:03+02:00: ==> azure-arm.win11-23h2-avd: Pausing 1m0s before the next provisioner... 2025-09-24T03:25:07+02:00: ==> azure-arm.win11-23h2-avd: Uploading the Windows update elevated script... 2025-09-24T03:25:19+02:00: ==> azure-arm.win11-23h2-avd: Uploading the Windows update check for reboot required elevated script... 2025-09-24T03:25:31+02:00: ==> azure-arm.win11-23h2-avd: Uploading the Windows update script... 2025-09-24T03:25:45+02:00: ==> azure-arm.win11-23h2-avd: Running Windows update... 2025-09-24T03:25:59+02:00: ==> azure-arm.win11-23h2-avd: Searching for Windows updates... 2025-09-24T03:26:09+02:00: ==> azure-arm.win11-23h2-avd: Found Windows update (2012-04-05; 9,8 MB): Sicherheitsupdate fr Microsoft Visual C++ 2010 Service Pack 1 Redistributable Package (KB2565063) 2025-09-24T03:26:10+02:00: ==> azure-arm.win11-23h2-avd: Found Windows update (2024-11-12; 63,34 MB): 2024-11 .NET 6.0.36 Update for x64 Client (KB5047486) 2025-09-24T03:26:12+02:00: ==> azure-arm.win11-23h2-avd: Found Windows update (2025-05-22; 18,16 MB): Update fr Windows Security platform - KB5007651 (Version 10.0.27840.1000) 2025-09-24T03:26:14+02:00: ==> azure-arm.win11-23h2-avd: Found Windows update (2025-09-09; 107,06 MB): 2025-09 .NET 8.0.20 Update for x64 Client (KB5066233) 2025-09-24T03:26:15+02:00: ==> azure-arm.win11-23h2-avd: Downloading Windows updates (4 updates; 198,36 MB)... 2025-09-24T03:26:39+02:00: ==> azure-arm.win11-23h2-avd: Installing Windows updates... 2025-09-24T03:26:55+02:00: ==> azure-arm.win11-23h2-avd: Waiting for operation to complete (system performance: 0% cpu; 6% memory)... 2025-09-24T03:27:16+02:00: ==> azure-arm.win11-23h2-avd: Restarting Machine 2025-09-24T03:27:23+02:00: ==> azure-arm.win11-23h2-avd: Waiting for machine to restart... 2025-09-24T03:49:31+02:00: ==> azure-arm.win11-23h2-avd: Provisioning step had errors: Running the cleanup provisioner, if present... 2025-09-24T03:49:33+02:00: ==> azure-arm.win11-23h2-avd: ==> azure-arm.win11-23h2-avd: Deleting Virtual Machine deployment and its attached resources... 2025-09-24T03:50:54+02:00: ==> azure-arm.win11-23h2-avd: Deleted -> Microsoft.Compute/virtualMachines : 'pkrvmkno7ptxfxp' 2025-09-24T03:51:16+02:00: ==> azure-arm.win11-23h2-avd: Deleted -> Microsoft.Network/networkInterfaces : 'pkrnikno7ptxfxp' 2025-09-24T03:51:36+02:00: ==> azure-arm.win11-23h2-avd: Deleted -> Microsoft.Compute/disks : '/subscriptions//resourceGroups/rg-pur-packer-build/providers/Microsoft.Compute/disks/pkroskno7ptxfxp' 2025-09-24T03:51:36+02:00: ==> azure-arm.win11-23h2-avd: Removing the created Deployment object: 'pkrdpkno7ptxfxp' 2025-09-24T03:51:53+02:00: ==> azure-arm.win11-23h2-avd: ==> azure-arm.win11-23h2-avd: Deleting KeyVault created during build 2025-09-24T03:52:04+02:00: ==> azure-arm.win11-23h2-avd: Deleted -> Microsoft.KeyVault/vaults : 'pkrkvkno7ptxfxp' 2025-09-24T03:52:05+02:00: ==> azure-arm.win11-23h2-avd: Removing the created Deployment object: 'kvpkrdpkno7ptxfxp' 2025-09-24T03:52:24+02:00: ==> azure-arm.win11-23h2-avd: ==> azure-arm.win11-23h2-avd: The resource group was not created by Packer, not deleting ... 2025-09-24T03:52:25+02:00: Build 'azure-arm.win11-23h2-avd' errored after 3 hours 45 minutes: unexpected EOF ==> Wait completed after 3 hours 45 minutes ==> Some builds didn't complete successfully and had errors: --> azure-arm.win11-23h2-avd: unexpected EOF ==> Builds finished but no artifacts were created. ##[error]Error: The process 'C:\az-build-agent\_work\_tool\packer\1.14.2\x64\packer.exe' failed with exit code 1 Finishing: Packer build
### ScreenshotSource: hashicorp/packer