Skip to content

Commit 40b4989

Browse files
azure-sdkbenbp
andauthored
Temporarily disable error handling for Get-AzKeyVault -InRemovedState (Azure#19941)
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
1 parent 34b3691 commit 40b4989

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

eng/common/scripts/Helpers/Resource-Helpers.ps1

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,23 @@ function Get-PurgeableResources {
7575

7676
Write-Verbose "Retrieving deleted Key Vaults from subscription $subscriptionId"
7777

78-
# Get deleted Key Vaults for the current subscription.
79-
$deletedKeyVaults = @(Get-AzKeyVault -InRemovedState `
80-
| Add-Member -MemberType NoteProperty -Name AzsdkResourceType -Value 'Key Vault' -PassThru `
81-
| Add-Member -MemberType AliasProperty -Name AzsdkName -Value VaultName -PassThru)
78+
# TODO: Remove try/catch handler for Get-AzKeyVault - https://github.com/Azure/azure-sdk-tools/issues/5315
79+
# This is a temporary workaround since Az module >= 9.2.0 uses a more recent API
80+
# version than is supported in the dogfood cloud environment:
81+
#
82+
# | The resource type 'deletedVaults' could not be found in the namespace 'Microsoft.KeyVault' for api version '2022-07-01'. The supported api-versions are
83+
# | '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'.
84+
try {
85+
# Get deleted Key Vaults for the current subscription.
86+
$deletedKeyVaults = @(Get-AzKeyVault -InRemovedState `
87+
| Add-Member -MemberType NoteProperty -Name AzsdkResourceType -Value 'Key Vault' -PassThru `
88+
| Add-Member -MemberType AliasProperty -Name AzsdkName -Value VaultName -PassThru)
8289

83-
if ($deletedKeyVaults) {
84-
Write-Verbose "Found $($deletedKeyVaults.Count) deleted Key Vaults to potentially purge."
85-
$purgeableResources += $deletedKeyVaults
86-
}
90+
if ($deletedKeyVaults) {
91+
Write-Verbose "Found $($deletedKeyVaults.Count) deleted Key Vaults to potentially purge."
92+
$purgeableResources += $deletedKeyVaults
93+
}
94+
} catch { }
8795

8896
return $purgeableResources
8997
}

0 commit comments

Comments
 (0)