Azure Functions Extensions Base

raw JSON →
1.1.0 verified Fri May 01 auth: no python

Base Python worker extension for Azure Functions, providing infrastructure for building custom extensions. Current version 1.1.0, requires Python >=3.8. Released as part of the Azure Functions Python programming model.

pip install azurefunctions-extensions-base
error ModuleNotFoundError: No module named 'azurefunctions'
cause Missing or incorrect installation of the Azure Functions SDK or extensions package.
fix
Run 'pip install azurefunctions-extensions-base azure-functions'.
error ImportError: cannot import name 'BaseExtension' from 'azurefunctions.extensions'
cause Incorrect import path; BaseExtension is in the 'base' submodule.
fix
Use 'from azurefunctions.extensions.base import BaseExtension'.
error AttributeError: module 'azurefunctions.extensions' has no attribute 'base'
cause The package may be outdated or not installed correctly.
fix
Update to the latest version: 'pip install --upgrade azurefunctions-extensions-base'.
deprecated The V1 programming model (using function.json) is deprecated in favor of the V2 model (using decorators). This extension base is designed for the V2 model.
fix Migrate to the Azure Functions Python programming model V2 (azure.functions v1.18+).
gotcha Importing from 'azurefunctions.extensions' directly without the 'base' submodule will fail. The package structure is not flat.
fix Always import from 'azurefunctions.extensions.base'.
breaking Version 1.0.0 changed the extension registration API. Previously, extensions were registered via a different method.
fix Use the new 'ExtensionRegistry.add_extension' method. Refer to the official changelog.

Initialize an ExtensionRegistry, define a custom extension by subclassing BaseExtension, and register it.

from azurefunctions.extensions.base import BaseExtension, ExtensionRegistry

# Initialize registry
registry = ExtensionRegistry()

# Define a custom extension
class MyExtension(BaseExtension):
    def __init__(self):
        super().__init__()

# Register extension
extension = MyExtension()
registry.add_extension(extension)

print('Extension registered successfully.')