在Azure中运行Python脚本的选项 [英] Options for running Python scripts in Azure

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

问题描述

我有一个Python脚本,该脚本从Google Analytics(分析)获取数据并将其放入CSV文件.我目前在本地计算机上运行此脚本,但我想在我的公司Azure租户中运行该脚本.我可以/应该使用哪种Azure服务来每天运行此脚本?

I have a Python script that gets data from Google Analytics and puts in into a CSV file. I currently run this script on a local machine but I'd like to run the script in my companies Azure tenant. What Azure service could / should I use to run this script on a daily schedule?

推荐答案

根据您的需求,建议您在Web Apps Service中使用 Web Jobs .

For your needs, I suggest you use Web Jobs in Web Apps Service.

它有两种类型的Azure Web作业供您选择: 连续触发. 根据您的需求,应采用触发器.

It has two types of Azure Web Jobs for you to choose: Continuous and Trigger. For your needs, Trigger should be adopted.

您可以在此处了解更多详情.此外,

You could refer to the document here for more details.In addition, here shows how to run tasks in WebJobs.

我创建了一个简单的Trigger网络作业供您参考.

I created a simple Trigger webjob for your reference.

第1步:我编写了一个Sample.py,如下所示:

Step 1: I write a Sample.py as below:

我使用python第三方模块virtualenv创建一个隔离的python环境,并使用pip install requests命令行下载了请求所依赖的libs软件包.

I used the python third-party module virtualenv create a isolated python environment and used the pip install requests command line to download the libs packages that the requests depend on.

然后将Sample.py均匀地压缩到一个包含libs包的文件夹中,该文件夹取决于您所依赖的请求.

​ then keep the Sample.py uniformly compressed into a folder with the libs packages dependent on the requests that you rely on.

步骤2 :在Web应用服务中创建Webjob.在这里,我选择触发类型"并设置cron表达式0/5 * * * * *,这意味着该作业每5秒执行一次.

Step 2: Create webjob in Web app service. Here, I choose Triggered Type and set cron expression 0/5 * * * * * which means this job will be excuted per 5 seconds.

创建成功后,您会看到"Web Job"列表.

you'll see the Web Job list after your successful creation.

第3步:您可以通过日志按钮检查正在运行的Web作业的状态和日志,如下所示:

Step 3: You could check your running web job's status and logs via the Logs button as below:

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

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