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.

Support for `UserDelegationKey`

See original GitHub issue

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

blob

Which version of the Azurite was used?

3.9.0

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

npm

What’s the Node.js version?

v12.16.2

What problem was encountered?

Trying to generate a SAS using a TokenCredential instead of a connection string fails because it requires a user delegation key. Azurit does not (yet) support retrieving a user delegation key.

Azure.RequestFailedException : Current API is not implemented yet. Please vote your wanted features to https://github.com/azure/azurite/issues
RequestId:a6cae55a-8b72-48bd-8d2c-357d942bdb9b
Time:2020-12-10T14:15:41.547Z
Status: 500 (Current API is not implemented yet. Please vote your wanted features to https://github.com/azure/azurite/issues)
ErrorCode: APINotImplemented

Headers:
Server: Azurite-Blob/3.9.0
x-ms-error-code: APINotImplemented
x-ms-request-id: a6cae55a-8b72-48bd-8d2c-357d942bdb9b
Date: Thu, 10 Dec 2020 14:15:41 GMT
Connection: keep-alive
Transfer-Encoding: chunked
Content-Type: application/xml

Steps to reproduce the issue?

Invoke BlobServiceClient.GetUserDelegationKeyAsync(...)

Have you found a mitigation/solution?

No, but if there is a different way to configure a static/fake user delegation key that would solve my issue as well.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:17
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
bluewwcommented, Nov 28, 2022

We already have a PR for User delegation key https://github.com/Azure/Azurite/pull/1753, the PR is being review.

1reaction
kaylumahcommented, Oct 19, 2022
private async Task<Uri> GenerateSasToken(BlobBaseClient blobClient, TimeSpan expiresAfter)
        {
            var dateNow = DateTimeOffset.UtcNow;
            var dateExpiresOn = dateNow.Add(expiresAfter);
            var sasBuilder = new BlobSasBuilder
            {
                BlobContainerName = blobClient.BlobContainerName,
                BlobName = blobClient.Name,
                Resource = "b",
                StartsOn = dateNow,
                ExpiresOn = dateExpiresOn
            };
            sasBuilder.SetPermissions(BlobSasPermissions.Read);
            if (blobClient.CanGenerateSasUri)
            {
                return blobClient.GenerateSasUri(sasBuilder);
            }

            var userDelegationKey = await _blobServiceClient.GetUserDelegationKeyAsync(dateNow, dateExpiresOn);
            var blobUriBuilder = new BlobUriBuilder(blobClient.Uri)
            {
                Sas = sasBuilder.ToSasQueryParameters(userDelegationKey, _blobServiceClient.AccountName)
            };
            return blobUriBuilder.ToUri();
        }

I am using C# to generate a token url.

If you use the https connection string (default endpoint protocol etc) it goes in the If CanGenerateSasUri, but if you use token credential for example Azure CLI Credential, you need to get the user key t generate a sas url

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create a user delegation SAS - Azure Storage - Microsoft Learn
To get the user delegation key, first request an OAuth 2.0 token from Azure AD. Provide the token with the Bearer scheme to...
Read more >
azure-docs/storage-blob-user-delegation-sas-create-dotnet ...
The user delegation key is analogous to the account key used to sign a service SAS or an account SAS, except that it...
Read more >
How to create user delegation SAS after getting User ...
I am able to generate the delegation key and now I want to get SAS Token by using this user delegation key. Note...
Read more >
Generating Azure Blob Storage User Delegation SAS
This technique is called a "user delegation" SAS, and it allows you to sign the signature with Azure AD credentials instead of with...
Read more >
User Delegation SAS — Azure Storage Account | by Avanish
User Delegation SAS — It is signed with Azure AD Credentials of user/service principal instead of Azure storage keys.
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