Ubuntu 中的 Azure Pipeline 在 Debian 中部署到 Azure App Service

Azure Pipeline in Ubuntu deployed to Azure App Service in Debian

我正在做一个需要基于网页创建的 pdf 文件的项目,并使用了 wkhtmltopdf。该项目包含一个基于 python 的 Web 应用程序,该应用程序在 Ubuntu 20 环境中运行。 Azure 管道用于将项目部署到使用 Python 的基于 Linux 的 Azure 应用服务 3. 该项目在本地主机上运行,​​但将其部署到 Azure 应用服务一直导致问题。

经过搜索和反复试验,我想到了将我的项目部署到 Ubuntu 中的 Azure 管道,然后一旦项目上传到 Azure 应用服务,我就进入 Azure,导航到应用程序服务的 SSH,并手动安装 wkhtmltopdf。出于某种原因,应用程序服务在 Debian 9 上运行,因此我无法在 .yml 文件中为管道创建脚本。管道安装的 wkhtmltopdf 包不适用于 Debian。

我想知道是否有办法自动让 debian 应用程序服务安装 wkhtmltopdf。可以通过 Azure 中的 SSH 手动完成,但是构建很多,会非常耗时。

另一个选项是将 yml 文件更改为 Debian 9(似乎不受支持 here), or changing the app service OS to Ubuntu, which I could not find out how to do after hours of searching. It appears that it is automatically Debian 9 based on here

这是 Azure 上 SSH 的屏幕截图

通过在 /home 目录中创建脚本,我能够在 Debian 环境中安装 wkhtmltopdf。然后,我将 Azure 中的启动命令设置为指向此脚本。

我认为如果你给它一个启动命令,Azure 不会运行任何自动脚本,因此我在脚本末尾自己启动应用程序。

这是脚本:

wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.stretch_amd64.deb
apt-get install -y ./wkhtmltox_0.12.6-1.stretch_amd64.deb
rm wkhtmltox_0.12.6-1.stretch_amd64.deb
gunicorn --bind=0.0.0.0 --timeout 600 app:app

请注意,我还必须在 .yml 文件中的 pip install requirements.txt 上方添加一个 pip install python-dotenv。不知道为什么,因为 dotenv 在 yml 文件中,但是如果 yml 中没有这一行,我会得到一个依赖异常。