Skip to content

Commit 3ef96de

Browse files
committed
improve clean up script
1 parent 22b6790 commit 3ef96de

1 file changed

Lines changed: 32 additions & 16 deletions

File tree

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
11
# This file can be used to clean up Resource Groups if there has been an issue with the End to End tests.
22
# CAUTION: Make sure you are connected to the correct subscription before running this script!
33
$filter = ""
4+
$subscriptions = @(
5+
"6be58818-3390-4c43-a3bb-2666110eeb66",
6+
"5331601a-985a-4f45-87d1-6b4156c8acf5",
7+
"bceedecb-9f0b-4aa3-9778-1d1fa92f289e",
8+
"9ebf45b8-555d-49c6-81fb-d27ca08f7c28",
9+
"eac9acf5-0a34-4db8-ae56-cdbcc7e2cf4c",
10+
"3a6bdc35-0830-41ac-b323-37a5a030e241",
11+
"c4332eb2-f966-47db-aa47-5d71e239d8aa",
12+
"0aeefd1c-62c7-4071-91ad-925899603976",
13+
"0d754f66-65b4-4f64-97f5-221f0174ad48"
14+
)
415

5-
az account show
6-
$resourceGroups = @("")
7-
while ($resourceGroups.Count -gt 0) {
8-
if($filter -eq "")
9-
{
10-
$resourceGroups = az group list | ConvertFrom-Json
11-
}
12-
else
13-
{
14-
$resourceGroups = az group list --query "[?contains(name, '$filter')]" | ConvertFrom-Json
15-
}
16+
$subscriptions | ForEach-Object -Parallel {
17+
$subscription = $_
18+
Write-Host "Processing subscription: $subscription"
1619

17-
$resourceGroups | ForEach-Object -Parallel {
18-
Write-Host "Deleting resource group: $($_.name)"
19-
az group delete --name $_.name --yes
20-
} -ThrottleLimit 10
21-
}
20+
$resourceGroups = @("")
21+
while ($resourceGroups.Count -gt 0) {
22+
if($filter -eq "")
23+
{
24+
$resourceGroups = az group list --subscription $subscription | ConvertFrom-Json
25+
}
26+
else
27+
{
28+
$resourceGroups = az group list --subscription $subscription --query "[?contains(name, '$filter')]" | ConvertFrom-Json
29+
}
30+
31+
$resourceGroups | ForEach-Object -Parallel {
32+
$subscription = $using:subscription
33+
Write-Host "Deleting resource group: $($_.name)"
34+
az group delete --subscription $subscription --name $_.name --yes
35+
} -ThrottleLimit 10
36+
}
37+
} -ThrottleLimit 10

0 commit comments

Comments
 (0)