Creating the deployment package (BYOF)
See original GitHub issuebring-your-own-files
To deploy Python functions to Azure along with the required dependencies, follow the steps below.
Note: If the only dependencies are other user defined modules already contained in the functionapp
directory, no action is required. Please make sure to reference these modules correctly in your code.
1. Generate the requirements manifest
The requirements.txt
file must contain a list of all packages required to execute your function code. Use the pip freeze
utility to capture the exact version of everything that is installed in your development environment.
pip freeze > requirements.txt
2. Build wheel archives
Wheel
is a built-package format, and offers the advantage of not recompiling your software during every install. Build a directory of wheels for all dependencies in requirements.txt
.
# Install the wheel utility
pip install wheel
# Download to wheels subdirectory
pip wheel --wheel-dir=/functionapp/wheels -r requirements.txt
Serverside workflow
To ensure that your packages are available in the production environment in Azure, we will run pip install
on the wheels
folder using the command below:
pip install --no-index --find-links=/functionapp/wheels -r requirements.txt
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:11 (5 by maintainers)
Top GitHub Comments
Option 3 that might want to be advertised is creating a deployment package. Instead of using pip to install packages on the Function app, one could configure their app to install libraries in the root of their project with something like
pip install requests -t /path/to/project
ZIP, upload project dir to wwwroot or FTP. This could be an easier approach in a CI/CD type workflow.@asavaritayal The only correct way to make a package available is to
pip install
it into the correct virtual env. Thus, the host, upon unzipping the artifact should runpip install
on the folder that contains the wheels.