This release is a pre-release and may not be stable for production use.
Azure Functions Extensions Bindings Blob library for Python
This library allows Blob Trigger and Blob Input bindings in Python Function Apps to recognize and bind to client types from the Azure Storage Blob sdk.
Blob client types can be generated from:
- Blob Triggers
- Blob Input
Source code Package (PyPi) | API reference documentation | Product documentation | Samples
Getting started
Prerequisites
-
Python 3.9 or later is required to use this package. For more details, please read our page on Python Functions version support policy.
-
You must have an Azure subscription and an Azure storage account to use this package.
Install the package
Install the Azure Functions Extensions Bindings Blob library for Python with pip:
pip install azurefunctions-extensions-bindings-blob
Create a storage account
If you wish to create a new storage account, you can use the Azure Portal, Azure PowerShell, or Azure CLI:
# Create a new resource group to hold the storage account -
# if using an existing resource group, skip this step
az group create --name my-resource-group --location westus2
# Create the storage account
az storage account create -n my-storage-account-name -g my-resource-group
Bind to the SDK-type
The Azure Functions Extensions Bindings Blob library for Python allows you to create a function app with a Blob Trigger or Blob Input and define the type as a BlobClient, ContainerClient, or StorageStreamDownloader. Instead of receiving an InputStream, when the function is executed, the type returned will be the defined SDK-type and have all of the properties and methods available as seen in the Azure Storage Blob library for Python.
import logging
import azure.functions as func
import azurefunctions.extensions.bindings.blob as blob
app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION)
@app.blob_trigger(arg_name="client",
path="PATH/TO/BLOB",
connection="AzureWebJobsStorage")
def blob_trigger(client: blob.BlobClient):
logging.info(f"Python blob trigger function processed blob \n"
f"Properties: {client.get_blob_properties()}\n"
f"Blob content head: {client.download_blob(encoding="utf-8").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):
logging.info(f"Python blob input function processed blob \n"
f"Properties: {client.get_blob_properties()}\n"
f"Blob content head: {client.download_blob(encoding="utf-8").read(size=1)}")
Troubleshooting
General
The SDK-types raise exceptions defined in Azure Core.
This list can be used for reference to catch thrown exceptions. To get the specific error code of the exception, use the error_code attribute, i.e, exception.error_code.
Next steps
More sample code
Get started with our Blob samples.
Several samples are available in this GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Storage Blobs:
-
blob_samples_blobclient - Examples for using the BlobClient type:
- From BlobTrigger
- From BlobInput
-
blob_samples_containerclient - Examples for using the ContainerClient type:
- From BlobTrigger
- From BlobInput
-
blob_samples_storagestreamdownloader - Examples for using the StorageStreamDownloader type:
- From BlobTrigger
- From BlobInput
Additional documentation
For more information on the Azure Storage Blob SDK, see the Azure Blob storage documentation on docs.microsoft.com and the Azure Storage Blobs README.
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Metadata
Release files for victorias-test-package 4.0a3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| victorias_test_package-4.0a3.tar.gz | 14.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| victorias_test_package-4.0a3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.2 kB
Release files / victorias_test_package-4.0a3.tar.gz
| Download URL | victorias_test_package-4.0a3.tar.gz |
|---|---|
| Size | 14.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
19e7a708a4f6a0c05419443007a01a08deb6b1234aefcbb8c43227766016d5e7
|
|
BLAKE2b-256 checksum How to use checksums |
45ae13f2d2b66c661e7bb740a2b01a5cf35a66d252f82a1ca7f6d8e13013dcb4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Release files / victorias_test_package-4.0a3-py3-none-any.whl
| Download URL | victorias_test_package-4.0a3-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5b88ea5ae9bb823b12899492c431f297deb7d567feefe09b6d162d4d602aff28
|
|
BLAKE2b-256 checksum How to use checksums |
7ccfcace8a6ed0a03ecb287f796ac8388b717a8ff3a0d5b8f47048cb2ebb8b1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Security for victorias-test-package 4.0a3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.