Azure Functions uses a language worker to execute Python functions and communicate with the Functions host. Whenever an HTTP request, queue message, timer event, or other trigger arrives, the host passes the execution information to the Python worker. The worker processes the request and sends the result back to the host.
For many years, this communication depended on Python packages such as grpcio and protobuf. Although this architecture worked well for most applications, it created challenges when developers upgraded Python versions or used libraries that required specific versions of these packages.
Azure Functions introduces a new Rust-based worker transport called R2P2, or Rust to Python Proxy. It is designed to separate host communication from Python application execution. The new architecture uses Rust for the communication layer while continuing to execute application code through CPython.
This change is particularly relevant when moving an existing Azure Functions application to Python 3.15. Instead of manually replacing the worker or rewriting function code, developers can move to the supported runtime and validate their application against the new worker architecture.
This article explains how the architecture works, what changes during migration, and how to prepare an existing Python Function App for the new transport.
Understanding the Existing Python Worker Architecture
Before migrating an application, it helps to understand how Azure Functions has evolved its Python worker.
The earlier architecture used a single Python worker package that handled several responsibilities, including communication with the Functions host, function indexing, dependency management, and function execution.
The host and worker communicated through gRPC. The Python worker used grpcio for transport and protobuf for message serialization.
This design introduced a dependency management challenge. The worker needed particular versions of grpcio and protobuf, but application libraries could require different versions of the same packages.
Azure Functions introduced an intermediate architecture with Python 3.13 and Python 3.14. This approach separated the communication proxy from the Python execution runtime. It made the runtime easier to update independently, but the communication layer still depended on Python gRPC packages.
The next step is R2P2, introduced with Python 3.15 support.
How the Rust-Based Worker Transport Works
R2P2 moves the host communication layer into a native Rust component. The Python application and its execution runtime remain in Python.
The architecture has three main parts:
The Azure Functions host manages triggers, bindings, application configuration, and function execution requests.
The Rust-based R2P2 worker manages communication with the host using native gRPC and Protocol Buffers libraries.
The embedded CPython interpreter executes the application code using the existing Azure Functions programming models.
The Rust component uses Tonic and Prost for communication. PyO3 provides the interface between Rust and Python.
The important architectural decision is that the transport and execution responsibilities are separated. Rust handles the communication protocol, while Python continues to handle application logic.
The Functions host also retains the existing FunctionRpc protocol contract. This means the host does not need a completely new communication protocol just because the Python worker has changed internally.
For developers, this means the migration does not require rewriting HTTP triggers, queue triggers, timer functions, or business logic in another language.
Understanding What Changes During Migration
Moving to R2P2 is primarily a runtime and deployment change, not a complete application rewrite.
The following comparison explains the difference between the worker generations.
Area | Earlier Python worker | R2P2 worker |
|---|---|---|
Communication layer | Python-based gRPC | Native Rust-based gRPC |
Protocol serialization | Python protobuf | Rust Prost |
Python execution | CPython | Embedded CPython |
Host protocol | FunctionRpc | Existing FunctionRpc contract |
Application language | Python | Python |
Programming models | v1 and v2 | v1 and v2 |
The new architecture removes the worker's dependency on Python grpcio and protobuf for host communication. However, an application can still install and use these packages when its own functionality requires them.
It is also important to understand that R2P2 does not automatically make every Python package compatible with Python 3.15. Application dependencies must still support the selected Python version and target operating system.
Preparing an Existing Function App for Migration
Start by reviewing the current Function App instead of changing the runtime immediately. This helps identify packages and configuration settings that might cause problems after the upgrade.
Review the Python Version and Hosting Plan
Check the Python version currently used by the application and confirm whether the target hosting plan supports Python 3.15.
Python 3.15 is available in public preview for Linux x64 deployments on supported Flex Consumption, Elastic Premium, and Dedicated plans.
Do not assume that an application running on Linux Consumption can move directly to Python 3.15. Confirm the current supported-language matrix and hosting requirements before planning the migration.
Review Application Dependencies
Open requirements.txt and identify packages that depend on grpcio or protobuf.
For example:
azure-functions
grpcio
protobuf
requestsThe presence of grpcio or protobuf is not automatically a problem. These packages may be required by the application itself.
The objective is to identify why each dependency exists. If a package was added only to resolve an older worker communication issue, it may no longer be necessary for that purpose. If the application uses gRPC clients, generated service code, or protobuf messages, retain the dependencies required by those features.
Also check whether the selected package versions support Python 3.15.
Check the Programming Model
Azure Functions supports both the v1 and v2 Python programming models.
The v1 model uses function.json files to define triggers and bindings. The v2 model uses decorators in Python code.
For example, an existing v2 HTTP function might look like this:
import azure.functions as func
app = func.FunctionApp()
@app.route(
route="orders",
methods=["GET"]
)
def get_orders(
req: func.HttpRequest
) -> func.HttpResponse:
return func.HttpResponse(
"Order service is running",
status_code=200
)This function does not need to be rewritten in Rust. Its trigger and application logic remain Python code.
Configuring the Application for the New Runtime
After reviewing the application, prepare the target environment.
The application should use a compatible Azure Functions runtime and a Python 3.15 worker supported by the selected hosting plan.
A typical host.json file can remain simple:
{
"version": "2.0"
}The requirements.txt file should contain the dependencies needed by the application:
azure-functions
requests
grpcio
protobufThe last two packages are included only when application functionality requires them. They are not needed just to enable R2P2.
Do not add a custom Python worker executable or manually copy the Rust worker binary into the application directory. The platform-managed Python 3.15 worker is responsible for selecting and launching the appropriate R2P2 component.
This distinction is important because the worker is part of the Azure Functions runtime environment, not an application-level library that developers should independently install.
Testing the Application Before Deployment
A migration should include more than checking whether the application starts. Test the function execution path and the dependencies that are important to the application.
For example, consider an HTTP function that uses an external service and returns its response.
import azure.functions as func
import requests
app = func.FunctionApp()
@app.route(
route="external-status",
methods=["GET"]
)
def external_status(
req: func.HttpRequest
) -> func.HttpResponse:
try:
response = requests.get(
"https://example.com",
timeout=5
)
return func.HttpResponse(
f"External service status: {response.status_code}",
status_code=200
)
except requests.RequestException:
return func.HttpResponse(
"External service is unavailable",
status_code=503
)The example demonstrates a basic external HTTP call with a timeout and error handling. Replace the example endpoint with the actual service used by the application.
During migration testing, verify the following:
The worker starts successfully.
The application functions are indexed correctly.
HTTP and non-HTTP triggers execute as expected.
Required Python packages import successfully.
Application-level gRPC clients work if the application uses them.
Protobuf messages can be serialized and deserialized correctly.
External service failures are handled properly.
Application logs and exceptions are visible in the expected monitoring system.
Also test concurrent executions. A function that works with one request may behave differently when several invocations execute at the same time.
Deploying the Migrated Application
Once the application passes local and integration testing, deploy it to the supported Azure environment.
A typical deployment process is:
Create or select a Linux Function App on a supported hosting plan.
Configure the application to use the Python 3.15 preview runtime.
Confirm that the Functions runtime and development tools support the target worker.
Configure application settings, connection strings, and required environment variables.
Build and install dependencies using an environment compatible with the target Python version.
Publish the application using a supported Azure Functions deployment method.
Verify startup logs and execute the application's triggers.
For example, when the installed Azure Functions Core Tools version supports the target preview environment, the application can be published with:
func azure functionapp publish <FUNCTION_APP_NAME>For remote builds, verify that the build environment uses the intended Python version. This is particularly important for packages containing native extensions.
Do not assume that a successful deployment means every dependency is compatible. Check the worker startup logs, dependency installation output, and application execution results after publishing.
Common Migration Problems
Worker Fails to Start
A worker startup failure can occur when the Function App is configured for a Python version that is not supported by its hosting plan or runtime environment.
Check the selected hosting plan, operating system, Python version, and Functions runtime configuration. Also confirm that the preview worker is available in the target environment.
Package Installation Fails
Some Python packages may not yet provide compatible wheels for Python 3.15.
Check the package's supported Python versions and platform requirements. If a compatible wheel is unavailable, the package may require a source build or an updated release.
Application Still Reports Dependency Conflicts
R2P2 removes the worker's Python gRPC and protobuf transport dependencies, but it does not remove conflicts between application packages themselves.
For example, two application libraries may still require incompatible protobuf versions. Review the dependency tree and use compatible package releases.
Functions Are Not Indexed
If the worker starts but functions are not available, inspect the application structure and programming model configuration.
For a v2 application, verify that the FunctionApp instance and decorators are correctly defined. For a v1 application, verify that the function.json files and entry points are present.
Also check the runtime logs for import errors that prevent function discovery.
Best Practices for a Safe Migration
Treat the migration as a runtime upgrade with a controlled testing process.
First, maintain a list of application dependencies and their supported Python versions. This makes it easier to identify packages that need upgrades before deployment.
Second, keep application dependencies separate from worker implementation details. Do not add transport packages just because an older worker required them internally.
Third, test the same application on the target hosting plan and deployment environment. Local development alone cannot confirm that the Azure-managed worker is configured correctly.
Finally, use a separate test Function App before moving production traffic. Monitor startup failures, execution exceptions, response times, and dependency-related errors after deployment.
Because Python 3.15 support is currently in public preview, review Microsoft's compatibility guidance and preview updates before adopting it for workloads that require a production support commitment.
Summary
The Rust-based R2P2 worker represents an architectural improvement in Azure Functions Python execution. It moves host communication into a native Rust component while keeping application execution in CPython.
For developers migrating an existing Function App, the main work involves checking hosting compatibility, reviewing application dependencies, validating the Python 3.15 environment, and testing the deployed application.
The existing Python programming models and FunctionRpc host contract remain in place, so application business logic generally does not need to be rewritten. By separating transport dependencies from application dependencies, R2P2 also makes it easier to use libraries that require specific grpcio and protobuf versions.
A careful migration with dependency checks, integration testing, and a separate validation environment can help teams evaluate the new worker architecture without introducing unnecessary changes to their existing Python applications.


Join the conversation! Your thoughts help the community grow.