Azure Durable Function not installing Python requirements on deployment
I am deploying multiple Durable Functions to a single (consumption plan) Function App. We use an Azure DevOps YAML pipeline for the deployment, specifically the AzureFunctionApp@1
task with a single .zip
file containing the functions. The task uses deploymentMethod
set to zipDeploy
. The function app is configured to use Linux and Python 3.9, and FUNCTIONS_EXTENSION_VERSION
is set to 4.
We package a single requirements.txt
into the root of the archive with the requirements for all functions. As per the documentation here this approach should result in Azure installing the Python requirements on deployment by default. However, we get module not found errors when the functions are triggered.
I followed the relevant troubleshooting guide here and found the requirements are not being built at all - when downloading the deployed archive from the URL referred to by the WEBSITE_RUN_FROM_PACKAGE
configuration value, there is no .python_packages
present. As per the guide, I went to the Function App configuration and set the values SCM_DO_BUILD_DURING_DEPLOYMENT
and ENABLE_ORYX_BUILD
to true
. I also saw the advice in the "Build native dependencies" section here but could not see an equivalent of this setting for the AzureFunctionApp@1
task in Azure DevOps pipelines.
The only way we have been able to get the functions to run is to build dependencies locally instead, by pip installing the requirements into the archive before deploying it, using a script in the build pipeline:
- script: |
python -m pip install -U pip
pip install --target="$(System.DefaultWorkingDirectory)/functions/.python_packages/lib/site-packages" -r "$(System.DefaultWorkingDirectory)/functions/requirements.txt"
This works but is not ideal as it creates additional runtime for the pipeline, and according to the documentation remote build is the recommended approach. If anyone can assist with whether I am missing something or whether there is an issue with Azure here, it would be much appreciated.