首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用node.js列出azure文件共享快照

使用node.js列出azure文件共享快照
EN

Stack Overflow用户
提问于 2021-03-31 01:12:50
回答 1查看 69关注 0票数 0

是否可以在node.js中列出文件共享拥有的快照列表?

示例代码:

代码语言:javascript
复制
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拥有的快照?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-31 08:57:58

因此,没有特殊的方法来列出文件共享的快照。需要调用ShareServiceClient (@azure/storage-file-share version 12.5.0)的listShares方法,includeSnapshots参数为true,共享名为prefix

下面是执行此操作的示例代码(未经测试的代码):

代码语言:javascript
复制
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);
})
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66875453

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档