Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| dev | [![Build Status](https://img.shields.io/azure-devops/build/azfunc/public/658/dev)](https://azfunc.visualstudio.com/public/_build/latest?definitionId=658&branchName=dev) | [![codecov](https://codecov.io/gh/Azure/azure-functions-python-worker/branch/dev/graph/badge.svg)](https://codecov.io/gh/Azure/azure-functions-python-worker) | [![Test Status](https://img.shields.io/azure-devops/build/azfunc/public/658/dev)](https://azfunc.visualstudio.com/public/_build/latest?definitionId=658&branchName=dev) |

Python support for Azure Functions is based on Python 3.10, 3.11, 3.12, and 3.13 serverless hosting on Linux and the Functions 4.0 runtime.
Python support for Azure Functions is based on Python 3.10, 3.11, 3.12, 3.13, and 3.14 serverless hosting on Linux and the Functions 4.0 runtime.

Here is the current status of Python in Azure Functions:

What are the supported Python versions?

| Azure Functions Runtime | Python 3.10 | Python 3.11 | Python 3.12 | Python 3.13 |
|----------------------------------|------------|------------|-------------|-------------|
| Azure Functions 4.0 |||||
| Azure Functions Runtime | Python 3.10 | Python 3.11 | Python 3.12 | Python 3.13 | Python 3.14 |
|----------------------------------|-------------|-------------|-------------|-------------|-------------|
| Azure Functions 4.0 | | ||| |

For information about Azure Functions Runtime, please refer to [Azure Functions runtime versions overview](https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions) page.

Expand Down
8 changes: 4 additions & 4 deletions runtimes/v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| dev | [![Build Status](https://img.shields.io/azure-devops/build/azfunc/public/658/dev)](https://azfunc.visualstudio.com/public/_build/latest?definitionId=658&branchName=dev) | [![codecov](https://codecov.io/gh/Azure/azure-functions-python-worker/branch/dev/graph/badge.svg)](https://codecov.io/gh/Azure/azure-functions-python-worker) | [![Test Status](https://img.shields.io/azure-devops/build/azfunc/public/658/dev)](https://azfunc.visualstudio.com/public/_build/latest?definitionId=658&branchName=dev) |

Python support for Azure Functions is based on Python 3.13 serverless hosting on Linux and the Functions 4.0 runtime.
Python support for Azure Functions is based on Python 3.13 and 3.14 serverless hosting on Linux and the Functions 4.0 runtime.

Here is the current status of Python in Azure Functions:

What are the supported Python versions?

| Azure Functions Runtime | Python 3.13 |
|----------------------------------|-------------|
| Azure Functions 4.0 | ✔ |
| Azure Functions Runtime | Python 3.13 | Python 3.14 |
|----------------------------------|-------------|-------------|
| Azure Functions 4.0 | ✔ | |

For information about Azure Functions Runtime, please refer to [Azure Functions runtime versions overview](https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions) page.

Expand Down
8 changes: 4 additions & 4 deletions runtimes/v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| dev | [![Build Status](https://img.shields.io/azure-devops/build/azfunc/public/658/dev)](https://azfunc.visualstudio.com/public/_build/latest?definitionId=658&branchName=dev) | [![codecov](https://codecov.io/gh/Azure/azure-functions-python-worker/branch/dev/graph/badge.svg)](https://codecov.io/gh/Azure/azure-functions-python-worker) | [![Test Status](https://img.shields.io/azure-devops/build/azfunc/public/658/dev)](https://azfunc.visualstudio.com/public/_build/latest?definitionId=658&branchName=dev) |

Python support for Azure Functions is based on Python 3.13 serverless hosting on Linux and the Functions 4.0 runtime.
Python support for Azure Functions is based on Python 3.13 and 3.14 serverless hosting on Linux and the Functions 4.0 runtime.

Here is the current status of Python in Azure Functions:

What are the supported Python versions?

| Azure Functions Runtime | Python 3.13 |
|----------------------------------|-------------|
| Azure Functions 4.0 | ✔ |
| Azure Functions Runtime | Python 3.13 | Python 3.14 |
|----------------------------------|-------------|-------------|
| Azure Functions 4.0 | ✔ | |

For information about Azure Functions Runtime, please refer to [Azure Functions runtime versions overview](https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions) page.

Expand Down
69 changes: 61 additions & 8 deletions runtimes/v2/azure_functions_runtime/bindings/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
BINDING_REGISTRY = None
DEFERRED_BINDING_REGISTRY = None

# Tracks whether the lazy load of azurefunctions.extensions.base has
# already been attempted (independent of success). This prevents repeated
# import attempts when the extension isn't installed.
_DEFERRED_BINDING_REGISTRY_LOADED = False


def _check_http_input_type_annotation(bind_name: str, pytype: type,
is_deferred_binding: bool) -> bool:
Expand Down Expand Up @@ -61,7 +66,10 @@ def load_binding_registry() -> None:
not found, it loads the builtin. If the BINDING_REGISTRY is None,
azure-functions hasn't been loaded in properly.

Tries to load the base extension.
Note: ``azurefunctions.extensions.base`` is NOT eagerly imported
here. Only apps that use deferred bindings or HTTP v2 actually
need it. The deferred binding registry is populated lazily on first
use via :func:`_get_deferred_binding_registry`.
"""

func = sys.modules.get('azure.functions')
Expand All @@ -82,16 +90,53 @@ def load_binding_registry() -> None:
sys.path, sys.modules,
os.path.exists(CUSTOMER_PACKAGES_PATH))


def _get_deferred_binding_registry():
"""
Lazily resolve the deferred binding registry from
``azurefunctions.extensions.base``.

The first call attempts the import. On success the registry is
cached in :data:`DEFERRED_BINDING_REGISTRY` and returned on every
subsequent call without re-importing. If the extension is not
installed or the customer's code never imported it, the result is
cached as ``None`` and no further work is done.

Deferred binding parameter types come from
``azurefunctions.extensions.bindings.*`` packages, which all
transitively import ``azurefunctions.extensions.base``. So if the
base extension is not in ``sys.modules`` by the time we are asked
(always called after `function_app.py` has been imported), the
function app cannot be using deferred bindings.

Tests may set :data:`DEFERRED_BINDING_REGISTRY` directly; that
value is honored.
"""
global DEFERRED_BINDING_REGISTRY, _DEFERRED_BINDING_REGISTRY_LOADED

if DEFERRED_BINDING_REGISTRY is not None:
return DEFERRED_BINDING_REGISTRY
if _DEFERRED_BINDING_REGISTRY_LOADED:
return None

# Short-circuit: if the customer hasn't (transitively) imported the
# base extension, they cannot be using deferred bindings. Skip the
# cold-import cost entirely.
if 'azurefunctions.extensions.base' not in sys.modules:
_DEFERRED_BINDING_REGISTRY_LOADED = True
return None

_DEFERRED_BINDING_REGISTRY_LOADED = True
try:
import azurefunctions.extensions.base as clients
global DEFERRED_BINDING_REGISTRY
DEFERRED_BINDING_REGISTRY = clients.get_binding_registry()
except ImportError:
logger.debug('Base extension not found. '
'Python version: 3.%s, Sys path: %s, '
'Sys Module: %s, python-packages Path exists: %s.',
sys.version_info.minor, sys.path,
sys.modules, os.path.exists(CUSTOMER_PACKAGES_PATH))
return DEFERRED_BINDING_REGISTRY


def get_binding(bind_name: str,
Expand All @@ -107,7 +152,9 @@ def get_binding(bind_name: str,
if binding is None and not is_deferred_binding:
binding = BINDING_REGISTRY.get(bind_name) # type: ignore
if binding is None and is_deferred_binding:
binding = DEFERRED_BINDING_REGISTRY.get(bind_name) # type: ignore
deferred_registry = _get_deferred_binding_registry()
if deferred_registry is not None:
binding = deferred_registry.get(bind_name)
if binding is None:
binding = GenericBinding
return binding
Expand Down Expand Up @@ -270,8 +317,9 @@ def check_deferred_bindings_enabled(param_anno: Union[type, None],
The first bool represents if deferred bindings is enabled at a fx level
The second represents if the current binding is deferred binding
"""
if (DEFERRED_BINDING_REGISTRY is not None
and DEFERRED_BINDING_REGISTRY.check_supported_type(param_anno)):
deferred_registry = _get_deferred_binding_registry()
if (deferred_registry is not None
and deferred_registry.check_supported_type(param_anno)):
return True, True
else:
return deferred_bindings_enabled, False
Expand All @@ -284,13 +332,15 @@ def get_deferred_raw_bindings(indexed_function, input_types):
the defined binding type and if deferred bindings is enabled for that
binding.
"""
raw_bindings, bindings_logs = DEFERRED_BINDING_REGISTRY.get_raw_bindings(
deferred_registry = _get_deferred_binding_registry()
raw_bindings, bindings_logs = deferred_registry.get_raw_bindings(
indexed_function, input_types)
return raw_bindings, bindings_logs


def get_settlement_client():
return DEFERRED_BINDING_REGISTRY.get(SERVICE_BUS_CLIENT_NAME).get_client()
deferred_registry = _get_deferred_binding_registry()
return deferred_registry.get(SERVICE_BUS_CLIENT_NAME).get_client()


def validate_settlement_param(params: dict,
Expand Down Expand Up @@ -318,7 +368,10 @@ def validate_settlement_param(params: dict,
try:
param_type = annotations.get(settlement_param)
# Check if the type is a supported type for the settlement client
if DEFERRED_BINDING_REGISTRY.check_supported_grpc_client_type(param_type):
deferred_registry = _get_deferred_binding_registry()
if (deferred_registry is not None
and deferred_registry.check_supported_grpc_client_type(
param_type)):
return settlement_param
except Exception:
param_type = None
Expand Down
6 changes: 6 additions & 0 deletions runtimes/v2/azure_functions_runtime/http_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import asyncio
import importlib
import socket
import sys

from typing import Any, Dict

Expand Down Expand Up @@ -277,6 +278,11 @@ def ext_base(cls):

@classmethod
def _check_http_v2_enabled(cls):
# HTTP v2 support requires azurefunctions.extensions.base. If the
# function_app.py did not transitively import that package, HTTP
# v2 cannot be in use, so skip the cold-import cost
if 'azurefunctions.extensions.base' not in sys.modules:
return False
try:
# Attempt to import the base extension module
import azurefunctions.extensions.base as ext_base
Expand Down
Loading
Loading