I would like to read a JSON document from an Azure (Blob) Storage Account and use that in an Azure Function.

Note that the following is very specific to my use case and may have to be adapted.

Requirements

Pretty simple: Include azure-storage-blob==12.17.0 into you requirements.

The solution

import json

from azure.storage.blob import BlobClient

def poll_blob():

    connection_string = ...
    container_name = ...
    blob_name = ...

    blob = BlobClient.from_connection_string(
        connection_string,
        container_name,
        blob_name
    )
    data = json.loads(blob.download_blob().content_as_bytes())

Notes

  • My storage account has annonymous identification enabled. Not quite sure yet how authentication works, I may have to research that in the future.
  • The connection string can be found in Storage Account - Access Keys. You have two access keys and the connection strings for them, use one of those.
  • My main source was this Medium article which discusses a bit more things I did not really require.