I've run into deployment failures for my Flask app to Azure Web Apps recently. Was hoping to get some advice on how to remediate the issue.
Steps to recreate problem:
- Create a GitHub repo and create a new file
app.py
with the following Flask Python code:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
- Add another file
requirements.txt
flask==2.1.0
flask-talisman==0.7.0
flask-session==0.4.0
#flask-cors
pandas==1.3.0
datetime
pyodbc==4.0.31
sqlalchemy==2.0.8
requests==2.25.0
msal==1.15.0
envelopes==0.4
adal==1.2.5
cryptography==3.4.8
pypdf==3.6.0
bleach==6.0.0
xhtml2pdf==0.2.9
- Create a new Azure Web Apps instance for Linux-Python 3.8 in Canada Central or US East
- Connect it with GitHub with Continuous Integration turned on so that changes in this repository will invoke the new deploy workflow Azure places into the repo
- Navigate to the Actions tab on GitHub and you will notice the build steps complete successfully on GitHub
- After the steps complete, the files are sent to Azure in a second Deploy job
- Oryx takes over and performs a second build job on Azure's side and fails
- The parts of the log detailing what failed reads as follows:
Building wheels for collected packages: pycairo
Building wheel for pycairo (pyproject.toml): started
Building wheel for pycairo (pyproject.toml): finished with status 'error'
error: subprocess-exited-with-error
Building wheel for pycairo (pyproject.toml) did not run successfully.
exit code: 1
lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-38
creating build/lib.linux-x86_64-cpython-38/cairo
copying cairo/init.py -> build/lib.linux-x86_64-cpython-38/cairo
copying cairo/init.pyi -> build/lib.linux-x86_64-cpython-38/cairo
copying cairo/py.typed -> build/lib.linux-x86_64-cpython-38/cairo
running build_ext
Package cairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `cairo.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cairo' found
Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']' returned non-zero exit status 1.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pycairo
Failed to build pycairo
ERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects
The python dependency xhtml2pdf
requires the python dependency pycairo
which requires the OS-level package cairo
. According to the docs on https://pycairo.readthedocs.io/en/latest/getting_started.html, it seems that the container running Oryx Build is missing cairo >= 1.15.10
thus failing.
This deployment issue hasn't occurred before with the same dependencies. It was only discovered recently (start of May).
I've tried to set the PRE_BUILD_COMMAND
to apt-get install cairo
or similar but these operations require permission elevation. Adding the install commands to the yaml workflow file shows that the Ubuntu-latest docker containers on GitHub's side contains the package but Oryx Build steps don't run on these containers - they run on Azure's side.
Maybe I'm missing something. Application runs fine locally. Any expert advice to work around this problem halting deployment?