Skip to content

When running packer build it errors in our Azure Devops pipeline #12703

@Fazer01

Description

@Fazer01

Description

Context

We are using packer build in our pipeline in Azure Devops. This pipeline runs on a Microsoft hosted ubuntu-latest machine and will create and deploy the image for our Azure Virtual Machine Scale Set agents.

As we are using packer build using the build.windows-2025.pkr.hcl file, we get an error.

Any help would be appreciated.

Thanks in advance.

Platforms affected

  • Azure DevOps
  • GitHub Actions - Standard Runners
  • GitHub Actions - Larger Runners

Runner images affected

  • Ubuntu 22.04
  • Ubuntu 24.04
  • macOS 13
  • macOS 13 Arm64
  • macOS 14
  • macOS 14 Arm64
  • macOS 15
  • macOS 15 Arm64
  • Windows Server 2019
  • Windows Server 2022
  • Windows Server 2025

Image version and build link

We are running the packer build in an ubuntu-24.04 image:

Image: ubuntu-24.04
Version: 20250728.1.0

Is it regression?

Expected behavior

Expect the packer build command to succeed.

Actual behavior

The packer build is ran after a while (49 minutes) it errors:

##[debug]Agent environment resources - Disk: / Available 24424.09 MB out of 73325.30 MB, Memory: Used 1312.00 MB out of 7944.00 MB, CPU: Usage 0.98%
==> windows-2025.azure-arm.image: Get latest Moby release
##[debug]Agent environment resources - Disk: / Available 24424.09 MB out of 73325.30 MB, Memory: Used 1312.00 MB out of 7944.00 MB, CPU: Usage 0.48%
##[debug]Agent environment resources - Disk: / Available 24424.09 MB out of 73325.30 MB, Memory: Used 1312.00 MB out of 7944.00 MB, CPU: Usage 0.48%
==> windows-2025.azure-arm.image: Invoke-RestMethod : {
==> windows-2025.azure-arm.image:   "message": "Server Error"
==> windows-2025.azure-arm.image: }
==> windows-2025.azure-arm.image: At C:\Program Files\WindowsPowerShell\Modules\ImageHelpers\InstallHelpers.ps1:601 char:29
==> windows-2025.azure-arm.image: + ... easesPage = Invoke-RestMethod -Uri "[https://api.github.com/repos/${Re](https://api.github.com/repos/$%7BRe) ...
==> windows-2025.azure-arm.image: +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==> windows-2025.azure-arm.image:     + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
==> windows-2025.azure-arm.image:    eption
==> windows-2025.azure-arm.image:     + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
==> windows-2025.azure-arm.image: Provisioning step had errors: Running the cleanup provisioner, if present...
==> windows-2025.azure-arm.image: 
==> windows-2025.azure-arm.image: Deleting Virtual Machine deployment and its attached resources...
##[debug]Agent environment resources - Disk: / Available 24424.11 MB out of 73325.30 MB, Memory: Used 1312.00 MB out of 7944.00 MB, CPU: Usage 0.48%
##[debug]Agent environment resources - Disk: / Available 24424.11 MB out of 73325.30 MB, Memory: Used 1312.00 MB out of 7944.00 MB, CPU: Usage 0.48%
##[debug]Agent environment resources - Disk: / Available 24424.11 MB out of 73325.30 MB, Memory: Used 1312.00 MB out of 7944.00 MB, CPU: Usage 0.48%
##[debug]Agent environment resources - Disk: / Available 24424.11 MB out of 73325.30 MB, Memory: Used 1312.00 MB out of 7944.00 MB, CPU: Usage 0.00%
==> windows-2025.azure-arm.image: Deleted -> pkrvmdwt7vh2y0w : 'Microsoft.Compute/virtualMachines'

Repro steps

As part of the pipeline the following task will run our packer build command.

   -  - task: PowerShell@2
          displayName: Packer build
          env: 
            ARM_CLIENT_ID: $(AzureClientId)
            ARM_CLIENT_SECRET: $(AzureClientSecret)
            ARM_TENANT_ID: $(AzureTenantId)
            ARM_SUBSCRIPTION_ID: $(SubscriptionId)
            ARM_RESOURCE_GROUP: $(ImageResourceGroupName)
          inputs:
            targetType: inline
            script: | 
              cd $(TemplatesDir)
              Remove-Item build.windows-2022.pkr.hcl
              Remove-Item build.windows-2019.pkr.hcl           
              ls
              packer plugins install github.com/hashicorp/azure
              packer build -var "image_os=win25" `
                           -var "install_password=$(InstallPassword)" `
                           -var "managed_image_name=$(ImageName)" `
                           -var "vm_size=Standard_D2ds_v5" `
                           -var "build_resource_group_name=$(BuildResourceGroupName)" `
                           -var "azure_tags={`"ExcludeMdeAutoProvisioning`":`"True`"}" `
                           .

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions