AzureStorageClient报错:无法确定共享密钥凭据的账户名求助
问题根源
你同时传递了account_url和完整连接字符串作为credential,导致客户端无法正确解析连接字符串中的账户名信息——连接字符串本身已经包含了账户名、密钥和端点地址,参数组合冲突引发了解析错误。
两种正确的初始化方式
方式1:直接使用连接字符串初始化(推荐)
不需要单独传入account_url,直接用连接字符串即可:
storage_client = AzureStorageClient(connection_string=<connecion_string>, container=<container_name>)
方式2:拆分账户信息使用SharedKeyCredential
如果需要单独指定account_url,则拆分出账户名和密钥,用SharedKeyCredential作为凭证:
from azure.core.credentials import SharedKeyCredential # 从连接字符串中提取账户名和密钥,或者直接从Azure门户复制 account_name = "你的存储账户名称" account_key = "你的存储账户密钥" credential = SharedKeyCredential(account_name, account_key) storage_client = AzureStorageClient( account_url=f"https://{account_name}.blob.core.windows.net", container=<container_name>, credential=credential )
额外验证
确认你的连接字符串格式正确,标准格式为:
DefaultEndpointsProtocol=https;AccountName=你的账户名;AccountKey=你的密钥;EndpointSuffix=core.windows.net
确保没有多余的空格或特殊字符。
内容的提问来源于stack exchange,提问作者Anna Bianca Marzetti Biggi
相关产品推荐
相关产品推荐

