Azure SQL bulk insert of CSV blob throws ''Cannot bulk load because the file "azure_test.csv" could not be opened. Operating system error code 5(Access is denied.).'

firebolt1110 1 Reputation point
2022-05-07T18:10:26.323+00:00

When I generate SAS from azure portal, bulk insert works fine. But when I generate SAS token from "generateBlobSASQueryParameters" class in my node.js application and execute bulk insert, i get access denied error. Below is the code.
const sasOptions = {
containerName,
blobName,
permissions: BlobSASPermissions.parse('r'),
startsOn: new Date(new Date().valueOf() - 86400 * 1000),
expiresOn: new Date(new Date().valueOf() + 86400 * 1000),
};
const sharedKeyCredential = new StorageSharedKeyCredential(
account_name,
account_key,
);
generateBlobSASQueryParameters(sasOptions, sharedKeyCredential).toString(),

Sample Token: sv=2020-10-02&st=2022-05-06T17:37:57Z&se=2022-05-08T17:37:57Z&sr=b&sp=r&sig=xxxxx

What could be the reason for access being denied?

Azure SQL Database
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,614 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. GeethaThatipatri-MSFT 29,012 Reputation points Microsoft Employee
    2022-05-09T22:40:14.843+00:00

    Hi, @firebolt1110 Welcome to Microsoft Q&A, Thanks for posting your query.
    Please confirm if you have followed all the pre requestions, please refer to this document

    I would start by comparing the two SAS signatures (i.e. the one that works and the one that doesn’t) and seeing what arguments are different. We would expect the signature and the time ones to be different, but the other options should be the same.
    You said “bulk insert works fine” from the portal, wouldn’t that require write, create, update permissions? check here
    Also when you say “bulk insert works fine”, are you talking about uploading one or many blobs? please confirm
    Regards
    Geetha


  2. firebolt1110 1 Reputation point
    2022-06-06T13:33:14.433+00:00

    Hello @GeethaThatipatri-MSFT , thank you for responding. after few trial and error, i was able to fix the issue. I was trying to upload one blob at a time, and then generate SAS token for that particular blob and then perform bulk insert.

    The signature, however is different from what is generated in the portal and what is generated in the NodeJS.