kilag
kilag

Reputation: 574

Blob Storage: connection to emulator, local development fail

I am working with Azure function for my project. I need to connect to a blob storage and upload some files.

For now, all is working good. But I was trying to use emulator storage to do a complete local development (https://learn.microsoft.com/en-us/azure/storage/common/storage-use-emulator), and here the problems come

As explains, I download the emulator, run it, here all is good, I can see my emulator in Azure Storage Explorer. I change the "AzureWebJobsStorage" connection string to the shortcut "UseDevelopmentStorage=true" in my local.settings.json

And when I am running the code, the problem appear at this line:

container_client = ContainerClient.from_connection_string(
        conn_str=conn_str, 
        container_name=container_name
        )

Where conn_str is

conn_str = os.get_env_variable('AzureWebJobsStorage')

during the initialization, I am printting this connection string and the result is :

ConnectionString to blob storage : UseDevelopmentStorage=true

it seems python don't understand the shortcut, do you have any idea what am I doing wrong? thanks

Upvotes: 3

Views: 2509

Answers (1)

Jon Gallant
Jon Gallant

Reputation: 311

It appears that the new SDK does not yet support the Storage Emulator UseDevelopmentStorage=true; connection string.

In the meantime, please use the full connection string:

container_client = ContainerClient.from_connection_string("DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;", "foo")

Here's the open issue I just created to implement this support: https://github.com/Azure/azure-sdk-for-python/issues/10040

Upvotes: 7

Related Questions