【发布时间】:2021-04-26 13:00:58
【问题描述】:
我正在尝试使用 Python SDK 和以下代码创建一个 Azure blob 容器。我在响应中收到“ErrorCode:InvalidHeaderValue”。
我正在使用存储帐户 Azure 门户中“访问密钥”部分的“连接字符串”。而且我认为连接不是问题,因为这条线可以正常工作blob_service_client = BlobServiceClient.from_connection_string(connection_string)。
我为此使用了一个干净的 venv,以下是库版本 天蓝色核心==1.10.0 azure-storage-blob==12.7.1
import os
import yaml
from azure.storage.blob import ContainerClient, BlobServiceClient
def load_config():
dir_root = os.path.dirname(os.path.abspath(__file__))
with open (dir_root + "/config.yaml", "r") as yamlfile:
return yaml.load(yamlfile, Loader=yaml.FullLoader)
config = load_config()
connection_string = config['azure_storage_connectionstring']
blob_service_client = BlobServiceClient.from_connection_string(connection_string)
blob_service_client.create_container('testing')
Traceback (most recent call last):
File "/Users/anojshrestha/Documents/codes/gen2lake/project_azure/lib/python3.7/site-packages/azure/storage/blob/_container_client.py", line 292, in create_container
**kwargs)
File "/Users/anojshrestha/Documents/codes/gen2lake/project_azure/lib/python3.7/site-packages/azure/storage/blob/_generated/operations/_container_operations.py", line 134, in create
raise HttpResponseError(response=response, model=error)
azure.core.exceptions.HttpResponseError: Operation returned an invalid status 'The value for one of the HTTP headers is not in the correct format.'
During handling of the above exception, another exception occurred:
.......
azure.core.exceptions.HttpResponseError: The value for one of the HTTP headers is not in the correct format.
RequestId:5X-601e-XXXX00ab-5368-f0c05f000000
Time:2021-01-22T02:43:22.3983063Z
ErrorCode:InvalidHeaderValue
Error:None
HeaderName:x-ms-version
HeaderValue:2020-04-08```
【问题讨论】:
-
能否请您启用日志以获取详细的错误消息:docs.microsoft.com/en-us/azure/developer/python/…?
-
同样的故事。看起来像 azure-storage-blob 中的错误。我恢复到 12.6.0 并解决了问题。
-
谢谢@kopaczew。你说得对!回滚版本解决了我的问题。我会看看是否存在现有的错误。
标签: python azure azure-storage azure-sdk-python