使用 az 工具检查密钥保管库的创建时间

Use az tool to check when key vaults were created

我需要检查在 Azure 中创建密钥保管库(不是密钥)的时间。 Keyvault show 似乎没有给我那个信息。谁能指出我正确的方向?

az keyvault show --name 

谢谢

您可以使用 az group deployment show 获取资源组中密钥库的部署,timestamp 就是您想要的。

az group deployment show --name <keyvualt-name> --resource-group <resource-group-name>

注意:以上命令仅适用于在门户中或通过 ARM 模板创建的密钥库(需要更改名称参数),如果您使用 powershell 或 cli 命令来创建keyvault,组中没有部署信息,选项是使用az monitor activity-log list获取你组的日志,但日志只存在90天,操作只会显示为Update Key vault,所以我们无法知道它实际上是 Create 还是 Update

您必须直接调用 REST API 才能获得此功能。您可以列出 Microsoft.KeyVault/vaults 类型的资源并使用 $expand=createdTime。有关详细信息,请参阅 https://docs.microsoft.com/en-us/rest/api/resources/resources/list

这是订阅范围内的示例,但如果您知道目标 Key Vault 的位置,也可以在资源组范围内执行此操作。

az rest --method GET --uri "https://management.azure.com/subscriptions/1237f4d2-3dce-4b96-ad95-677f764e7123/resources?$expand=createdTime&$filter=resourceType eq 'Microsoft.KeyVault/vaults'&api-version=2020-06-01"

{
  "value": [
    {
      "createdTime": "2019-11-07T22:02:10.6437781Z",
      "id": "/subscriptions/1237f4d2-3dce-4b96-ad95-677f764e7123/resourceGroups/CSSAutomation-xxx/providers/Microsoft.KeyVault/vaults/CSSAutomationVault-xxx",
      "location": "centralus",
      "name": "CSSAutomationVault-xxx",
      "resourceGroup": "CSSAutomation-xxx",
      "tags": {},
      "type": "Microsoft.KeyVault/vaults"
    },
    {
      "createdTime": "2019-11-04T14:57:25.8974771Z",
      "id": "/subscriptions/1237f4d2-3dce-4b96-ad95-677f764e7123/resourceGroups/rgKeyVault/providers/Microsoft.KeyVault/vaults/KeyVaultTestyyy",
      "location": "northcentralus",
      "name": "KeyVaultTestyyy",
      "resourceGroup": "rgKeyVault",
      "tags": {},
      "type": "Microsoft.KeyVault/vaults"
    }
  ]
}