Skip to content

Commit

Permalink
feature: added try/catch to credential key removal to prevent pipelin…
Browse files Browse the repository at this point in the history
…e to fail when key has already been removed (manually). (#590)
  • Loading branch information
eikeskogen authored Sep 19, 2023
1 parent c08120c commit 9b016d8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/backend/infrastructure/cleanup-secrets.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ foreach ($s in $secretWithVersions) {
$newTags["deleted"] = (Get-Date).ToString()
Update-AzKeyVaultSecret $s -Version $s.Version -Tag $newTags

Remove-AzADAppCredential -ApplicationId $AAD_APP_ID -KeyId $keyId
try {
Remove-AzADAppCredential -ApplicationId $AAD_APP_ID -KeyId $keyId -ErrorAction Stop
}
catch {
Write-Host "Unable to remove credential with key id: '$keyId' from application '$AAD_APP_ID'. The key has probably already been removed."
}

}
} else {
Write-Host "Non auto generated key, skipping"
Expand Down

0 comments on commit 9b016d8

Please sign in to comment.