什么时候在 azure 中创建块 blob?

When was a block blob created in azure?

blob 引用包含一个 Properties 属性,它的 LastModifiedDateTimeOffset?。但是,我找不到 blob 的创建日期(时间)。是否有我可以使用的标准 API 或者我需要将其存储在元数据中?

    public async Task<IBlobMeta> GetBlobMetaAsync(string blobId)
        {
            if (IsNullOrWhiteSpace(blobId))
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(blobId));

            var blob = await EnsureGetBlobById(blobId);
            await blob.FetchAttributesAsync();

            string clientBlobName;
            blob.Metadata.TryGetValue(BlobNameMetaKey, out clientBlobName);

            var length = blob.Properties.Length;
            var md5 = blob.Properties.ContentMD5;
            var lastModified = blob.Properties.LastModified.Value.ToUniversalTime().DateTime;
            var dateCreated= blob.Properties.???????;
            return new AzureBlobMeta(blobId, clientBlobName, length, md5, dateCreated);
  }

Is there a standard API I can use or I need to store that in the meta?

从今天开始,您需要以 blob 元数据的形式存储此信息。没有 API 会告诉您何时创建了 blob。 blob 的 Last Modified 属性 告诉您上次修改 blob 的时间。这可能是因为 blob 的内容已更改,或者它的属性或元数据已更改。

已将 Created 日期 属性 添加到存储客户端库中,从 version 9.2.0 开始:

Blobs: Added support for blob creation time property.

(自 2018 年 5 月 23 日起在 Nuget 上可用)

BlobProperties.cs中是这样声明的:

/// <summary>
/// Gets the the creation time for the blob, expressed as a UTC value.
/// </summary>
/// <value>A <see cref="DateTimeOffset"/> containing the blob's creation time, in UTC format.</value>
public DateTimeOffset? Created { get; internal set; }

类型为可为空的DateTimeOffset,等同于LastModified 属性.


值的来源来自RESTAPI中的x-ms-creation-timeheader,在version 2017-11-09中添加:

x-ms-creation-time Version 2017-11-09 and newer. The date/time at which the blob was created. The date format follows RFC 1123.

它在 class CloudBlob 中可用,然后 Properties.CreatedMicrosoft.Azure.Storage.Blob