简体   繁体   English

Azure Ubuntu 中的管道部署到 Azure 中的应用程序服务 Z6FE8B98C363E8D08594681

[英]Azure Pipeline in Ubuntu deployed to Azure App Service in Debian

I am working on a project that needs pdf files created based on a webpage, and went with wkhtmltopdf.我正在开发一个需要基于网页创建的 pdf 文件的项目,并使用 wkhtmltopdf。 The project consists of a python-based web app that runs in an Ubuntu 20 environment.该项目包含一个基于 python 的 web 应用程序,该应用程序在 Ubuntu 20 环境中运行。 An Azure pipeline is used to deploy the project to a Linux-based Azure app service that uses Python 3. The project runs on a localhost, but deploying it to an Azure app service has been causing issues. An Azure pipeline is used to deploy the project to a Linux-based Azure app service that uses Python 3. The project runs on a localhost, but deploying it to an Azure app service has been causing issues.

After searching and trial and error, I came up with deploying my project to the Azure pipeline in Ubuntu, and then once the project has been uploaded to the Azure app service, I go into Azure, navigate to the SSH for the app service, and manually install wkhtmltopdf. After searching and trial and error, I came up with deploying my project to the Azure pipeline in Ubuntu, and then once the project has been uploaded to the Azure app service, I go into Azure, navigate to the SSH for the app service, and手动安装 wkhtmltopdf。 For some reason, the app service runs on Debian 9, so I cannot create a script in the.yml file for the pipeline.由于某种原因,应用服务在 Debian 9 上运行,因此我无法在 .yml 文件中为管道创建脚本。 The wkhtmltopdf package that is installed by the pipeline doesn't work with Debian.管道安装的 wkhtmltopdf package 不适用于 Debian。

I was wondering if there is a way to automatically have the debian app service install wkhtmltopdf.我想知道是否有办法自动让 debian 应用服务安装 wkhtmltopdf。 It can be done manually via the SSH in Azure, but with a lot of builds, it would be very time consuming.可以通过 Azure 中的 SSH 手动完成,但是构建很多,会非常耗时。

Another option is changing the yml file to Debian 9 (which appears not to be supported here ), or changing the app service OS to Ubuntu, which I could not find out how to do after hours of searching.另一种选择是将 yml 文件更改为 Debian 9( 此处似乎不支持),或将应用服务操作系统更改为 Ubuntu,经过数小时的搜索,我无法找到如何操作。 It appears that it is automatically Debian 9 based on here看来它是自动 Debian 9 基于here

Here is a screenshot of the SSH on Azure这是 Azure 上的 SSH 的屏幕截图在此处输入图像描述

I was able to get wkhtmltopdf to install in the Debian environment by creating a script in the /home directory.通过在 /home 目录中创建脚本,我能够将 wkhtmltopdf 安装在 Debian 环境中。 I then set the Startup Command in Azure to point to this script.然后我将 Azure 中的启动命令设置为指向此脚本。

I don't think Azure runs any auto scripts if you give it a startup command, thus I start the application myself at the end of the script.如果您给它一个启动命令,我认为 Azure 不会运行任何自动脚本,因此我在脚本末尾自己启动应用程序。

Here is the script:这是脚本:

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

Note that I also had to add a pip install python-dotenv above pip install requirements.txt in the.yml file.请注意,我还必须在 .yml 文件中的pip install requirements.txt上方添加pip install python-dotenv Not sure why, as dotenv is in the requirements file, but I would get a dependency exception without this line in the yml.不知道为什么,因为 dotenv 在需求文件中,但是如果没有 yml 中的这一行,我会得到一个依赖异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM