cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AnjanaM
New Member

Execute python script from Power Automate Flow

How does one execute Python script from within a Flow ? 

10 REPLIES 10
Krishna92
Microsoft
Microsoft

@AnjanaM 

 

You can make use of azure functions to achieve the scenario.

 

You can bind the python script inside azure function and you can use flow to pass input to the azure function.

The flow will call the azure function API and processing will be performed and the result will be returned back to flow.

https://docs.microsoft.com/en-us/azure/azure-functions/supported-languages

 

You can check the below mentioned document regarding the steps on how to create azure function.

https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-azure-function

 

You can use HTTP trigger to call the azure function from flow.

 

If this information helps you, please consider giving a thumbs up and mark the solution as resolved

Is there any other option other than Azure functions ?

@AnjanaM 

 

If you have a website which allows custom API, then you can built your python program on the website and can use the custom connector to connect to the website and pass information.

 

You can pass the input parameters from flow and the processing will be done on the website and it will share back the information will which in turn be processed by flow and displayed to the end user.

 

Hope this approach helps.

 

If this information helps you, please consider giving a thumbs up and mark the solution as resolved

I achieve this with the onedrive file connector.

Create directories in your onedrive root.

'root/,run/results/'

and use a file watcher to monitor file creation in 'root/.run'

than use the onedrive connector to create a new file with contents:

"python script.py > /results/script.txt"

 

Than create a onedrive trigger as another flow to watch the results folder or whatever you want to do with it.

 

@Dan_Edens 

Hi, I'm very interesting in your method, but I tried to follow, but only get file content with string "python script.py > /results/script.txt", could you please share more details on how you do this? 

 

many thanks. 

costa86
New Member

Use "run powershell script" instead, then type "python %pyFile%" (no quotes) in it.

you mean using Azure Automation? or what connector do you use, do you have an exemple maybe?

No need for that. The python script runs locally, being executed by power shell solely.

1.Create a variable, let us say "x", and store the path to your python script in it.

2.Use the "run power shell script" action, and type "python %x%" inside it.

Thanks a lot for your help, but I can't seem to find an action called "run power shell script"...do you by any chance know where I did wrong?

 

Hi VswaldB ,

I think costa86 is using Power Automate Desktop rather than Power Automate cloud fow.

In PAD it's rather easy to excute python script. You can use the way as mentioned by costa86 or if it's just simple script you can also chooose action "Run Python script" by directly input your codes there.

 

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (1,386)