kil*_*lag 2 python connection-string azure-storage-emulator azure-blob-storage
我正在为我的项目使用 Azure 函数。我需要连接到 blob 存储并上传一些文件。
目前,一切进展顺利。但我试图使用模拟器存储进行完整的本地开发(https://learn.microsoft.com/en-us/azure/storage/common/storage-use-emulator),问题就来了
正如所解释的,我下载了模拟器,运行它,一切都很好,我可以在 Azure 存储资源管理器中看到我的模拟器。我将 local.settings.json 中的“AzureWebJobsStorage”连接字符串更改为快捷方式“UseDevelopmentStorage=true”
当我运行代码时,问题出现在这一行:
container_client = ContainerClient.from_connection_string(
conn_str=conn_str,
container_name=container_name
)
Run Code Online (Sandbox Code Playgroud)
其中 conn_str 是
conn_str = os.get_env_variable('AzureWebJobsStorage')
Run Code Online (Sandbox Code Playgroud)
在初始化期间,我打印此连接字符串,结果是:
ConnectionString to blob storage : UseDevelopmentStorage=true
Run Code Online (Sandbox Code Playgroud)
看来 python 不理解快捷方式,你知道我做错了什么吗?谢谢
新的 SDK 似乎还不支持存储模拟器UseDevelopmentStorage=true;连接字符串。
同时,请使用完整的连接字符串:
container_client = ContainerClient.from_connection_string("DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;", "foo")
Run Code Online (Sandbox Code Playgroud)
这是我刚刚创建的用于实现此支持的开放问题: https://github.com/Azure/azure-sdk-for-python/issues/10040
| 归档时间: |
|
| 查看次数: |
1990 次 |
| 最近记录: |