From 129a2b09e5ec8fed983360a47c115566dda8e329 Mon Sep 17 00:00:00 2001 From: Marcos Salamanca Date: Tue, 14 Jul 2026 11:02:03 -0500 Subject: [PATCH 1/2] make prefix check optional --- eng/common/scripts/Helpers/Resource-Helpers.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/Helpers/Resource-Helpers.ps1 b/eng/common/scripts/Helpers/Resource-Helpers.ps1 index f12b35503500..1de1a886c6f1 100644 --- a/eng/common/scripts/Helpers/Resource-Helpers.ps1 +++ b/eng/common/scripts/Helpers/Resource-Helpers.ps1 @@ -297,7 +297,8 @@ function Remove-WormStorageAccounts() { [CmdletBinding(SupportsShouldProcess = $True)] param( [string]$GroupPrefix, - [switch]$CI + [switch]$CI, + [bool]$CheckPrefix = $true ) $ErrorActionPreference = 'Stop' @@ -306,10 +307,14 @@ function Remove-WormStorageAccounts() { # DO NOT REMOVE THIS # We call this script from live test pipelines as well, and a string mismatch/error could blow away # some static storage accounts we rely on - if (!$groupPrefix -or ($CI -and (!$GroupPrefix.StartsWith('rg-') -and !$GroupPrefix.StartsWith('SSS3PT_rg-')))) { + # Note: Prefix Check is optional and can be disabled by setting `-CheckPrefix $false` for situations were prefix isn't standardized + if ($CheckPrefix){ + if (!$groupPrefix -or ($CI -and (!$GroupPrefix.StartsWith('rg-') -and !$GroupPrefix.StartsWith('SSS3PT_rg-')))) { throw "The -GroupPrefix parameter must not be empty, or must start with 'rg-' or 'SSS3PT_rg-' in CI contexts" + } } + $groups = Get-AzResourceGroup | Where-Object { $_.ResourceGroupName.StartsWith($GroupPrefix) } | Where-Object { $_.ProvisioningState -ne 'Deleting' } foreach ($group in $groups) { From 94d5c1a5f70085d84a540d1852bd21c604dbcf27 Mon Sep 17 00:00:00 2001 From: msalaman Date: Tue, 14 Jul 2026 13:02:12 -0500 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- eng/common/scripts/Helpers/Resource-Helpers.ps1 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/eng/common/scripts/Helpers/Resource-Helpers.ps1 b/eng/common/scripts/Helpers/Resource-Helpers.ps1 index 1de1a886c6f1..35f3ec23b87e 100644 --- a/eng/common/scripts/Helpers/Resource-Helpers.ps1 +++ b/eng/common/scripts/Helpers/Resource-Helpers.ps1 @@ -307,11 +307,13 @@ function Remove-WormStorageAccounts() { # DO NOT REMOVE THIS # We call this script from live test pipelines as well, and a string mismatch/error could blow away # some static storage accounts we rely on - # Note: Prefix Check is optional and can be disabled by setting `-CheckPrefix $false` for situations were prefix isn't standardized - if ($CheckPrefix){ - if (!$groupPrefix -or ($CI -and (!$GroupPrefix.StartsWith('rg-') -and !$GroupPrefix.StartsWith('SSS3PT_rg-')))) { - throw "The -GroupPrefix parameter must not be empty, or must start with 'rg-' or 'SSS3PT_rg-' in CI contexts" - } + # Note: Prefix check can be disabled via `-CheckPrefix:$false` for scenarios where the resource group prefix isn't standardized. + if (!$GroupPrefix) { + throw "The -GroupPrefix parameter must not be empty" + } + + if ($CheckPrefix -and $CI -and (!$GroupPrefix.StartsWith('rg-') -and !$GroupPrefix.StartsWith('SSS3PT_rg-'))) { + throw "In CI contexts with -CheckPrefix enabled, -GroupPrefix must start with 'rg-' or 'SSS3PT_rg-'" }