Azure 数据湖抛出错误 - 确保授权 header 的值正确形成,包括签名

Azure Data lake throwing error - Make sure the value of Authorization header is formed correctly including the signature

我正在使用我的存储密钥测试 Azure 数据湖功能。当我尝试在容器中创建一个目录时,它使我陷入异常。我该如何解决错误?

Python代码:

import os, uuid, sys
from azure.storage.filedatalake import DataLakeServiceClient
from azure.core._match_conditions import MatchConditions
from azure.storage.filedatalake._models import ContentSettings
from azure.storage.blob import BlobServiceClient

global service_client

service_client = DataLakeServiceClient(account_url="{}://{}.dfs.core.windows.net".format(
    "https", storage_account_name), credential=storage_account_key)
file_system_client = service_client.get_file_system_client(file_system="demo")
file_system_client.create_directory("demo-directory")

异常:

(AuthenticationFailed) Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:f3880178-801f-0073-2c58-09be43000000
Time:2021-02-22T20:22:15.9974202Z

您的代码是正确的。但是您向 credential 传递了错误的值。您应该传递 Key 而不是 connection string.

当我将 connection string 传递给 credential 时,我收到了与您相同的错误消息。

您可以在此处找到 Key