[英]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 并返回它的版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.