Comments (4)
"getUserDelegationKey" only support Oauth (Microsoft Entra ID) authentication. This is same in both product Azure and Azurite.
However, you are trying to call it with sharedkey authentication so the failure happen, this is by design in both product Azure and Azurite.
See more details in the rest API doc and feature doc:
https://learn.microsoft.com/en-us/rest/api/storageservices/get-user-delegation-key#authorization
https://learn.microsoft.com/en-us/rest/api/storageservices/create-user-delegation-sas
BTW, to enable Oauth authentication with Azurite, you need to start Azurite with https and Oauth configuration, see https://github.com/Azure/Azurite?tab=readme-ov-file#oauth-configuration
And for Oauth, Azurite will do basic authentication, like validating incoming bearer token, checking issuer, audience, expiry. But Azurite will NOT check token signature and permission.
I will close this issue as it's by design.
Feel free to contact us again if you need any further assistance on Azurite.
from azurite.
BTW, to enable Oauth authentication with Azurite, you need to start Azurite with https and Oauth configuration, see https://github.com/Azure/Azurite?tab=readme-ov-file#oauth-configuration
And for Oauth, Azurite will do basic authentication, like validating incoming bearer token, checking issuer, audience, expiry. But Azurite will NOT check token signature and permission.
Can you give me an example of how to create a test blob client w/ oauth instead of using the emulator connection string?
from azurite.
I ended up w/ this, is this what you meant?
// See https://aka.ms/new-console-template for more information
using Azure.Core;
using Azure.Storage.Blobs;
Console.WriteLine("Hello, World!");
var client = new BlobServiceClient(new Uri(@"https://localhost:10000/devstoreaccount1"), new TestTokenCredentials());
var key = await client.GetUserDelegationKeyAsync(DateTimeOffset.UtcNow, DateTimeOffset.UtcNow.AddDays(10));
Console.WriteLine(key);
return;
class TestTokenCredentials : TokenCredential
{
public TestTokenCredentials()
{
}
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
{
return new AccessToken("test", DateTimeOffset.UtcNow.AddDays(1));
}
public override ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
{
return ValueTask.FromResult(new AccessToken("test", DateTimeOffset.UtcNow.AddDays(1)));
}
}
from azurite.
I ended up w/ this, is this what you meant?
// See https://aka.ms/new-console-template for more information using Azure.Core; using Azure.Storage.Blobs; Console.WriteLine("Hello, World!"); var client = new BlobServiceClient(new Uri(@"https://localhost:10000/devstoreaccount1"), new TestTokenCredentials()); var key = await client.GetUserDelegationKeyAsync(DateTimeOffset.UtcNow, DateTimeOffset.UtcNow.AddDays(10)); Console.WriteLine(key); return; class TestTokenCredentials : TokenCredential { public TestTokenCredentials() { } public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken) { return new AccessToken("test", DateTimeOffset.UtcNow.AddDays(1)); } public override ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken) { return ValueTask.FromResult(new AccessToken("test", DateTimeOffset.UtcNow.AddDays(1))); } }
We are Azurite owner, but not .net SDK expert, so might not be the best person to give the usage of .net SDK.
Here's a .net SDK example for you reference.
https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-dotnet?tabs=visual-studio%2Cmanaged-identity%2Croles-azure-portal%2Csign-in-visual-studio%2Cidentity-visual-studio&pivots=blob-storage-quickstart-scratch#sign-in-and-connect-your-app-code-to-azure-using-defaultazurecredential
For your above code, it might not work with Azurite, since Azurite will do some basic validation on the token (see details). So use string like "test" as the token won't pass validation in Azurite.
And you must start Azurite with Oauth configuration to support Oauth credential.
from azurite.
Related Issues (20)
- Update mysql2 version HOT 5
- Metadata Vanishing HOT 12
- UserDelegationKey fails with 500 HOT 2
- Azurite HTTP Interface Impossible to Use from the Command Line. HOT 1
- BeginCopyAsync is throwing wrong exception when source blob is not found. HOT 1
- Upload from URL not working with a SAS URL HOT 1
- Not being able to launch Azurite from DockerHub. HOT 4
- The value for one of the HTTP headers is not in the correct format HOT 2
- Please Document Azurite Logging in VS CODE - not obvious how to see logs HOT 1
- Cannot add --skipApiVersionCheck when using testcontainers HOT 2
- Docker container is not up-to-date HOT 2
- Azurite returns 500 for all PUT requests after an unexpected client restart HOT 6
- Docker image won't stop restarting HOT 4
- Port specification not working (docker, --blobPort) HOT 1
- Block blob StageBlockWithURL isn't implemented HOT 6
- Azurite will deprecate supporting Node.js 14 in a future release.
- Azurite not recognizing accounts other than default even though prerequisites are met. HOT 2
- Azure Shared Access Signature - Signature did not match using ingress nginx HOT 3
- `Access-Control-Allow-Origin` header not set in Azurite response
- Aspire default table HealthCheck fails with 400 bad request
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azurite.