FuncExtensionBase Class
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)
- Inheritance
-
builtins.objectFuncExtensionBase
Constructor
FuncExtensionBase(*args, **kwargs)
Parameters
Name | Description |
---|---|
file_path
Required
|
The name of trigger the extension attaches to (e.g. file). |
Methods
post_function_load |
This hook will be called right after a customer's function loaded. In this stage, the customer's logger is not fully initialized, so it is not provided. Please use print() to emit message if necessary. |
post_invocation |
This hook will be called right after a customer's function is executed. |
pre_invocation |
This hook will be called right before customer's function is being executed. |
post_function_load
This hook will be called right after a customer's function loaded. In this stage, the customer's logger is not fully initialized, so it is not provided. Please use print() to emit message if necessary.
post_function_load(function_name: str, function_directory: str, *args, **kwargs) -> None
Parameters
Name | Description |
---|---|
function_name
Required
|
The name of customer's function (e.g. HttpTrigger) |
function_directory
Required
|
The path to customer's function directory (e.g. /home/site/wwwroot/HttpTrigger) |
post_invocation
This hook will be called right after a customer's function is executed.
post_invocation(logger: Logger, context: Context, func_args: Dict[str, object] | None = None, func_ret: object | None = None, *args, **kwargs) -> None
Parameters
Name | Description |
---|---|
logger
Required
|
A logger provided by Python worker. Extension developer should use this logger to emit telemetry to Azure Functions customers. |
context
Required
|
This will include the function_name, function_directory and an invocation_id of this specific invocation. |
func_args
Required
|
Arguments that are passed into the Azure Functions. The name of each parameter is defined in function.json. Extension developers may also want to do isinstance() check if you want to apply operations to specific trigger types or input binding types. Default value: None
|
func_ret
Required
|
Return value from Azure Functions. This is usually the value defined in function.json $return section. Extension developers may also want to do isinstance() check if you want to apply operations to specific types or input binding types. Default value: None
|
pre_invocation
This hook will be called right before customer's function is being executed.
pre_invocation(logger: Logger, context: Context, func_args: Dict[str, object] | None = None, *args, **kwargs) -> None
Parameters
Name | Description |
---|---|
logger
Required
|
A logger provided by Python worker. Extension developer should use this logger to emit telemetry to Azure Functions customers. |
context
Required
|
This will include the function_name, function_directory and an invocation_id of this specific invocation. |
func_args
Required
|
Arguments that are passed into the Azure Functions. The name of each parameter is defined in function.json. Extension developers may also want to do isinstance() check if you want to apply operations to specific trigger types or input binding types. Default value: None
|
Azure SDK for Python