Azure / Azurite

A lightweight server clone of Azure Storage that simulates most of the commands supported by it with minimal dependencies
MIT License
1.84k stars 325 forks source link

Blob_SetHTTPHeaders:On page blob, set sequence-number doesn't update the blob #332

Closed blueww closed 4 years ago

blueww commented 4 years ago

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

blob

Which version of the Azurite was used?

3.3.0-preview

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

VS code

What's the Node.js version?

v10.15.3

What problem was encountered?

Blob_SetHTTPHeaders:On page blob, set sequence-number doesn't update the blob. Like set sequence-number to 5, the return value is still 0.

Steps to reproduce the issue?

On a page blob, set sequence-number to 5, the return value is still 0.

Have you found a mitigation/solution?

No Debug Log:

2019-12-18T03:17:44.658Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 info: BlobStorageContextMiddleware: RequestMethod=PUT RequestURL=http://127.0.0.1/devstoreaccount1/testc355f8410046c41da8eb3371bb496f55e/testbf1ed7a298fa349ef900c9b41899585ee?comp=properties RequestHeaders:{"x-ms-sequence-number-action":"Update","x-ms-blob-sequence-number":"5","x-ms-client-request-id":"ead2d73a-1b25-4b8f-9c7d-27bac51a63fa","user-agent":"Azure-Storage/11.1.1 (.NET Core; Win32NT 6.2.9200.0)","x-ms-version":"2019-02-02","x-ms-date":"Wed, 18 Dec 2019 03:17:44 GMT","authorization":"SharedKey devstoreaccount1:56hl1S+gAJ55KsCiH6Lcq67fm/OkRIRASdkypNuenjQ=","content-length":"0","host":"127.0.0.1:10000"} ClientIP=127.0.0.1 Protocol=http HTTPVersion=1.1
2019-12-18T03:17:44.659Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 info: BlobStorageContextMiddleware: Account=devstoreaccount1 Container=testc355f8410046c41da8eb3371bb496f55e Blob=testbf1ed7a298fa349ef900c9b41899585ee
2019-12-18T03:17:44.660Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 verbose: DispatchMiddleware: Dispatching request...
2019-12-18T03:17:44.662Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 info: DispatchMiddleware: Operation=Blob_SetHTTPHeaders
2019-12-18T03:17:44.662Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 verbose: AuthenticationMiddlewareFactory:createAuthenticationMiddleware() Validating authentications.
2019-12-18T03:17:44.663Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 info: PublicAccessAuthenticator:validate() Start validation against public access.
2019-12-18T03:17:44.663Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 debug: PublicAccessAuthenticator:validate() Getting account properties...
2019-12-18T03:17:44.664Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 debug: PublicAccessAuthenticator:validate() Retrieved account name from context: devstoreaccount1, container: testc355f8410046c41da8eb3371bb496f55e, blob: testbf1ed7a298fa349ef900c9b41899585ee
2019-12-18T03:17:44.669Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 debug: PublicAccessAuthenticator:validate() Skip public access authentication. Cannot get public access type for container testc355f8410046c41da8eb3371bb496f55e
2019-12-18T03:17:44.669Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 info: BlobSharedKeyAuthenticator:validate() Start validation against account shared key authentication.
2019-12-18T03:17:44.670Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 info: BlobSharedKeyAuthenticator:validate() [STRING TO SIGN]:"PUT\n\n\n\n\n\n\n\n\n\n\n\nx-ms-blob-sequence-number:5\nx-ms-client-request-id:ead2d73a-1b25-4b8f-9c7d-27bac51a63fa\nx-ms-date:Wed, 18 Dec 2019 03:17:44 GMT\nx-ms-sequence-number-action:Update\nx-ms-version:2019-02-02\n/devstoreaccount1/devstoreaccount1/testc355f8410046c41da8eb3371bb496f55e/testbf1ed7a298fa349ef900c9b41899585ee\ncomp:properties"
2019-12-18T03:17:44.670Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 info: BlobSharedKeyAuthenticator:validate() Calculated authentication header based on key1: SharedKey devstoreaccount1:56hl1S+gAJ55KsCiH6Lcq67fm/OkRIRASdkypNuenjQ=
2019-12-18T03:17:44.670Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 info: BlobSharedKeyAuthenticator:validate() Signature 1 matched.
2019-12-18T03:17:44.671Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 verbose: DeserializerMiddleware: Start deserializing...
2019-12-18T03:17:44.671Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 info: HandlerMiddleware: DeserializedParameters={"options":{"requestId":"ead2d73a-1b25-4b8f-9c7d-27bac51a63fa","blobHTTPHeaders":{},"leaseAccessConditions":{},"modifiedAccessConditions":{}},"comp":"properties","version":"2019-02-02"}
2019-12-18T03:17:44.676Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 verbose: SerializerMiddleware: Start serializing...
2019-12-18T03:17:44.676Z 74600ca4-55f4-4b62-8155-3caadb8bd0e3 info: EndMiddleware: End response. TotalTimeInMS=18 StatusCode=200 StatusMessage=undefined Headers={"server":"Azurite-Blob/3.3.0-preview","etag":"506bd594-d1d1-48d3-b2a2-991e15b36687","last-modified":"Wed, 18 Dec 2019 03:17:44 GMT","x-ms-client-request-id":"ead2d73a-1b25-4b8f-9c7d-27bac51a63fa","x-ms-request-id":"74600ca4-55f4-4b62-8155-3caadb8bd0e3","x-ms-version":"2019-02-02","date":"Wed, 18 Dec 2019 03:17:44 GMT"}

Test Case:

Test Name:  CloudPageBlobSequenceNumber
Test FullName:  Microsoft.Azure.Storage.Blob.CloudPageBlobTest.CloudPageBlobSequenceNumber
Test Source:    C:\code\azure-storage-net\Test\ClassLibraryCommon\Blob\CloudPageBlobTest.cs : line 345
Test Outcome:   Failed
Test Duration:  0:06:19.1766795

Result StackTrace:  at Microsoft.Azure.Storage.Blob.CloudPageBlobTest.CloudPageBlobSequenceNumber() in C:\code\azure-storage-net\Test\ClassLibraryCommon\Blob\CloudPageBlobTest.cs:line 360
Result Message: Assert.AreEqual failed. Expected:<5>. Actual:<(null)>.
XiaoningLiu commented 4 years ago

In incoming request header, Update is used while in RESTful doc, action should be update.

"x-ms-sequence-number-action":"Update"

https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-properties#request-headers-page-blobs-only

XiaoningLiu commented 4 years ago

It's a behavior .Net SDK doesn't align with document, while XStore actually parser the parameter values case insensitive. It brings difficult for Azurite, because swagger used by Azurite define update sequense number action as a string enum, while max and Max cannot be provided toghether.

Latest v12 storage .net SDK has updated to align using lower case, will leave this as an open issue.