Skip to content

Contributor Guide

hallvictoria edited this page May 2, 2025 · 13 revisions

This page explains how to set up the development environment and run tests locally.

You need to have the following installed on your system:

  1. Python 3.9.x+
  2. dotnet 6.x+
  3. azure-functions-core-tools
  4. Export CORE_TOOLS_EXE_PATH to the installation path Azure Functions Core Tools (e.g. on macOS as installed by brew - /usr/local/bin/func)

Note: On macOS systems, where zsh is used, you might see some issues. In the meantime, please use bash to run these commands.

  1. Clone the repository:
git clone https://github.com/Azure/azure-functions-python-worker.git
  1. Create a virtual environment:
python -m venv worker_env
  1. Activate the virtual environment:
source worker_env/bin/activate
  1. Change the directory to the root of the cloned repository:
cd azure-functions-python-worker
  1. Download pyproject.toml optional-dependencies dev packages:
pip install .[dev]
  1. Build gRPC message, download WebHost binaries, and build Azure Functions extensions:
cd tests
invoke -c test_setup build-protos
invoke -c test_setup webhost
invoke -c test_setup extensions
  1. Create a test function app, obtain the AzureWebJobsStorage key, and various service connection strings and put them into .testconfig (no quotes on around ConnectionStrings):
[azure]
storage_key = DefaultEndpointsProtocol=https;...
cosmosdb_key = AccountEndpoint=https://endpoint.documents.azure.com:443/;...
eventhub_key = Endpoint=sb://endpoint.servicebus.windows.net/;...
servicebus_key = Endpoint=sb://endpoint.servicebus.windows.net/;...
eventgrid_topic_uri = https://eventgridendpoint.region.eventgrid.azure.net/api/events
eventgrid_topic_key = event_grid_key
  1. Activate the dev virtual environment:
source worker_env/bin/activate
  1. Change the directory to the root of the cloned repository:
cd azure-functions-python-worker
  1. Run tests with pytest:
# test everything
pytest
# test specifc file : pytest <test.py file location>
pytest tests/unittests/test_mock_eventhub_functions.py
# test specific method : pytest <test.py file location>::<test class>::<test method>
pytest tests/unittests/test_mock_eventhub_functions.py::TestEventHubMockFunctions::test_mock_eventhub_cardinality_one
  1. Activate the dev virtual environment:
source worker_env/bin/activate
  1. Change the directory to the root of the cloned repository:
cd azure-functions-python-worker
  1. Start a local webhost:
python -m azure.worker.testutils <directory-with-python-functions>

Alternatively, download/build manually and then specify the full path to Microsoft.Azure.WebJobs.Script.WebHost.dll either in the PYAZURE_WEBHOST_PATH environment variable, or in the .testconfig (no quotes on around dll path) configuration file:

[webhost]
dll = <path to Microsoft.Azure.WebJobs.Script.WebHost.dll>
  1. Activate the dev virtual environment:
source worker_env/bin/activate
  1. Change the directory to the root of the cloned repository / docs:
cd azure-functions-python-worker/docs
  1. Ensure that sphinx package is installed:
pip install sphinx
  1. Build the docs!
make html
  • dev: this branch contains the logic for the azure-functions-runtime package. This is the most regularly updated branch.
  • dev-v1: this branch contains the logic for the azure-functions-runtime-v1 package.
  • dev-proxy: this branch contains worker logic that is shipped with the host.