使用 sas 列出 Azure Gen2 存储帐户中的文件夹

List folder in Azure Gen2 storage account with sas

我为数据湖存储帐户 gen2 中的文件夹生成了一个具有列表权限的 sas 令牌。
但是,当我尝试使用 httpGet 请求访问它时,出现 AuthorizationPermissionMismatch 错误 This request is not authorized to perform this operation using this permission
我知道要使用 httpRequest 列出容器,我们必须在 queryString 中添加 &comp=list&restype=container。是否有任何特定参数要添加以列出文件夹
谢谢

使用所需权限在容器级别生成 SAS 令牌后。您可以在其余 API 中添加目录过滤器,如下所示:

https://<StorageURL>/<Container>?directory=<DirectoryName>&restype=container&comp=list&<SASToken>

我在我的环境中进行了同样的测试。我创建了 ADLS Gen 2 存储帐户,一个测试容器,然后是一个名为文件夹的目录,并在其中添加了几个文件,如下所示:

然后使用在容器级别生成的 SAS,我调用了下面的 Rest API :

https://adlsgen2ansuman.blob.core.windows.net/test?directory=folder&restype=container&comp=list&sp=racwdlmeop&st=2022-02-03T06:55:43Z&se=2022-02-03T14:55:43Z&spr=https&sv=2020-08-04&sr=c&sig=xxxxxxxxxxxxxxxxxx

输出: