question

Tom-3021 avatar image
1 Vote"
Tom-3021 asked ShivendooKumar-8455 commented

How to run Python scripts on Azure

How do I run Python scripts on Azure ? My client need to run Python scripts and he cnn't install Python (or any app) on his computer due to organization restricted policy. However he has Azure. So I am testing to run a Python script on Azure. How do I do that ?

azure-webapps
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

For developers: WinPython is portable and does not need to get installed.

For customers: Create portable python distribution, e.g. copy from WinPython. Remove all packages which are not need. Install all packages which are needed. Run python code by referencing python interpretor with batch file for example. My last portable python distribution took about 70 MB.

0 Votes 0 ·
VaibhavChaudhari avatar image
0 Votes"
VaibhavChaudhari answered Tom-3021 commented

Web jobs can be created to run python code in Azure. See similar question here

https://stackoverflow.com/questions/45716757/options-for-running-python-scripts-in-azure

Also for reference - Azure for Python Developers



Please don't forget to Accept Answer and Up-vote if the response helped -- Vaibhav

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks. I couldn't create a Web Job.
I tried following this link: https://docs.microsoft.com/en-us/azure/automation/learn/automation-tutorial-runbook-textual-python2
I opened Azure portal, went to the App Service but couldn't see/find Web Jobs anywhere.

0 Votes 0 ·
Sam-Cogan avatar image
1 Vote"
Sam-Cogan answered ShivendooKumar-8455 commented

Both Azure Automation and Azure Functions support running Python scripts and do not require the creation of any VM's or similar.

Azure Functions for Python - https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python
Azure Automation for Python - https://docs.microsoft.com/en-us/azure/automation/learn/automation-tutorial-runbook-textual-python2


· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks. Unfortunately, I still couldn't run Python scripts either way. Could you please help me and provide more specific guidance ?

For your 1st link on Azure Functions for Python, I can't see where it show a step by step-by-step guide to run Python scripts. It's just a developer guide

0 Votes 0 ·

For your 2nd link on Azure Automation for Python, I got to the Test pane and successfully ran a simple command "print("Hello World!")". But when I tried "import pandas as pd" it gave me the following error:
Failed
Traceback (most recent call last): File "C:\Temp\k4hcqxo1.tu3\c03d1ca1-5fea-4b1b-99c5-f6579a08dc5d", line 5, in <module> import pandas as pdImportError: No module named pandas

I thought I could be because this is Python version 2 so I tried checking if pandas is available by using "pip help", then I get the following error:
Failed
File "C:\Temp\eivgid5v.lwe\c03d1ca1-5fea-4b1b-99c5-f6579a08dc5d", line 5 pip help ^SyntaxError: invalid syntax

1 Vote 1 ·

Thanks for this. I have similar requirement and going to try Azure Automation for Python https://docs.microsoft.com/en-us/azure/automation/learn/automation-tutorial-runbook-textual-python2

0 Votes 0 ·