【问题标题】:Blob Storage: connection to emulator, local development failBlob 存储:连接到模拟器,本地开发失败
【发布时间】:2020-06-11 17:41:50
【问题描述】:

我正在为我的项目使用 Azure 函数。 我需要连接到 Blob 存储并上传一些文件。

目前,一切正常。但是我尝试使用模拟器存储做一个完整的本地开发(https://docs.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
        )

conn_str 在哪里

conn_str = os.get_env_variable('AzureWebJobsStorage')

在初始化过程中,我打印了这个连接字符串,结果是:

ConnectionString to blob storage : UseDevelopmentStorage=true

似乎python不理解快捷方式,你知道我做错了什么吗? 谢谢

【问题讨论】:

  • 您收到的错误信息是什么。请编辑您的问题并将其包含在内。

标签: python connection-string azure-blob-storage azure-storage-emulator


【解决方案1】:

新的 SDK 似乎还不支持 Storage Emulator 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")

这是我刚刚创建的用于实现此支持的未解决问题: https://github.com/Azure/azure-sdk-for-python/issues/10040

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-11
    • 2019-02-24
    • 1970-01-01
    • 1970-01-01
    • 2021-09-29
    • 1970-01-01
    • 2014-11-30
    • 2017-01-05
    相关资源
    最近更新 更多