4

I'm trying to query Azure query blob content through REST API, following the documentation below

https://learn.microsoft.com/en-us/rest/api/storageservices/query-blob-contents

I made my blob contents public for testing and a GET request to blob URI is giving the content, but making a post request to mentioned URI

https://myaccount.blob.core.windows.net/mycontainer/myblob?comp=query (replaced myaccount, mycontainer and myblob)

gibing me following error

<Error>
    <Code>InvalidQueryParameterValue</Code>
    <Message>Value for one of the query parameters specified in the request URI is invalid.
RequestId:1c52fc4f-801e-0061-63fc-f98163000000
Time:2021-02-03T07:15:32.9547540Z</Message>
    <QueryParameterName>comp</QueryParameterName>
    <QueryParameterValue>query</QueryParameterValue>
    <Reason />
</Error>```

blob content is JSON and Blob is a Block Blob type
 
ASHMIL
  • 521
  • 1
  • 7
  • 23

1 Answers1

2

I think you might use the SharedKey for authentication when using Query Blob Contents rest api.

If it's the case, you'd better add the steps or code about how do you build the Authorization header. There might be a minor error there.

I give it a try by using sas token for authentication(you can refer to this link for how to generate sas token via azure portal or code), and it can work well.

Here is my request url:

https://yy1.blob.core.windows.net/a11/my11.csv?comp=query&my_sas_token

And in postman, the request headers are as below:

enter image description here

the request body is as below:

enter image description here

And as you can see the test results in the above screenshots, the status code is 200, and we can get the expected blob content.

Ivan Glasenberg
  • 29,865
  • 2
  • 44
  • 60
  • After adding SAS Token I got this error solved, Thanks for your help. but now it is showing. A required feature for this operation is not enabled on the account, BlobQuery. I searched for an option like this in Azure and not able to find it. How to enable this feature in my account? – ASHMIL Feb 10 '21 at 12:48
  • @ASHMILHUSSAINK, what's your azure storage? general purpose v2 or others? are you querying a .json/.csv file or other types of file? – Ivan Glasenberg Feb 11 '21 at 02:41
  • @Ican Yang, Storage is StorageV2 (general purpose v2) I have tried with Both .json and .csv – ASHMIL Feb 11 '21 at 05:45
  • @ASHMILHUSSAINK the file is `block blob type`? – Ivan Glasenberg Feb 11 '21 at 06:05
  • Yes the file is Block blob – ASHMIL Feb 14 '21 at 04:51
  • @ASHMILHUSSAINK, I didn't see there is something to turn it on or off in the storage account. Please provide more details like the storage account like location / standard or performance tier etc. and it's better show us your detailed request and the settings. – Ivan Glasenberg Feb 16 '21 at 08:01