I have a URL for an Azure Container (i.e. https://<redacted>.blob.core.windows.net/<redacted>?sp=r&st=202*-**-**T18:56:55Z&se=202*-**-**T03:56:55Z&spr=https&sv=202*-**-**&sr=c&sig=vlAq<redacted>%3D
). I want to list all the files in a “folder” (/test/datadrive/outbound/
). I have tried both of the following and receive an error.
var host = "https://<redacted>.blob.core.windows.net/<redacted>?sp=r&st=202*-**-**T18:56:55Z&se=202*-**-**T03:56:55Z&spr=https&sv=202*-**-**&sr=c&sig=vlAq<redacted>%3D";
var sorucePath = "/test/datadrive/outbound/";
var blobServiceClient = new BlobServiceClient(new Uri(host));
var blobContainerClient = blobServiceClient.GetBlobContainerClient(sourcePath);
var blobs = blobContainerClient.GetBlobsAsync();
foreach (var blob in blobs
{
// do something here
}
This results in an exception stating The requested URI does not represent any resource on the server.
I have also tried the following:
var host = "https://<redacted>.blob.core.windows.net/<redacted>?sp=r&st=202*-**-**T18:56:55Z&se=202*-**-**T03:56:55Z&spr=https&sv=202*-**-**&sr=c&sig=vlAq<redacted>%3D";
var sorucePath = "/test/datadrive/outbound/";
var blobContainerClient = new BlobContainerClient(new Uri(_options.Host));
var blobs = blobContainerClient.GetBlobsAsync(prefix: sourcePath);
foreach (var blob in blobs
{
// do something here
}
This returns an exception stating Azure.RequestFailedException: This request is not authorized to perform this operation.
With the information I have, how can I get the list of files I’m looking for?
0
The reason you are getting this error is because your SAS Token is missing List
permission. In order to list blobs inside a container, you need this permission. Read
permission is for reading the contents of the blob.
To fix this issue, please use a SAS Token that has list permission in it (something like sp=rl
).