Skip to content

Using BUILD_RG_NAME to not create RG #13750

@gavintodd

Description

@gavintodd

Description

My org has a permissions structure that won't work to create RGs at start of the process. I added $env:BUILD_RG_NAME = "<rg_name>" and then i started getting the error

"* Specify either a location to create the resource group in or an existing build_resource_group_name, but not both."

The issue i'm running into is the validate is called as

    Write-Host "Validating packer template..."
    & $PackerBinary validate `
        "-only=$($PackerTemplate.BuildName).*" `
        "-var=client_id=fake" `
        "-var=client_secret=fake" `
        "-var=subscription_id=$($SubscriptionId)" `
        "-var=tenant_id=fake" `
        "-var=location=$($AzureLocation)" `
        "-var=image_os=$($PackerTemplate.ImageOS)" `
        "-var=managed_image_name=$($ManagedImageName)" `
        "-var=managed_image_resource_group_name=$($ResourceGroupName)" `
        "-var=install_password=$($InstallPassword)" `
        "-var=allowed_inbound_ip_addresses=$($AllowedInboundIpAddresses)" `
        "-var=azure_tags=$($TagsJson)" `
        $PackerTemplate.Path

But the GenerateResourcesAndImage.ps1 has

        [Parameter(Mandatory = $True)]
        [string] $AzureLocation,

How am i'm supposed to use a premade RG in the process?

Platforms affected

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

Runner images affected

  • Ubuntu 22.04
  • Ubuntu 24.04
  • Ubuntu Slim
  • macOS 14
  • macOS 14 Arm64
  • macOS 15
  • macOS 15 Arm64
  • macOS 26
  • macOS 26 Arm64
  • Windows Server 2022
  • Windows Server 2025
  • Windows Server 2025 with Visual Studio 2026

Image version and build link

Main branch all versions

Is it regression?

Not sure, org permissions structure used to allow me to create temp RG

Expected behavior

Leverages existing RG

Actual behavior

Throws error either

Cannot process command because of one or more missing mandatory
     | parameters: AzureLocation.

or if passed as ""

Cannot bind argument to parameter 'AzureLocation' because it is an empty
     | string.

Repro steps

$env:BUILD_RG_NAME = "<existing_rg_name>"
GenerateResourcesAndImage -SubscriptionId <sub_id> -ResourceGroupName "<destination_rg>" -ImageGenerationRepositoryRoot "$pwd" -ImageType $imageType -ManagedImageName $imageName -AzureClientId <client_id> -AzureClientSecret $azureClientSecret -AzureTenantId <tenant_id>

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions