question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Azurite SAS query token access to blob file

See original GitHub issue

Which service(blob, file, queue, table) does this issue concern?

blob

Which version of the Azurite was used?

$ docker run --rm mcr.microsoft.com/azure-storage/azurite:latest azurite --version           
3.15.0

Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)

mcr.microsoft.com/azure-storage/azurite:latest

What’s the Node.js version?

/opt/azurite # node --version
v14.17.0

What problem was encountered?

SAS token access does not work when the connect string references service endpoints not running on localhost, as per default.

Steps to reproduce the issue?

I am using two separate containers, one called “azurite” running azurite, and one called “func” that hosts the local Azure Function App development environment. If I run the function app stack on the host directly and use a connection string that references localhost (and export those ports as per documentation on Azurite) it works.

The following code will give me an URL that I can access in Azure, but Azurite will give a 403.

    import { BlobClient, BlobSASPermissions } from '@azure/storage-blob'

    try {
        const blobName = "input.json"
        const client = new BlobClient(connectionString, "invoices", blobName)
        const options = {
            permissions: BlobSASPermissions.from({ read: true }),
            expiresOn: new Date(Date.now() + 24 * 3600 * 1000),
            // startsOn: new Date(Date.now() - 300 * 1000),
            // protocol: SASProtocol.HttpsAndHttp,
        }
        //const url = (await client.generateSasUrl(options)).replace(/%2F/g,"/")
        const url = await client.generateSasUrl(options)
        context.log(url)
    }
    catch (err) {
        console.log(err)
    }

Have you found a mitigation/solution?

No

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bpossolocommented, May 10, 2022

try upgrading to azurite 3.17.1 there were several bugs related to SAS validation in azurite versions < 3.17.0

see here for some examples:

0reactions
hholst80commented, Nov 20, 2022

I will look into it this weekend hopefully.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create SAS tokens for your storage containers - Microsoft Learn
How to create Shared Access Signature tokens (SAS) for containers and blobs with Microsoft Storage Explorer and the Azure portal.
Read more >
How to Generate an Azure SAS Token to Access Storage ...
Learn how to create an Azure SAS token both via the Azure portal and via PowerShell to authenticate and authorize Azure storage management....
Read more >
Azure Blob Storage SAS Guidelines
Azure Blob Storage provides the concept of “shared access ... Sometimes I see code that passes just the SAS token, and the name...
Read more >
Azurite V3 - npm
Blob storage features align with Azure Storage API version 2020-10-02 ... SharedKey/Account SAS/Service SAS/Public Access Authentications ...
Read more >
Azure Blob how to properly create and consume a SAS token
After much trial and error my ways to fix it were as follows: Use latest version of azurite from Microsoft, I used the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found