Home > Back-end >  Shared Access Signature URL returns The requested URL does not represent any resource on the server
Shared Access Signature URL returns The requested URL does not represent any resource on the server

Time:02-03

using my Visual Studio Enterprise subscription, I can create a SAS from a blob. It looks like this. I created this from console, so quite confident about it

https://[mystorageaccounthere].blob.core.windows.net/[thecontainernamehere]?sp=r&st=2022-02-02T21:25:10Z&se=2022-02-03T05:25:10Z&spr=https&sv=2020-08-04&sr=c&sig=[the signtaure]

Then I try out a sample taken from Azure Storage samples to get the properties.

Uri mySASUri = new Uri(Environment.GetEnvironmentVariable("SAS_URL"));
BlobServiceClient service = new BlobServiceClient(mySASUri);
await service.GetPropertiesAsync();

Result is an exception

Unhandled exception. Azure.RequestFailedException: The requested URI does not represent any resource on the server.

any ideas

Thanks to all who look into this

CodePudding user response:

The reason you are getting this error is because you are using an incorrect type of SAS token (URL). You are creating a SAS token on the container which is a Service SAS kind of token which will only work on the container (or blob) for which The SAS token is acquired.

Considering BlobServiceClient.GetPropertiesAsync() is an account level operation, you would need to create an Account SAS token and use that to perform this operation.

Please create an Account SAS URL with at least read permission and use that in your code and you should not get this error.

  •  Tags:  
  • Related