I am using the following code to give users access to a single file in my blob storage via a Shared Access Signature (SAS):
var container = _blobClient.GetContainerReference(containerPath[0]);
var blob = container.GetBlockBlobReference(blobName);
var policy = new SharedAccessBlobPolicy()
{
SharedAccessStartTime = DateTimeOffset.UtcNow,
SharedAccessExpiryTime = DateTime.UtcNow.AddHours(24),
Permissions = SharedAccessBlobPermissions.Read
};
var blobHeaders = new SharedAccessBlobHeaders();
var sasToken = blob.GetSharedAccessSignature(policy, blobHeaders);
return blob.Uri.AbsoluteUri + sasToken;
The token I am creating is created but it doesn't work, I get the following error:
Signature did not match. String to sign used was r 2019-06-07T09:19:05Z 2019-06-08T09:19:05Z /blob/X/filestore/images/company/X.jpeg 2018-11-09 b
Where filestore/images/company/
is the directory and X.jpeg
is my file name.
My blob container is private.
I've tried most of the options that have been provided to questions on a similar theme but not sure where I am going wrong. I created a Shared Access Signature via the Azure portal for this blob and it worked just fine. Any ideas?