[英](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.