[英]Execute sudo commands as part of startup on Azure linux app service
We have a requirement to generate pdfs from html. We are using pdfkit which requires the wkhtmltopdf package.我们需要从 html 生成 pdf。我们正在使用 pdfkit,它需要 wkhtmltopdf package。
import logging import azure.functions as func import time import pdfkit import os
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
pdf_bytes = give_me_pdf()
return func.HttpResponse(pdf_bytes, mimetype='application/pdf')
def give_me_pdf(package):
with open('comb_template.html') as f:
pdf_bytes = pdfkit.from_file(f)
return pdf_bytes
When I deploy my code to Azure Linux App service, I need to SSH into my server and fire the sudo apt-get install wkhtmltopdf
command to manually install the package into my linux app service.当我将代码部署到 Azure Linux 应用程序服务时,我需要将 SSH 部署到我的服务器并启动
sudo apt-get install wkhtmltopdf
命令以手动将 package 安装到我的 linux 应用程序服务中。
Is there a way to do this via some startup script so that this happens automatically when I deploy to Azure app service?有没有办法通过一些启动脚本来做到这一点,以便在我部署到 Azure 应用程序服务时自动发生?
You could try setting either PRE_BUILD_COMMAND or POST_BUILD_COMMAND in the App configuration settings.您可以尝试在 App 配置设置中设置 PRE_BUILD_COMMAND 或 POST_BUILD_COMMAND。
For more details, here's a document about the process used for the Python runtime on App Service: https://github.com/microsoft/Oryx/blob/main/doc/runtimes/python.md#build有关更多详细信息,请参阅应用服务上用于 Python 运行时的过程的文档: https://github.com/microsoft/Oryx/blob/main/doc/runtimes/python.md#build
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.