Skip to content

Add support for an existing resource group to the build-image.ps1 script#13933

Open
eduardkuijpers86 wants to merge 16 commits intoactions:mainfrom
eduardkuijpers86:feature/add-fixed-rg-support
Open

Add support for an existing resource group to the build-image.ps1 script#13933
eduardkuijpers86 wants to merge 16 commits intoactions:mainfrom
eduardkuijpers86:feature/add-fixed-rg-support

Conversation

@eduardkuijpers86
Copy link
Copy Markdown

@eduardkuijpers86 eduardkuijpers86 commented Apr 15, 2026

Description

Adds support for an existing resource group to the build-image.ps1 script.

Useful for developers/teams that are blocked by Azure policies that can interfere with the image build or hosting(for example firewallShouldBeEnabledOnKeyVaultMonitoringEffect and deployazuremonitoringagentlinuxvms) and need to add policy exemptions on the resource group.

  • Exposes the Packer variable build_resource_group_name in the build-image.ps1 script with parameter ExistingResourceGroupName
  • Implements two parameter sets to ensure Packer variables build_resource_group_name, temp_resource_group_name, and location don't conflict as described in the Packer documentation on resource groups
  • Added Write-output to show if Packer will be called with a temporary or existing resource group
  • Added Pester tests to verify the parameter sets and that Packer is called using the correct variables
  • Added the Pester tests as part of the GitHub workflow powershell-tests
  • Updated docs on the Packer variables to better reflect the Packer documentation on resource groups

Test results

Temporary resource group

Build yaml:
MS-PR-tempResourceGroup-yaml

Build output:
MS-PR-tempResourceGroup-build

Resource group:
MS-PR-tempResourceGroup

Existing resource group

Build yaml:
MS-PR-existingResourceGroup-yaml

Build output:
MS-PR-existingResourceGroup-build

Resource group:
MS-PR-existingResourceGroup

Related issue:

N/A

Check list

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

@eduardkuijpers86 eduardkuijpers86 marked this pull request as ready for review April 15, 2026 12:47
Copilot AI review requested due to automatic review settings April 15, 2026 12:47
Copy link
Copy Markdown
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

Adds support in the images.CI/linux-and-win/build-image.ps1 wrapper to run Packer builds in an existing Azure resource group, enabling teams to apply policy exemptions on that RG and avoid build-time policy blocks.

Changes:

  • Added two PowerShell parameter sets to enforce Packer’s mutually-exclusive resource group options (temporary RG vs existing RG).
  • Refactored Packer -var argument construction to a reusable helper and added logging indicating which RG mode is used.
  • Added Pester tests for parameter sets and Packer invocation, and wired those tests into the powershell-tests workflow; updated docs for RG-related Packer variables.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
images.CI/linux-and-win/build-image.ps1 Adds ExistingResourceGroupName support and parameter-set-driven Packer var selection.
images.CI/linux-and-win/tests/build-image.Tests.ps1 Adds Pester tests validating parameter sets and correct Packer variables per mode.
.github/workflows/powershell-tests.yml Runs the new linux-and-win Pester tests in CI and triggers the workflow on changes in that subtree.
docs/create-image-and-azure-resources.md Updates documentation about RG-related Packer variables and their allowed combinations.

Comment thread docs/create-image-and-azure-resources.md Outdated
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