Skip to content

Commit

Permalink
Skip cleaning up locked resource groups (#6951)
Browse files Browse the repository at this point in the history
  • Loading branch information
benbp authored Sep 12, 2023
1 parent c3f571b commit 5238410
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions eng/scripts/live-test-resource-cleanup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,12 @@ function HasDoNotDeleteTag([object]$ResourceGroup) {
return $doNotDelete -ne $null
}

function HasDeleteLock() {
function HasDeleteLock([object]$ResourceGroup) {
$lock = Get-AzResourceLock -ResourceGroupName $ResourceGroup.ResourceGroupName
if ($lock) {
Write-Host " Skipping locked resource group '$($ResourceGroup.ResourceGroupName)'"
return $true
}
return $false
}

Expand Down Expand Up @@ -347,7 +352,10 @@ function DeleteOrUpdateResourceGroups() {
if (HasValidAliasInName $rg) {
continue
}
if (HasValidOwnerTag $rg -or HasDeleteLock $rg) {
if (HasValidOwnerTag $rg) {
continue
}
if (HasDeleteLock $rg) {
continue
}
$toUpdate += $rg
Expand Down

0 comments on commit 5238410

Please sign in to comment.