在Azure中,我可以从C#WebJob中调用Python脚本吗? [英] In Azure, can I call a Python script from my C# WebJob?

查看:99
本文介绍了在Azure中,我可以从C#WebJob中调用Python脚本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用C#创建一个WebJob.不幸的是,我需要使用Python 3脚本,因为当前没有适合我使用C#执行的一项特定任务的合适的库.

I want to create a WebJob in C#. Unfortunately, I need to use a Python 3 script as there is currently no suitable library for 1 particular task that I need to perform, using C#.

例如,请参见 answer/example .

是否可以让我的WebJob调用Python脚本?我可以将Python3脚本放在blob容器中-然后我可以从C#WebJob调用并执行它了吗?

Is it possible to have my WebJob call a Python script? I can place the Python3 script in a blob container - would I then be able to call and execute it from my C# WebJob?

推荐答案

当然,可以通过

Sure, it's possible to call a Python 3 script via C# WebJob that follow the sample you linked. First of all, you need to install a Python 3 runtime as below.

  1. 通过URL https://<your webapp name>.scm.azurewebsites.net访问kudu工具,并按照下图安装Python 3运行时.
  2. 例如要安装Python 3.5.2 x86,它将安装在路径D:\home\Python35中,那么您只需更改示例中的Python执行文件路径即可尝试运行它.
  1. Access the kudu tool via the url https://<your webapp name>.scm.azurewebsites.net, and follow the figure below to install a Python 3 runtime.
  2. For example to install Python 3.5.2 x86, it will be installed in the path D:\home\Python35, then you just need to change the Python execute file path in the sample to try to run it.

希望有帮助.

更新:安装pip工具&其他Python软件包.

Update: Install pip tool & other Python packages.

  1. 访问网址https://<your azure webapp name>.scm.azurewebsites.net/DebugConsole.
  2. 命令如下.

  1. Access the url https://<your azure webapp name>.scm.azurewebsites.net/DebugConsole.
  2. Commands as below.

D:\home>cd Python35
D:\home\Python35>curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

100 1558k  100 1558k    0     0  6829k      0 --:--:-- --:--:-- --:--:-- 7179k
D:\home\Python35>python get-pip.py
Requirement already up-to-date: pip in d:\home\python35\lib\site-packages
Collecting wheel
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
Installing collected packages: wheel
Successfully installed wheel-0.29.0

  • 例如,安装numpy软件包

    D:\home\Python35>python get-pip.py numpy
    Collecting numpy
      Downloading numpy-1.13.1-cp35-none-win32.whl (6.8MB)
    Installing collected packages: numpy
    Successfully installed numpy-1.13.1
    

  • 这篇关于在Azure中,我可以从C#WebJob中调用Python脚本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆