Azurite alway return 400 when use sasUrl generate by Azurite
luyue14 opened this issue · comments
Which service(blob, file, queue, table) does this issue concern?
Blob and file
Which version of the Azurite was used?
3.29.0
Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)
npm
What's the Node.js version?
What problem was encountered?
Azurite alway return 400 bad request.
I use the Azure SDK(.net core: Azure.Storage.Files.DataLake SDK) call Azurite, if I use sasUrl which is generated by Storage the code works well, but if I use the sasUrl generate by Azurite, Azurite will return 400.
Steps to reproduce the issue?
- start Azurite azurite -L --skipApiVersionCheck --silent --location c:\azurite --debug c:\azurite\debug.log
- Generate sasUrl
DataLakeSasBuilder builder = new DataLakeSasBuilder();
builder.SetPermissions(DataLakeSasPermissions.All);
builder.ExpiresOn = DateTime.UtcNow.AddDays(1);
builder.Resource = "d";
builder.Protocol = SasProtocol.Https;
builder.IsDirectory = true;
Uri uri = client.GenerateSasUri(builder);
- call Azurite
var client = new DataLakeDirectoryClient(sasUrl, dataLakeClientOptions);
DataLakeFileClient file = client.GetFileClient(path);
file. xxxx
If possible, please provide the debug log using the -d parameter, replacing <pathtodebuglog> with an appropriate path for your OS, or review the instructions for docker containers:
2024-04-24T08:51:37.871Z 4c638e1a-c673-4a66-ab74-f639b9e872ed error: ErrorMiddleware: ErrorName=UnsupportedRequestError ErrorMessage=Incoming URL doesn't match any of swagger defined request patterns. ErrorHTTPStatusCode=400 ErrorHTTPStatusMessage=undefined ErrorHTTPHeaders=undefined ErrorHTTPBody=undefined ErrorStack="UnsupportedRequestError: Incoming URL doesn't match any of swagger defined request patterns.\n at dispatchMiddleware (C:\Users\luyue\AppData\Roaming\npm\node_modules\azurite\dist\src\blob\generated\middleware\dispatch.middleware.js:41:30)\n at C:\Users\luyue\AppData\Roaming\npm\node_modules\azurite\dist\src\blob\generated\ExpressMiddlewareFactory.js:50:47\n at Layer.handle [as handle_request] (C:\Users\luyue\AppData\Roaming\npm\node_modules\azurite\node_modules\express\lib\router\layer.js:95:5)\n at trim_prefix (C:\Users\luyue\AppData\Roaming\npm\node_modules\azurite\node_modules\express\lib\router\index.js:328:13)\n at C:\Users\luyue\AppData\Roaming\npm\node_modules\azurite\node_modules\express\lib\router\index.js:286:9\n at Function.process_params (C:\Users\luyue\AppData\Roaming\npm\node_modules\azurite\node_modules\express\lib\router\index.js:346:12)\n at next (C:\Users\luyue\AppData\Roaming\npm\node_modules\azurite\node_modules\express\lib\router\index.js:280:10)\n at blobStorageContextMiddleware (C:\Users\luyue\AppData\Roaming\npm\node_modules\azurite\dist\src\blob\middlewares\blobStorageContext.middleware.js:137:5)\n at C:\Users\luyue\AppData\Roaming\npm\node_modules\azurite\dist\src\blob\middlewares\blobStorageContext.middleware.js:15:16\n at Layer.handle [as handle_request] (C:\Users\luyue\AppData\Roaming\npm\node_modules\azurite\node_modules\express\lib\router\layer.js:95:5)"
2024-04-24T08:51:37.871Z 4c638e1a-c673-4a66-ab74-f639b9e872ed error: ErrorMiddleware: Set HTTP code: 400
-d "<pathtodebuglog>"
Please be sure to remove any PII or sensitive information before sharing!
The debug log will log raw request headers and bodies, so that we can replay these against Azurite using REST and create tests to validate resolution.
Have you found a mitigation/solution?
No
Could you help investigate why the Azurite always return 400?
The sas you generated is with "DataLakeSasBuilder", it's datalakegen2 SAS. And you can calling datalakeGen2 API with " DataLakeDirectoryClient".
Azurite still not support datalakeGen2, so this does not work in Azurite.
From Azurite ReadMe file, you can see only blob, queue, table are supported.