0

I have a Azure Logic App with a http trigger and would like to call this logic app with a Azure Function. I have tried to make a post call using the Requests Library. The code looks sth like this:

import requests

url='https://prod-56.westeurope.logic.azure.com:...'
requests.post(url)

When I try this code with VS Code it works. But somehow it doesn't work in Azure Functions. I have already changed CORS in the Azure function to allow all but it still didn't work. Any idea how i can call the logic app with a azure function in python?

6
  • it seems to me you're missing the payload. Commented Oct 14, 2022 at 16:00
  • Hi, I just want to activate the logic app. I have executed the code in Visual Studio Code and the logic app starts running. So the code should be fine. But when I use the code in Azure Functions, it doesn't work. Through Application Insight I can see that CORS is addressed and I had to enable all (*) for CORS to be successful. But the Logic app doesn't start. If you try to start a logic app with a http trigger through an Azure Function, does it work? Commented Oct 15, 2022 at 10:38
  • sure! If you pass the expected parameter to trigger the Logic App, it will start running Commented Oct 17, 2022 at 12:57
  • So it doesn't work for you if you dont add a payload? Commented Oct 18, 2022 at 12:54
  • We need to install the requests module as you're using the requests module in your code. As stated in this, there is no direct way to obtain the module via packet manager. The requirements.txt file will automatically get generated if we implement in Vs code. However, you could use kudu console while working with Azure functions by setting up a venv and install the Python modules. I suggest you to execute the code directly in Visual Studio Code and deploy to azure using the Publish command. Commented Oct 19, 2022 at 2:43

1 Answer 1

1

I have reproduced in my environment and got expected results and i followed below process:

Firstly , I created http trigger in my local vs code as below and i added the code which i need to call logic app as below:

url='XX'
requests.post(url)

XX- url of logic app enter image description here

My requirements.txt:

enter image description here

Then i deployed my function to azure and in portal requirements looks like below:

enter image description here

In code test of function:

enter image description here

enter image description here

Then in logic app( My logic app got triggered):

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.