是否可以在node.js中列出文件共享拥有的快照列表?
示例代码:
const { ShareServiceClient, StorageSharedKeyCredential } = require("@azure/storage-file-share");
const credential = new StorageSharedKeyCredential(AZURE_STORAGE_ACCOUNT,AZURE_STORAGE_ACCESS_KEY);
const shareServiceClient = new ShareServiceClient(AZURE_STORAGE_CONNECTION_STRING,credential);
var shareName = "xxxxx";
var shareClient = shareServiceClient.getShareClient(shareName);
// Create a snapshot:
await shareClient.createSnapshot();如何列出此shareName拥有的快照?
发布于 2021-03-31 08:57:58
因此,没有特殊的方法来列出文件共享的快照。需要调用ShareServiceClient (@azure/storage-file-share version 12.5.0)的listShares方法,includeSnapshots参数为true,共享名为prefix。
下面是执行此操作的示例代码(未经测试的代码):
const shareName = 'share-name';
const listingOptions = {
prefix: shareName,
includeSnapshots: true
};
shareServiceClient.listShares(listingOptions).byPage().next()
.then((result) => {
const shareItems = result.value.shareItems;
//Filter results where name of the share is same as share name and is a snapshot
const shareSnapshots = shareItems.filter(s => s.name === shareName && s.snapshot && s.snapshot !== '');
console.log(shareSnapshots);
})
.catch((error) => {
console.log(error);
})https://stackoverflow.com/questions/66875453
复制相似问题