在Azure中使用WebJobs的Python脚本 [英] Python script using webjobs in azure

查看:52
本文介绍了在Azure中使用WebJobs的Python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我在上传新的天蓝色webjob时遇到错误.该错误表明它无法创建网络作业.

我遵循了本教程,该教程是在这里提出的一个问题中找到的.

如果任何人都可以指出我在哪里出错了,我只是搜索了几个小时,许多问题和教程指出这是在Azure中添加库的正确方法.

解决方案

请参考以下步骤,我之前将python脚本上传到了Webjobs中.

第1步:使用 virtualenv 组件在系统中创建一个独立的python运行时环境.如果没有,请首先使用命令 pip install virtualenv 进行安装.

如果安装成功,则可以在 python/Scripts 文件中看到它.

第二步:运行commad创建独立Python运行时环境

第3步:然后进入创建目录的 Scripts 文件夹并激活它(这一步很重要,请不要错过)

不要关闭此命令窗口,并使用 pip install<您的库名称> 在此命令窗口中下载外部库.

第4步:将Sample.py统一压缩到一个文件夹,该文件夹包含您所依赖的 Libs/site-packages 文件夹中的libs软件包.

第5步:在Web应用服务中创建Webjob并上传zip文件,然后您可以执行Web Job并检查日志

您还可以参考SO线程:在Azure中运行Python脚本

希望它对您有帮助.

Hello I'm getting an error when uploading a new azure webjob. The error says it cant create the webjob.

I followed this tutorial which I found it in a question that was asked in here. Link

My script is the following:

import sys, os
sys.path.append(os.path.join(os.getcwd(), "site-packages"))
import requests as req

r = req.get('http://my_website.azurewebsites.net/user/cron')
# Development
# r = req.get('http://localhost:5000/user/cron')
print(r.status_code)

And the structure of my files is this one

If anyone can point out where I made a mistake, I just searched for hours and many questions and tutorials point out this is the proper way to add a library in Azure.

解决方案

Please refer to the steps as below which I uploaded python script into Webjobs previously.

Step 1 : Use the virtualenv component to create an independent python runtime environment in your system.Please install it first with command pip install virtualenv if you don't have it.

If you installed it successfully ,you could see it in your python/Scripts file.

Step2 : Run the commad to create independent python runtime environment.

Step 3: Then go into the created directory's Scripts folder and activate it (this step is important , don't miss it)

Please don't close this command window and use pip install <your libraryname> to download external libraries in this command window.

Step 4:Keep the Sample.py uniformly compressed into a folder with the libs packages in the Libs/site-packages folder that you rely on.

Step 5: Create webjob in Web app service and upload the zip file,then you could execute your Web Job and check the log

You could also refer to the SO thread :Options for running Python scripts in Azure

Hope it helps you.

这篇关于在Azure中使用WebJobs的Python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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