在 Azure 存储中查找软删除 blob 的永久删除日期

Find permanent deletion date for soft deleted blobs in Azure Storage

几周前,我在受软删除保护的 Azure 存储帐户中删除了很多 blob (50TB+)。软删除配置了14天的保留,后来我改成了7天。

然而,14 天过去了,这些 blob 仍然没有被永久删除,因为我在 Azure 门户中选择 'Show deleted blobs' 时仍然可以看到它们。 这也意味着我仍然需要支付存储费用。

有没有办法找出 blob 的实际删除日期?我在 Insights 下也看到已用容量仍然没有变化。

如果您使用的是 REST API,当您列出带有 deleted 作为 include 参数值之一的 blob(以便列表结果包含软删除的 blob ),您可以通过检查结果中的两个属性找到此信息:

  • Deleted-Time: 它会告诉你 date/time blob 被删除的时间。
  • RemainingRetentionDays:它会告诉您剩余天数,之后 blob 将从存储中永久删除。

从这个link:

For version 2017-07-29 and above, Deleted, DeletedTime and RemainingRetentionDays appear when this operation includes the include={deleted} parameter. These elements do not appear if this blob was not deleted. These elements appear for blob or snapshot that are deleted with DELETE operation when soft delete feature was enabled. Deleted element is set to true for blobs and snapshots that are soft deleted. Deleted-Time corresponds to time when the blob was deleted. RemainingRetentionDays indicates number of days after which soft deleted blob will be permanently deleted by blob service.

如果您正在使用 Azure.Storage.Blobs (.Net SDK), you will find this information in the following properties: BlobItemProperties.DeletedOn and BlobItemProperties.RemainingRetentionDays

对于其他语言,您可以在相应的 SDK 中搜索类似的属性。

更新

请尝试以下操作:

$context = New-AzStorageContext -StorageAccountName account-name -StorageAccountKey account-key
$blobs = Get-AzStorageBlob -Container 001-000 -IncludeDeleted -Context $context
$blobs.ICloudBlob.Properties | ConvertTo-Json

输出将类似于以下内容。下面的第一个 blob 没有被删除,因此 DeletedTimeRemainingDaysBeforePermanentDelete 将为空。第二个 blob 是软删除的,它将填充这些值。

{
    "CacheControl":  null,
    "ContentDisposition":  null,
    "ContentEncoding":  null,
    "ContentLanguage":  null,
    "Length":  89,
    "ContentMD5":  "nax+W2kkfQqP8+K6dj2uFw==",
    "ContentType":  "image/svg+xml",
    "ETag":  "\"0x8D951D0C90A29CA\"",
    "Created":  "\/Date(1627481141000)\/",
    "LastModified":  "\/Date(1627481141000)\/",
    "BlobType":  2,
    "LeaseStatus":  2,
    "LeaseState":  1,
    "LeaseDuration":  0,
    "PageBlobSequenceNumber":  null,
    "AppendBlobCommittedBlockCount":  null,
    "IsServerEncrypted":  true,
    "IsIncrementalCopy":  false,
    "StandardBlobTier":  null,
    "RehydrationStatus":  null,
    "PremiumPageBlobTier":  null,
    "BlobTierInferred":  null,
    "BlobTierLastModifiedTime":  null,
    "DeletedTime":  null,
    "RemainingDaysBeforePermanentDelete":  null
},
{
    "CacheControl":  null,
    "ContentDisposition":  null,
    "ContentEncoding":  null,
    "ContentLanguage":  null,
    "Length":  98024,
    "ContentMD5":  "/uZucSqKCO71gFpGiSkyrQ==",
    "ContentType":  "application/font-woff",
    "ETag":  "\"0x8D951D0C90AC631\"",
    "Created":  "\/Date(1627481141000)\/",
    "LastModified":  "\/Date(1627481141000)\/",
    "BlobType":  2,
    "LeaseStatus":  0,
    "LeaseState":  0,
    "LeaseDuration":  0,
    "PageBlobSequenceNumber":  null,
    "AppendBlobCommittedBlockCount":  null,
    "IsServerEncrypted":  true,
    "IsIncrementalCopy":  false,
    "StandardBlobTier":  null,
    "RehydrationStatus":  null,
    "PremiumPageBlobTier":  null,
    "BlobTierInferred":  null,
    "BlobTierLastModifiedTime":  null,
    "DeletedTime":  "\/Date(1627481162000)\/",
    "RemainingDaysBeforePermanentDelete":  9
}