Add support for an existing resource group to the build-image.ps1 script#13933
Open
eduardkuijpers86 wants to merge 16 commits intoactions:mainfrom
Open
Add support for an existing resource group to the build-image.ps1 script#13933eduardkuijpers86 wants to merge 16 commits intoactions:mainfrom
eduardkuijpers86 wants to merge 16 commits intoactions:mainfrom
Conversation
…ardkuijpers86/runner-images into feature/add-fixed-rg-support
Contributor
There was a problem hiding this comment.
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
-varargument 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-testsworkflow; 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
firewallShouldBeEnabledOnKeyVaultMonitoringEffectanddeployazuremonitoringagentlinuxvms) and need to add policy exemptions on the resource group.build_resource_group_namein the build-image.ps1 script with parameterExistingResourceGroupNamebuild_resource_group_name,temp_resource_group_name, andlocationdon't conflict as described in the Packer documentation on resource groupsTest results
Temporary resource group
Build yaml:

Build output:

Resource group:

Existing resource group
Build yaml:

Build output:

Resource group:

Related issue:
N/A
Check list