不允许操作 'DeletedVaultPurge' - 尝试清除 Azure Key Vault

Operation 'DeletedVaultPurge' is not allowed - trying to purge Azure Key Vault

我正在使用我的个人 Azure 帐户和 Visual Studio Azure 订阅,我是全局管理员。当我尝试清除软删除的 Azure Key Vault 时出现以下错误。

使用 Azure Power Shell:

Remove-AzKeyVault: Operation 'DeletedVaultPurge' is not allowed.

使用 Azure CLI:

ValidationError: (MethodNotAllowed) Operation 'DeletedVaultPurge' is not allowed.

似乎有一个我没有的权限,即使我是全局管理员。那么我需要做什么才能清除软删除的 Key Vault?

以下是我可以用来重现错误的 Azure Power Shell (4.7.0) 中的步骤:

首先我创建了一个 Key Vault:

New-AzKeyVault -Name $keyVaultName -ResourceGroupName $resourceGroupName -Location $location -EnablePurgeProtection

那我删了

Remove-AzKeyVault -Name $keyVaultName -ResourceGroupName $resourceGroupName

然后尝试清除软删除的 Key Vault:

Remove-AzKeyVault -Name $keyVaultName -Location $location -InRemovedState -Force

Remove-AzKeyVault: Operation 'DeletedVaultPurge' is not allowed.

原因是您在创建密钥库时有 enabled the Purge protection

一旦Purge protection is enabled,不允许删除。详情请参考doc。我刚刚粘贴了部分文档,如下所示:

打开清除保护后,在保留期结束之前,无法清除处于已删除状态的保管库或对象。

另请注意,如果启用了清除保护,则无法将其禁用。因此在创建密钥库时,请确保 Purge protection is disabled,然后重试该命令。