Reputation: 2662
I'm attempting to write an Azure function which converts an html input to pdf and either writes this to a blob and/or returns the pdf to the client. I'm using the pdfkit python library. This requires the wkhtmltopdf executable to be available.
To test this locally on my windows machine, I installed the windows version of wkhtmltopdf and this works completely fine.
When I deployed this function on a Linux app service on Azure, I could still execute the function successfully only after I execute the sudo command on kudo tools to install wkhtmltopdf on the app service.
sudo apt-get install wkhtmltopdf
I'm also aware that I can write this start up script on the app service itself.
My question is : Is there something I can do on my local windows machine so I can just deploy the the azure function along with the linux version of wkhtmltopdf directly from my vscode without having to execute another script on the app service itself?
Upvotes: 0
Views: 895
Reputation: 1506
By setting the below commands in the App configuration will work.
Thanks to @pamelafox for the comments.
Commands
PRE_BUILD_COMMAND
or POST_BUILD_COMMAND
The following process is applied for each build.
PRE_BUILD_COMMAND
or PRE_BUILD_SCRIPT_PATH
.VIRTUALENV_NAME
.python -m pip install --cache-dir /usr/local/share/pip-cache --prefer-binary -r requirements.txt
if requirements.txt
exists in the root of repo or specified by CUSTOM_REQUIREMENTSTXT_PATH
.python setup.py install
if setup.py
exists.manage.py
is found in the root of the repo manage.py collectstatic
is run. However, if DISABLE_COLLECTSTATIC
is set to true
this step is skipped.compress_virtualenv
property key.POST_BUILD_COMMAND
or POST_BUILD_SCRIPT_PATH
.The following process is applied for each build.
PRE_BUILD_COMMAND
or PRE_BUILD_SCRIPT_PATH
.conda env create --file $envFile
.requirment.txt
exists in the root of repo or specified by CUSTOM_REQUIREMENTSTXT_PATH
, activate environemnt conda activate $environmentPrefix
and run pip install --no-cache-dir -r requirements.txt
.POST_BUILD_COMMAND
or POST_BUILD_SCRIPT_PATH
.The latest version of pip
is used to install dependencies.
Run
The below process is applied to know how to start an app.
wsgi.py
file (for Django).app
class within them (for Flask and other WSGI frameworks).
application.py
app.py
index.py
server.py
To enable running gunicorn with multiple workers strategy and fully utilize the cores to improve performance and prevent potential timeout/blocks from sync workers, add and set the environment variable PYTHON_ENABLE_GUNICORN_MULTIWORKERS=true
into the app settings.
In Azure Web Apps the version of the Python runtime which runs your app is determined by the value of LinuxFxVersion
in your site config. See ../base_images.md for how to modify this.
References taken from
Upvotes: 0