简体   繁体   English

(Azure 存储 - nodeJS)获取应用于 blob 容器和队列的 SAS 策略

[英](Azure Storage - nodeJS) Getting SAS policies that are applied on blob container and queue

I'm trying to get the expiration date of the SAS policies that are applied on blob container and queue.我正在尝试获取应用于 blob 容器和队列的 SAS 策略的到期日期。 I'm able to get the information via powershell with the Get-AzStorageQueueStoredAccessPolicy and Get-AzStorageContainerStoredAccessPolicy but I cannot find a way to look a way to do the same via nodeJS.我可以使用 Get-AzStorageQueueStoredAccessPolicy 和 Get-AzStorageContainerStoredAccessPolicy 通过 powershell 获取信息,但我找不到通过 nodeJS 寻找方法的方法。

I've went trough the MS node sdk for storage, i was able to find a way to setup the SAS policy but not to retrieve an existing one.我已经通过 MS 节点 sdk 进行存储,我能够找到一种方法来设置 SAS 策略但不能检索现有策略。

Do I need to go trough the ms graph?我需要通过 ms 图表 go 吗?

Thank you for your help.谢谢您的帮助。

To get the access policies for a blob container, the method you would want to use is getAccessPolicy() which is in ContainerClient class.要获取 blob 容器的访问策略,您要使用的方法是getAccessPolicy() ,它位于ContainerClient class 中。

import {BlobServiceClient} from '@azure/storage-blob';

const connectionString = "your-storage-account-connection-string";
const containerName = "your-container-name";
const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString);
const containerClient = blobServiceClient.getContainerClient(containerName);
const accessPolicyResult = await containerClient.getAccessPolicy();
console.log(accessPolicyResult.signedIdentifiers);//access policies are defined in "signedIdentifiers"

Similarly to get the access policies for a queue, the method you would to use is getAccessPolicy() which is in QueueClient class.与获取队列的访问策略类似,您将使用的方法是getAccessPolicy() ,它位于QueueClient class 中。

import {QueueServiceClient} from '@azure/storage-queue';

const connectionString = "your-storage-account-connection-string";
const queueName = "your-queue-name";
const queueServiceClient = QueueServiceClient.fromConnectionString(connectionString);
const queueClient = queueServiceClient.getQueueClient(queueName);
const accessPolicyResult = await queueClient.getAccessPolicy();
console.log(accessPolicyResult.signedIdentifiers);//access policies are defined in "signedIdentifiers"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何删除Blob存储容器天蓝色NodeJS - how to delete blob storage container azure NodeJS 使用 SAS (NODEJS) 从 azure blob 存储创建可共享 URI - Create shareable URI from azure blob storage with SAS (NODEJS) 使用 nodejs 在 SDK v10 中获取 sasQueryParameter 后,如何将文件上传到 Azure 存储 blob 容器? - how to upload a file to Azure storage blob Container after getting sasQueryParameter in SDK v10 using nodejs? Nodejs Azure存储副本Blob到新Blob - Nodejs Azure Storage Copy Blob to New Blob 使用'azure-storage'npm生成Blob存储的SAS无法正常工作 - Generating SAS for Blob Storage using 'azure-storage' npm not working 如何使用 @azure/arm-storage nodejs 将 cors 添加到 Blob 容器 - How do I add cors to a Blob Container using @azure/arm-storage nodejs SharedKeyCredential 不是构造函数 - Azure Blob 存储 + Nodejs - SharedKeyCredential is not a constructor - Azure Blob Storage + Nodejs 如何使用 nodejs 在 azure blob 存储上设置 contenttype - How to set contenttype on azure blob storage with nodejs getmetadata用于Azure Blob存储NodeJ中的一系列Blob - getmetadata for a selection of blobs in Azure Blob Storage NodeJs Azure Webapp(使用Node.js)记录到Blob存储 - Azure Webapp (using Nodejs) logging to Blob storage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM