使用 REST 查询 Blob 内容中的无效查询参数值 API

InvalidQueryParameterValue in Query Blob Contents using REST API

我正在尝试通过 REST API 查询 Azure 查询 blob 内容,遵循以下文档

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

我制作了我的 blob 内容 public 用于测试,对 blob URI 的 GET 请求提供了内容,但是对提到的 URI post 发出了请求

https://myaccount.blob.core.windows.net/mycontainer/myblob?comp=query (替换了 myaccount、mycontainer 和 myblob)

gibing 我以下错误

<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
 

我想你可以使用 SharedKey for authentication when using Query Blob Contents 其余的 api。

如果是这样,您最好添加有关如何构建 Authorization header 的步骤或代码。那里可能有一个小错误。

我试了一下用sas token认证(如何通过azure portal或代码生成sas token可以参考this link),效果不错.

这是我的要求url:

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

而在邮递员中,request headers如下:

request body如下:

并且如上面截图中的测试结果,状态码为200,我们可以得到预期的blob内容。