Creating Azure Sharing Signatures Using BlobService.getBlobURL () in the Azure SDK for Node.js

I am trying to create a url for a blob with a shared signature using BlobService.getBlobURL() in the Azure library on Node.js on my local machine. But when I try to get blob through the generated URL, I get an authentication error message that says "signature does not match." Downloading the same block from the Azure Management portal works great.

The following is the code I use to create the url:

 process.env['AZURE_STORAGE_ACCOUNT'] = "[MY_ACCOUNT_NAME]"; process.env['AZURE_STORAGE_ACCESS_KEY'] = "[MY_ACCESS_KEY]"; var azure = require('azure'); var blobs = azure.createBlobService(); blobs.getBlobUrl('[CONTAINER_NAME]', "[BLOB_NAME]", { AccessPolicy: { Start: Date.now(), Expiry: azure.date.minutesFromNow(60), Permissions: azure.Constants.BlobConstants.SharedAccessPermissions.READ }}); 

URL generated by this function:

 https://[MY_ACCOUNT_NAME].blob.core.windows.net:443/[CONTAINER_NAME]/ [ENCODED_BLOB_NAME] ?st=2013-10-28T18%3A34%3A23Z &se=2013-10-28T19%3A34%3A23Z &sp=r &sr=b &sv=2012-02-12 &sig=rLB%2FEOAWzijkkWcseju8TJLAxzeE5e3Pvq1i68i5Erc%3D 

When I try to paste this URL into the browser, I get the following error message:

 <Error> <Code>AuthenticationFailed</Code> <Message> Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:9fe3d3ed-97f4-43d1-8c65-c95ce6b15a08 Time:2013-10-28T18:34:43.3015398Z </Message> <AuthenticationErrorDetail> Signature did not match. String to sign used was r 2013-10-28T18:34:23Z 2013-10-28T19:34:23Z /[MY_ACCOUNT_NAME]/[CONTAINER_NAME]/[BLOB_NAME] 2012-02-12 </AuthenticationErrorDetail> </Error> 

Then I tried to log into the Azure management portal by selecting the same blob and downloading it. It worked. URL provided on the management portal:

 http://[MY_ACCOUNT_NAME].blob.core.windows.net/[CONTAINER_NAME]/ [ENCODED_BLOB_NAME] ?sv=2012-02-12 &st=2013-10-28T18%3A35%3A16Z &se=2013-10-28T18%3A42%3A16Z &sr=b &sp=r &sig=kcjV%2BkrNAaWOj%2F7NFwmHefXJEiEyu61U7mUTsw3pw7w%3D 
+3
azure azure-storage-blobs
source share
1 answer

It seems that from Azure Node.js Library version 0.7.16, an error occurs that causes this behavior. When the Blob name includes spaces, BlobService.getBlobURL() cannot generate the correct signature. To allow, load a new block without spaces in its name and call BlobService.getBlobURL() again with the name of the new blob. The URL generated this time will be valid. You can register for this issue on Github .

+2
source share

All Articles