1
votes

I create an Azure Blob Storage container just fine:

connect_str = 'REDACTED'
blob_service_client = BlobServiceClient.from_connection_string(connect_str)
container_name = req.params.get('UserId').replace('.', '')
container_client = blob_service_client.create_container(container_name)

Then the rest of the code creates and adds a file to the container. Problem is, the container's public access level is private by default.

How can I make it create the container with a public access level set to public and readable? Right now I have to go change it manually. https://docs.microsoft.com/en-us/python/api/azure-storage-blob/azure.storage.blob.publicaccess?view=azure-python This only seems to return what type of public access it is, it doesn't change it.

EDIT: I think I need to use https://docs.microsoft.com/en-us/python/api/azure-storage-blob/azure.storage.blob.containerclient?view=azure-python#set-container-access-policy-signed-identifiers--public-access-none----kwargs- but I am not sure how to use it

1

1 Answers

0
votes

According to the docs, you should be able to set it in the create_container call:

create_container(name, metadata=None, public_access=None, **kwargs)