Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync eng/common directory with azure-sdk-tools for PR 1146 #536

Merged
merged 3 commits into from
Oct 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions eng/common/TestResources/Remove-TestResources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,31 @@ if (![string]::IsNullOrWhiteSpace($ServiceDirectory)) {
}
}

$verifyDeleteScript = {
try {
$group = Get-AzResourceGroup -name $ResourceGroupName
} catch {
if ($_.ToString().Contains("Provided resource group does not exist")) {
Write-Verbose "Resource group '$ResourceGroupName' not found. Continuing..."
return
}
throw $_
}

if ($group.ProvisioningState -ne "Deleting")
{
throw "Resource group is in '$($group.ProvisioningState)' state, expected 'Deleting'"
}
}

Log "Deleting resource group '$ResourceGroupName'"
if (Retry { Remove-AzResourceGroup -Name "$ResourceGroupName" -Force:$Force }) {
Write-Verbose "Successfully deleted resource group '$ResourceGroupName'"
if ($Force) {
Remove-AzResourceGroup -Name "$ResourceGroupName" -Force:$Force -AsJob
Retry $verifyDeleteScript 3
Write-Verbose "Requested async deletion of resource group '$ResourceGroupName'"
} else {
# Don't swallow interactive confirmation when Force is false
Remove-AzResourceGroup -Name "$ResourceGroupName" -Force:$Force
}

$exitActions.Invoke()
Expand Down Expand Up @@ -194,4 +216,4 @@ resource group whose name is stored in the environment variable
AZURE_RESOURCEGROUP_NAME.
.LINK
New-TestResources.ps1
#>
#>