How To Call Azure Function In Logic Apps

Updated: Mar 18, 2019

Introduction

Azure Functions is used for executing a small piece of code or “function” in a cloud and you pay only for the time your code executes. You can use a development language of your choice, such as C#, F#, PHP, Java etc. Some of the key features of Functions are - Choice of language, Pay-per-use pricing model, bring your own dependencies, integrated security, simplified integration, flexible development, and open-source. Please refer Azure Functions for more details. Refer to my previous articles below:

Azure Logic Apps is a fully managed integration Platform-as-a-Service which provides a way to automate the workflows and business process. You could easily integrate across different services in cloud and on-premise through connectors. Refer to my previous articles mentioned below:

In this article, you will see how to call Azure Functions in Logic Apps. I have created a custom list named “List Info” with “Title” field. Title field will contain the list name which will be deleted by the Azure Functions. I have already created an Azure function to delete SharePoint list. When a new item is created in List Info, Logic App will get triggered and execute the Azure function which will get the list name from the “List Info” list Title field and delete the respective list.


Azure Function Code

#r "Microsoft.SharePoint.Client.dll"

#r "Microsoft.SharePoint.Client.Runtime.dll"

using System.Net;  

using Microsoft.SharePoint.Client;  

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)  

{      

string siteURL="https://c986.sharepoint.com/sites/Vijai/Subsite";