Home > database >  Update metadata BlockBlob in Azure Blob Storage
Update metadata BlockBlob in Azure Blob Storage

Time:03-14

I have been trying to update the metadata to my BlockBlob using Insomnia.I have managed to clear the metadata using the header(param json is empty):

enter image description here

with the strToSign:

"PUT\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:Fri, 11 Mar 2022 09:24:07 GMT\nx-ms-version:2021-04-10\n/myaccount/search/file_6444\ncomp:metadata"

but if I want to update the metadata, sending x-ms-meta-ide:2021 in the header(param json is empty), it doesn't work, it returns the error: AuthenticationErrorDetail The MAC signature found in the HTTP request 'XXXXXXXXX' is not the same as any computed signature.

The strToSign is:

"PUT\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:Fri, 11 Mar 2022 09:24:07 GMT\nx-ms-version:2021-04-10\nx-ms-meta-ide:2021\n/myaccount/search/file_6444\ncomp:metadata"

why it's not working?? Thanksss

CodePudding user response:

Please change your string to sign to:

PUT\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:Fri, 11 Mar 2022 09:24:07 GMT\nx-ms-meta-ide:2021\nx-ms-version:2021-04-10\n/myaccount/search/file_6444\ncomp:metadata

Essentially the issue is that the headers must be alphabetically sorted in the string to sign so the order of the headers would be x-ms-date, x-ms-meta-ide and then x-ms-version.

For more details, please see this link: https://docs.microsoft.com/en-us/rest/api/storageservices/authorize-with-shared-key#constructing-the-canonicalized-headers-string.

  • Related