Azure Functions: SDK type bindings for Azure Blob Storage with Azure Functions in Python (Preview)

This post has been republished via RSS; it originally appeared at: Azure Compute Blog articles.

Azure Functions triggers and bindings enable you to easily integrate event and data sources with function applications. With SDK type bindings, you can use types from service SDKs and frameworks, providing more capability beyond what is currently offered. SDK type bindings for Azure Storage Blob when using Python in Azure Functions is now in Preview.


SDK type bindings for Azure Storage Blob enable the following key scenarios:


  • Downloading and uploading blobs of large sizes, reducing current memory limitations and GRPC limits.  
  • Improved performance by using blobs with Azure Functions  

To get started using SDK type bindings for Azure Storage Blob, the following prerequisites are required:


Note that currently, only synchronous SDK types are supported.


Then, enable the feature in your Azure Function app:


  1. Add the azurefunctions-extensions-bindings-blob extension package to the requirements.txt file in the project.
  2. Add this code to the file in the project, which imports the SDK type bindings:
    import azurefunctions.extensions.bindings.blob as blob


This example shows how to get the BlobClient from both a Blob storage trigger (blob_trigger) and from the input binding on an HTTP trigger (blob_input).


import logging import azure.functions as func import azurefunctions.extensions.bindings.blob as blob app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) @app.blob_trigger( arg_name="client", path="PATH/TO/BLOB", connection="AzureWebJobsStorage" ) def blob_trigger(client: blob.BlobClient): f"Python blob trigger function processed blob \n" f"Properties: {client.get_blob_properties()}\n" f"Blob content head: {client.download_blob().read(size=1)}" ) @app.route(route="file") @app.blob_input( arg_name="client", path="PATH/TO/BLOB", connection="AzureWebJobsStorage" ) def blob_input(req: func.HttpRequest, client: blob.BlobClient): f"Python blob input function processed blob \n" f"Properties: {client.get_blob_properties()}\n" f"Blob content head: {client.download_blob().read(size=1)}" ) return "ok"


You can view other SDK type bindings samples for Blob storage in the Python extensions repository:


Thanks for reading along! To learn more about SDK type bindings for Blob in Azure Functions using Python, checkout the developer reference guide. For questions and comments, create an issue in our Azure Functions Python GitHub repository.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.