Temporarily disable error handling for Get-AzKeyVault -InRemovedState (#4329)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
This commit is contained in:
Azure SDK Bot 2023-02-02 12:20:59 -08:00 committed by GitHub
parent 5954c5ef26
commit 57072c8af3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,15 +75,23 @@ function Get-PurgeableResources {
Write-Verbose "Retrieving deleted Key Vaults from subscription $subscriptionId"
# Get deleted Key Vaults for the current subscription.
$deletedKeyVaults = @(Get-AzKeyVault -InRemovedState `
| Add-Member -MemberType NoteProperty -Name AzsdkResourceType -Value 'Key Vault' -PassThru `
| Add-Member -MemberType AliasProperty -Name AzsdkName -Value VaultName -PassThru)
# TODO: Remove try/catch handler for Get-AzKeyVault - https://github.com/Azure/azure-sdk-tools/issues/5315
# This is a temporary workaround since Az module >= 9.2.0 uses a more recent API
# version than is supported in the dogfood cloud environment:
#
# | The resource type 'deletedVaults' could not be found in the namespace 'Microsoft.KeyVault' for api version '2022-07-01'. The supported api-versions are
# | '2016-10-01,2018-02-14-preview,2018-02-14,2019-09-01,2021-04-01-preview,2021-06-01-preview,2021-10-01,2021-11-01-preview'.
try {
# Get deleted Key Vaults for the current subscription.
$deletedKeyVaults = @(Get-AzKeyVault -InRemovedState `
| Add-Member -MemberType NoteProperty -Name AzsdkResourceType -Value 'Key Vault' -PassThru `
| Add-Member -MemberType AliasProperty -Name AzsdkName -Value VaultName -PassThru)
if ($deletedKeyVaults) {
Write-Verbose "Found $($deletedKeyVaults.Count) deleted Key Vaults to potentially purge."
$purgeableResources += $deletedKeyVaults
}
if ($deletedKeyVaults) {
Write-Verbose "Found $($deletedKeyVaults.Count) deleted Key Vaults to potentially purge."
$purgeableResources += $deletedKeyVaults
}
} catch { }
return $purgeableResources
}