Im using some code I found on another thread to generate a SAS uri. However, when I try to use the generated url in a browser window, I get the error “AuthenticationFailed” “Server failed to authenticate the request. Make sure the value of the authorization header is formed correctly including the signature….”
If I generate the SAS url from the portal for a given blob, it works fine.
Azure.Storage.Sas.BlobSasBuilder blobSasBuilder = new Azure.Storage.Sas.BlobSasBuilder()
{
BlobContainerName = "container/incoming",
BlobName = "testfile.pdf",
ExpiresOn = DateTime.UtcNow.AddMinutes(5),//Let SAS token expire after 5 minutes.
};
blobSasBuilder.SetPermissions(Azure.Storage.Sas.BlobSasPermissions.Read);//User will only be able to read the blob and it's properties
var sasToken = blobSasBuilder.ToSasQueryParameters(new StorageSharedKeyCredential(accountName, accountKey)).ToString();
var sasUrl = blobClient.Uri.AbsoluteUri + "?" + sasToken;