简体   繁体   中英

List folder in Azure Gen2 storage account with sas

I generated a sas token with the list permission for a folder in a datalake storage account gen2.
Howerver when I try to access it with an httpGet request, I get AuthorizationPermissionMismatch error This request is not authorized to perform this operation using this permission
I know that to list a container with httpRequest we have to add &comp=list&restype=container in the queryString. Is there any specific param to add for listing a folder
Thanks

Once you have generated the SAS token on the container level using the required permissions. You can add a directory filter in the rest API like below:

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

I tested the same in my environment. I created ADLS Gen 2 Storage account, a test container and then a directory named as Folder and added few files in it as shown below:

在此处输入图像描述

Then using SAS generated on container level, I called the below 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

Output:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM