简体   繁体   English

使用消费计划在 Azure function 应用程序上运行 sudo 命令

[英]Running sudo command on a Azure function app using consumption plan

I am trying to deploy an azure function written using python to an azure function app.我正在尝试将使用 python 编写的 azure function 部署到 azure function 应用程序。 The function is using pyzbar library. function 正在使用 pyzbar 库。 The pyzbar library documentation says that in a Linux environment, the below command needs to be executed so that the pyzbar can work. pyzbar 库文档说在 Linux 环境中,需要执行以下命令以便 pyzbar 可以工作。

sudo apt-get install libzbar0

How can I execute this command on the consumption plan.如何在消费计划上执行此命令。 Please note that I can get this to work if I deploy the function with a container approach using a premium or a dedicated plan.请注意,如果我使用高级或专用计划通过容器方法部署 function,我就可以让它工作。 But I want to get this to work using the consumption plan.但我想让它使用消费计划来工作。

Any help is highly appreciated.非常感谢任何帮助。

  • I have a work around where every time you trigger your function it will run a script that will install the required packages using the command prompt.我有一个解决方法,每次您触发 function 时,它都会运行一个脚本,该脚本将使用命令提示符安装所需的包。

  • This can be achieved using subprocess module这可以使用子流程模块来实现

code:代码:

subprocess.run(["apt-get"," install"," libzbar0"])

for Example in the following code I am installing pandas using pip and returning it's version.例如,在下面的代码中,我使用 pip 安装 pandas 并返回它的版本。

在此处输入图像描述

  • But this will increase your execution time as even if you have added the packages it will continue to execute the installation commands every time you trigger the function.但这会增加您的执行时间,因为即使您添加了软件包,它也会在您每次触发 function 时继续执行安装命令。

暂无
暂无

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

相关问题 Azure Function 消费计划和服务应用计划之间的应用拆分 - Azure Function App split between consumption plan and service app plan Azure Function 应用程序 - Python 消费 ZC1C425268E68385D14AB5074C17A - Azure Function App - Python function works with app service plan type consumption, but not with dedicated app service plan 处于消费计划中的 Azure Logic 应用程序能否通过 VNet 集成调用处于应用程序服务计划中的 azure 函数 - Can an Azure Logic app which is under consumption plan call the the azure function which is under app service plan with VNet integration 如何在 Linux 消费计划中导入作为 Azure 函数运行的 Python 模块? - How can I import Python modules running as an Azure Function on a Linux Consumption Plan? Azure Function(消耗 Linux 计划)未使用系统身份访问 zip 部署的存储帐户 - Azure Function (Consumption Linux Plan) is not working with System Identity to access the storage account for zip deployment 使用 paramiko 运行 Sudo 命令 - Running Sudo Command with paramiko 在应用服务计划中的 Azure Function App 上安装 Hive ODBC 驱动程序 - Install Hive ODBC driver on Azure Function App in App service Plan Azure功能:在消费计划上安装Python模块和扩展 - Azure functions: Installing Python modules and extensions on consumption plan 使用自定义 python 包发布 Azure function 应用程序服务计划 Z86408593C34AF77FDDZ0DF923 - Publishing Azure function with custom python packages for App Service Plan Function app Python 脚本在运行 SUDO 命令时抛出 TTY Sudo 错误 - Python Script throwing TTY Sudo error when running SUDO Command
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM