Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Options for running Python scripts in Azure

Tags:

python

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?

like image 932
user2637453 Avatar asked Aug 16 '17 14:08

user2637453


People also ask

What can you do with Python in Azure?

Deploy your Python code to Azure for web apps, serverless apps, containers, and machine learning models. Take advantage of the Azure libraries (SDK) for Python to programmatically access the full range of Azure services including storage, databases, pre-built AI capabilities, and much more.

How do I run a Python script in Azure Machine Learning Studio?

Loading Data Once you have logged into your Azure Machine Learning Studio account, click on the EXPERIMENTS option, listed on the left sidebar, followed by the NEW button. Next, click on the blank experiment and the new workspace will be displayed. Give the name Execute Scripts to the workspace.


1 Answers

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

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.

I created a simple Trigger webjob for your reference.

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

enter image description here

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.

enter image description here

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

enter image description here

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.

enter image description here

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

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

enter image description here

enter image description here

enter image description here

like image 85
Jay Gong Avatar answered Sep 17 '22 16:09

Jay Gong