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

fix: Provide more graceful handling for APIM default cleanup #225

Merged
merged 3 commits into from
Nov 16, 2021
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ $starterResult = Remove-AzApiManagementProduct -Context $apimContext -ProductId
Write-Host "Removing Unlimited product..."
$unlimitedResult = Remove-AzApiManagementProduct -Context $apimContext -ProductId 'unlimited' -DeleteSubscriptions

if ($apiResult -and $starterResult -and $unlimitedResult) {
Write-Host "Successfully removed the 'echo-api' API, 'starter' Product and 'unlimited' Product"
} else {
$message = "Failed to remove API Management defaults"
if (-not $apiResult) {
$message += [System.Environment]::NewLine + "> Failed to remove the 'echo' API"
}
if (-not $starterResult) {
$message += [System.Environment]::NewLine + "> Failed to remove the 'starter' Product"
}
if (-not $unlimitedResult) {
$message += [System.Environment]::NewLine + "> Failed to remove the 'unlimited' Product"
}
$message = $null

if ($null -ne $apiResult) {
$message += [System.Environment]::NewLine + "> Failed to remove the 'echo' API"
}
if ($null -ne $starterResult) {
$message += [System.Environment]::NewLine + "> Failed to remove the 'starter' Product"
}
if ($null -ne $unlimitedResult) {
$message += [System.Environment]::NewLine + "> Failed to remove the 'unlimited' Product"
}
stijnmoreels marked this conversation as resolved.
Show resolved Hide resolved

if($null -eq $message){
Write-Host "Successfully removed the 'echo-api' API, 'starter' Product and 'unlimited' Product"
}else{
Write-Error $message
}

Expand Down