简体   繁体   English

在 Azure linux 应用程序服务上执行 sudo 命令作为启动的一部分

[英]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.

相关问题 可以将 AZURE 应用服务定义为 .NET 的一部分吗? - Can an AZURE App Service be defined as part of a VNET? Azure 应用服务 linux 忽略自定义命令 - Azure app service linux custom command ignored 在 Azure 上使用 PM2 运行 nextjs 时出错 在 Linux 上应用服务 - Error running nextjs with PM2 on Azure App Service on Linux 使用 Linux 在 Azure App Service 上哪里可以找到 coredump? - Where to find coredump on Azure App Service using Linux? 如何作为 Azure 数据工厂的一部分解压缩和执行批处理服务作业 - How do I Unzip and Execute a Batch Service job as part of Azure Data Factory 如何使用启动命令在 azure 应用程序服务上启动分离的 tmux session - How to use startup command to start detached tmux session on azure app service Azure Linux 上的应用服务 - Static 文件内容未更新 - Azure App Service on Linux - Static File Content not updated 修改nginx.conf为Azure App Linux服务 - Modifying nginx.conf for Azure App Linux Service Ocelot Proxy AddJsonFile reloadOnChange 不适用于 azure linux 应用服务 - Ocelot Proxy AddJsonFile reloadOnChange is not working on azure linux app service 如何在Azure Web App Service Linux环境下安装自己的Python package? - How can I install my own Python package in Azure Web App Service Linux environment?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM