如何在 Blob 触发函数应用程序中获取 Blob 存储的最新快照?
我正在尝试接收 blob 的最新快照,并将其与最新的 blob 内容进行比较,以更新增量/内容(删除、删除或添加到文件中的新内容,文件中包含 json 内容)。为此,我需要获取最新的快照,并查看 azure sdk 是否提供了这样做的功能?
下面是实现逻辑:
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient("foo");
BlobClient blob = containerClient.GetBlobClient(pathtotheblobcontentfileinthecontainer);
var resultSegment = containerClient.GetBlobsAsync(prefix: PREFIX+path, states: BlobStates.Snapshots);
I am trying to receive the latest snapshot of the blob and compare it against the latest blob content to get the delta/ the content updated(either deleted, removed or new content added to the file, file has json content in it). For this, I'll need to get the latest snapshot and was seeing if the azure sdk provides the feature to do so?
Here is the implementation logic:
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient("foo");
BlobClient blob = containerClient.GetBlobClient(pathtotheblobcontentfileinthecontainer);
var resultSegment = containerClient.GetBlobsAsync(prefix: PREFIX+path, states: BlobStates.Snapshots);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SDK不提供此功能。您需要做的是获取 blob 的所有快照。这将返回按升序排列的 Blob 快照列表(即从最旧到最新)。
获得此列表后,您将需要反转该列表,以便获得最新的快照作为该列表的第一个元素。
SDK does not provide this feature. What you will need to do is fetch all snapshots for a blob. This will return a list of blob snapshots in ascending order (i.e. from oldest to newest).
Once you have this list, you will need to reverse that list so that you get the newest snapshot as the first element of that list.