AppExtensionBase Class

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.

Inheritance
builtins.object
AppExtensionBase

Constructor

AppExtensionBase(*args, **kwargs)

Methods

configure

This function is intended to be called by Azure Functions customers. This is a contract between extension developers and azure functions customers. If multiple .configure() are called, the extension system cannot guarantee the calling order.

init

The function will be executed when the extension is loaded. Happens when Azure Functions customers import the extension module.

post_function_load_app_level

This must be implemented as a classmethod. It will be called right after a customer's function is loaded. In this stage, the customer's logger is not fully initialized from the Python worker. Please use print() to emit a message if necessary.

post_invocation_app_level

This must be implemented as a staticmethod. It will be called right after a customer's function is being executed.

pre_invocation_app_level

This must be implemented as a staticmethod. It will be called right before a customer's function is being executed.

configure

This function is intended to be called by Azure Functions customers. This is a contract between extension developers and azure functions customers. If multiple .configure() are called, the extension system cannot guarantee the calling order.

configure(*args, **kwargs)

init

The function will be executed when the extension is loaded. Happens when Azure Functions customers import the extension module.

init()

post_function_load_app_level

This must be implemented as a classmethod. It will be called right after a customer's function is loaded. In this stage, the customer's logger is not fully initialized from the Python worker. Please use print() to emit a message if necessary.

post_function_load_app_level(function_name: str, function_directory: str, *args, **kwargs) -> None

Parameters

Name Description
function_name
Required
str

The name of customer's function (e.g. HttpTrigger)

function_directory
Required
str

The path to customer's function directory (e.g. /home/site/wwwroot/HttpTrigger)

post_invocation_app_level

This must be implemented as a staticmethod. It will be called right after a customer's function is being executed.

post_invocation_app_level(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_app_level

This must be implemented as a staticmethod. It will be called right before a customer's function is being executed.

pre_invocation_app_level(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