【发布时间】:2020-10-27 17:48:52
【问题描述】:
我使用 Azure Data Lake Storage Gen2 创建了一个 Azure 存储帐户。我想使用REST API 上传文件。虽然使用Shared Keys 的授权工作正常,但使用account SAS 时遇到问题。
对于路径创建,我使用Path - Create 操作。
# provide Azure Data Lake Storage Gen2 URL as environment variable
$ ADLS_URL="https://xxxxx.blob.core.windows.net/files"
# provide account SAS as environment variable
$ SAS="sv=2017-07-29&ss=bf&..."
# Create a new path in ADLS Gen2
$ curl -vX PUT -H "Content-Length: 112" "$ADLS_URL/example.txt?resource=file&$SAS"
请求返回400 An HTTP header that's mandatory for this request is not specified. 和以下错误消息。
<Error>
<Code>MissingRequiredHeader</Code>
<Message>An HTTP header that's mandatory for this request is not specified. RequestId:870e754b-... Time:2020-07-07T...</Message>
<HeaderName>x-ms-blob-type</HeaderName>
</Error>
事实证明,Creation of a blob in the Blob storage 需要缺少的标头。由于 ADLS Gen2 支持这两种 API 并且都提供类似的操作,因此它会将请求委托给错误的 API。
有没有办法通过 ADLS Gen2 API 上的 SAS 使用 PUT 操作创建路径?
【问题讨论】:
标签: azure azure-blob-storage azure-data-lake-gen2 azure-rest-api azure-sas