Sharefile signed url is randomly giving AuthenticationFailed error

mamounx馬木 tawakol 0 Reputation points
2023-05-10T10:18:23.8466667+00:00

Hi,

I am facing a random authentication failure error for each SAS URI that is being generated. I am using the NodeJs library @azure/storage-file-share. I couldn't find the pattern of why the error is happening, some generated URIs work using the same code, and others don't.

On the other hand, I tried to generate it using Azure Portal through "Shared access signature" and it worked perfectly, however; that's not a safe solution as it's preferable to be generated for no more than 24h.

My failing attempts to solve it:

  • I added timezone, I know in the code it's static but this is only for development.
  • change permission rights to rwdlc
  • Try with different params (I think the issue is about params, but I still don't understand why it works randomly please if there is any explanation)

Thank you!

Code:

const fileClient = this.shareServiceClient
        .getShareClient(this.shareName)
        .getDirectoryClient(STORAGE_RESULT_PATH)
        .getFileClient(fileName);

const timezoneOffset = +3 * 60;
const startDate = new Date();
const expiryDate = new Date(startDate);          
expiryDate.setHours(startDate.getHours() + timezoneOffset + (24*60));
startDate.setMinutes(startDate.getMinutes() + timezoneOffset );
const downloadFileResponse = fileClient.generateSasUrl({
        permissions: AccountSASPermissions.parse('r'),
        expiresOn: expiryDate,
        startsOn: startDate
      });

Error and URI params for failing attempt:

URI Params

User's image

Flow for error randomness:

Flow GIF

Azure Storage
Azure Storage
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.