HTTP 403 cloud auth_error ai_generated true

Microsoft.Azure.KeyVault.Models.KeyVaultErrorException:操作返回无效状态代码'Forbidden'

Microsoft.Azure.KeyVault.Models.KeyVaultErrorException: Operation returned an invalid status code 'Forbidden'

ID: cloud/azure-key-vault-secret-expiration

其他格式: JSON · Markdown 中文 · English
84%修复率
84%置信度
1证据数
2024-04-25首次发现

版本兼容性

版本状态引入弃用备注
Azure Key Vault REST API 7.0 active
.NET SDK 3.0.5 active

根因分析

Azure Key Vault密钥已过期或已禁用,即使权限有效也会导致访问被拒绝。

English

Azure Key Vault secret has expired or been disabled, causing access to be denied even with valid permissions.

generic

官方文档

https://learn.microsoft.com/en-us/azure/key-vault/secrets/about-secrets

解决方案

  1. Update the secret's expiration date using Azure CLI: `az keyvault secret set-attributes --vault-name MyVault --name MySecret --expires 2026-12-31T23:59:59Z`
  2. Enable soft-delete and purge protection, then restore a previous version of the secret if available: `az keyvault secret restore --vault-name MyVault --file backup.json`
  3. Create a new secret with a new name and update the application configuration to reference it

无效尝试

常见但无效的做法:

  1. 80% 失败

    Access policies are not the issue; the secret itself is expired, so re-adding policies does not restore access.

  2. 90% 失败

    Restarting does not renew the expired secret; it only clears the cache, and the same expired secret is fetched again.

  3. 70% 失败

    Changing the value does not reset the expiration date; the secret remains expired unless the expiration date is explicitly updated.