extension Package

Modules

app_extension_base
app_extension_hooks
extension_hook_meta
extension_meta
extension_scope
func_extension_base
func_extension_hooks
function_extension_exception

Classes

AppExtensionBase

An abstract class defines the global life-cycle hooks to be implemented by customer's extension, will be applied to all functions.

An AppExtension should be treated as a static class. Must not contain init method since it is not instantiable.

Please place your initialization code in init() classmethod, consider accepting extension settings in configure() classmethod from customers.

ExtensionMeta

The metaclass handles extension registration.

AppExtension is registered in init, it is applied to all triggers. FuncExtension is registered in call, as users need to instantiate it inside hook script.

After registration, the extension class will be flatten into the following structure to speed up worker lookup:

_func_exts[<trigger_name>].<hook_name>.(ext_name, ext_impl) (e.g. _func_exts['HttpTrigger'].pre_invocation.ext_impl)

_app_exts.<hook_name>.(ext_name, ext_impl) (e.g. _app_exts.pre_invocation_app_level.ext_impl)

The extension tree information is stored in _info for diagnostic purpose. The dictionary is serializable to json:

_info['FuncExtension'][''] = list() _info['AppExtension'] = list()

Executes on 'import extension', once the AppExtension class is loaded, call the setup() method and add the life-cycle hooks into _app_exts.

FuncExtensionBase

An abstract class defines the life-cycle hooks which to be implemented by customer's extension.

Everytime when a new extension is initialized in customer function scripts, the ExtensionManager._func_exts field records the extension to this specific function name.

Constructor for extension. This needs to be implemented and ensure super().init(file_path) is called.

The initializer serializes the extension to a tree. This speeds up the worker lookup and reduce the overhead on each invocation. _func_exts[<trigger_name>].<hook_name>.(ext_name, ext_impl) (e.g. _func_exts['HttpTrigger'].pre_invocation.ext_impl)

FunctionExtensionException

Exception emitted from Azure Functions Python Worker extension