Azure Logic Apps With Step By Step Demo - Part Three

This is the third and final part of the Azure Logic Apps demo series. In my previous two articles, I have shown the demo of how you can connect SaaS applications with Logic Apps and how you can integrate logic apps with Azure Storage. You can find links to the previous articles below.
In this article, I am going to show you how you can call Azure Functions from Azure Logic Apps.
 
Step 1

First of all, go to the Azure Portal, click on create a resource, go to compute and find Function App.
 
Azure Logic Apps With Step By Step Demo
 
Step 2

Fill in the details. Give some unique name, select the subscription, create a new resource group, select OS as Windows, select Consumption plan and the location and same thing for storage.
 
Azure Logic Apps With Step By Step Demo     Azure Logic Apps With Step By Step Demo 
 
Step 3

Go to the functioning app and create a new function.
 
Azure Logic Apps With Step By Step Demo
 
Step 4

Select Webhook + API and click on Create this function.
 
Azure Logic Apps With Step By Step Demo
 
Step 5

We have got an HTTPTriggerCSharp function and that is all we need. This type of function is going to be one where you pass in a value for a name and it is going to write that or return that name to us.
 
Azure Logic Apps With Step By Step Demo
 
Step 6

To make this simple, go to the Integrate tab and set the authorization level to anonymous so that we can call this easily from logic apps.
 
Azure Logic Apps With Step By Step Demo 
 
Step 7

Next, create a logic app.
 
Azure Logic Apps With Step By Step Demo 
 
Step 8

We want to trigger the logic app when an HTTP request is received. So we need to select this trigger when we are invoking the logic app from an external system, another program or interactively through some command line tool.
 
Azure Logic Apps With Step By Step Demo
 
Step 9

You can notice that here for this trigger, it says the URL will be generated once we save the logic app. So, click on the new step.
 
Azure Logic Apps With Step By Step Demo
 
Step 10

Select Azure Functions.
 
Azure Logic Apps With Step By Step Demo 
Step 11

Select the functioning app and then the function that we just created i.e. HttpTriggerCSharp1
 
Azure Logic Apps With Step By Step Demo   

Azure Logic Apps With Step By Step Demo
 
Step 12

Now, we are going to send some data with this HTTP request to this logic app. So we will send the body of that request to the Azure function.
 
Azure Logic Apps With Step By Step Demo
 
Step 13

Click on New Step and add an action.
 
Azure Logic Apps With Step By Step Demo 
 
Step 14

Select Response Request as an action.
 
Azure Logic Apps With Step By Step Demo 
 
Step 15

With this response, we are going to send back the body from the function. Basically, it is like an echo. We are going to send a request in, we are going to send that back to the caller of the webhook or the HTTP trigger that we are building here in logic apps. Next, click on save and let us see how it works.
 
Azure Logic Apps With Step By Step Demo
 
Step 16

After clicking save, you will be seeing the HTTP POST URL. Copy it.
 
Azure Logic Apps With Step By Step Demo
 
Step 17

Open PowerShell ISE and store the URL in a $url variable.
 
Azure Logic Apps With Step By Step Demo
 
Step 18

Next, we will invoke a web request. With the invoke web request commandlet, we will first set up some parameters. For that, we will build a hash table. Uri is going to be $url, method is going to post, the content type is application/json and the body is JSON data.
 
Azure Logic Apps With Step By Step Demo 
 
Step 19

We have the curl alias for invoking the web request, so we need to say curl @params and that will send everything in. We will send a post to that function app's URL here and we will send all this information to the URL up there.
 
Azure Logic Apps With Step By Step Demo 
 
Step 20

When we run the script, we will be able to see the contents. Next, we need to check if everything is alright in the logic app as well.
 
Azure Logic Apps With Step By Step Demo
 
Step 21

Back in the logic app, refresh and you will be able to see the status has succeeded.
 
Azure Logic Apps With Step By Step Demo
 
Step 22

We have got green checks from the request all the way to the function and to the response as well. We can also check the invocation log for the function.
 
Azure Logic Apps With Step By Step Demo 
 
Step 23

Back in the functioning app, you can see the log under the monitor tab of the HttpTriggerCSharp1 function.
 
Azure Logic Apps With Step By Step Demo
  • We figured out how to call an Azure function from a logic app and we also saw how to call a logic app externally through a web request.
  • It is very easy to call the function from inside a logic app and if you run into a situation where you need to understand how we actually invoke a logic app from another program, we would just treat it as an API.
  • We would just have an HTTP trigger like we had in this demo.