Skip to content

Changes to helper scripts to support ComputeGallery#13715

Open
Reterino wants to merge 2 commits intoactions:mainfrom
Reterino:feature/helper-script-compute-gallery-support
Open

Changes to helper scripts to support ComputeGallery#13715
Reterino wants to merge 2 commits intoactions:mainfrom
Reterino:feature/helper-script-compute-gallery-support

Conversation

@Reterino
Copy link

Description

This code slightly updates the helper script GenerateResourceAndImage.ps1 to add support for using a Compute Gallery. It modifies the input parameters to now accept ComputeGalleryName, ComputeGalleryImageName, ComputeGalleryImageVersion.
It adds logic to validate those parameters: if ComputeGalleryName exists, the other two must exist; and ComputeGalleryImageVersion must be semantic versioning notation.
It modifies the way artifact arguments are passed into the packer commands and uses an $artifactArgs array to do splatting and conditionally add either the managed image details or compute gallery details.

Related issue:

#13685

Check list

  • Related issue / work item is attached
  • Tests are written (not applicable)
  • Documentation is updated (not applicable)
  • Changes are tested and related VM images are successfully generated

Other

This should still be backwards compatible for everyone currently using this helper script.
I was not sure if I should support both Managed Image and Compute Gallery at the same time, but I think that's fairly niche and there is still the option of environment variables for that.

Copilot AI review requested due to automatic review settings February 23, 2026 07:52
@Reterino Reterino changed the title Initial changes to allow ComputeGallery for images Changes to helper scripts to support ComputeGallery Feb 23, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the helpers/GenerateResourcesAndImage.ps1 helper to support producing images into an Azure Compute Gallery (Shared Image Gallery) instead of only producing managed images, aligning the helper’s CLI surface area with existing Packer template capabilities.

Changes:

  • Adds ComputeGalleryName, ComputeGalleryImageName, and ComputeGalleryImageVersion parameters with basic validation (including a semver-style version check).
  • Introduces conditional artifact argument construction so Packer gets either managed image vars or compute gallery vars.
  • Adds an Azure CLI check intended to validate compute gallery existence before running the Packer build.

if ($ComputeGalleryName -and -not $ComputeGalleryImageVersion) {
throw "ComputeGalleryImageVersion parameter is required when ComputeGalleryName is specified."
}
if ($ComputeGalleryImageVersion -and -not ($ComputeGalleryImageVersion -match '^\d+\.\d+\.\d+$')) {
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ComputeGalleryImageName/ComputeGalleryImageVersion are provided without ComputeGalleryName, they are silently ignored and a managed image is produced. Add validation to reject "partial" compute gallery inputs (e.g., if either of the image name/version params are set, require ComputeGalleryName too) to prevent unexpected output artifacts.

Suggested change
if ($ComputeGalleryImageVersion -and -not ($ComputeGalleryImageVersion -match '^\d+\.\d+\.\d+$')) {
if ($ComputeGalleryImageName -and -not $ComputeGalleryName) {
throw "ComputeGalleryName parameter is required when ComputeGalleryImageName is specified."
}
if ($ComputeGalleryImageVersion -and -not $ComputeGalleryName) {
throw "ComputeGalleryName parameter is required when ComputeGalleryImageVersion is specified."
}
if ($ComputeGalleryName -and $ComputeGalleryImageVersion -and -not ($ComputeGalleryImageVersion -match '^\d+\.\d+\.\d+$')) {

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If wanting to do complete validation rather than silently ignore, we could do a more comprehensive check of all scenarios using an array of the 3 inputs, select non-empty and then length -eq 0 or length -eq 3.

Not sure if this is worthwhile as it looks pretty messy, but may give extra validation for people mis-inputting the parameters.

Modified compute gallery check
@Reterino Reterino force-pushed the feature/helper-script-compute-gallery-support branch from e626c77 to 5e8e7e6 Compare February 23, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants