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

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 = {
permissions: BlobSASPermissions.parse('r'),
startsOn: new Date(new Date().valueOf() - 86400 * 1000),
expiresOn: new Date(new Date().valueOf() + 86400 * 1000),
const sharedKeyCredential = new StorageSharedKeyCredential(
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

    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

  2. firebolt1110 1 Reputation point

    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.