Azure Function | Sharepoint List item | Call from Power Automate Flow

 

🔹 Steps to Set Up an Azure Function for SharePoint List Item Creation

1️⃣ Create an Azure Function App

  1. Go to Azure PortalFunction Apps → Click Create.
  2. Choose:
    • Subscription: Select your subscription.
    • Resource Group: Create a new one or use an existing one.
    • Function App Name: Enter a unique name.
    • Runtime Stack: Choose .NET, Python, or Node.js.
    • Region: Select a preferred region.
    • Plan Type: Choose Consumption (Serverless).
  3. Click Review + Create → Then Create.

2️⃣ Create a New Function Inside the Function App

  1. Open your Function App → Click Functions+ Add Function.
  2. Choose HTTP Trigger (for now, Power Automate will trigger this function).
  3. Name your function (e.g., SharePointNewItemTrigger).
  4. Set Authorization Level to Function.
  5. Click Create.

3️⃣ Get SharePoint List Data Using Microsoft Graph API

Since Azure Functions cannot directly detect SharePoint list changes, we use Power Automate to send data when an item is added.

Modify the Azure Function to Process SharePoint Data

  1. Go to your Function → Click on Code + Test.
  2. Modify the function to accept SharePoint data via HTTP POST.

C# Azure Function Code (using .NET 6/7)

using System.IO; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.WebJobs; using Microsoft.Azure.WebJobs.Extensions.Http; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Newtonsoft.Json; public static class SharePointItemFunction { [FunctionName("SharePointNewItemTrigger")] public static async Task<IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("Received request from Power Automate for a new SharePoint item."); string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); dynamic data = JsonConvert.DeserializeObject(requestBody); string title = data?.Title; string createdBy = data?.CreatedBy; string itemId = data?.ID; log.LogInformation($"New SharePoint Item Added: ID={itemId}, Title={title}, Created By={createdBy}"); return new OkObjectResult($"Item Processed: {title}"); } }

  • This function receives the Title, CreatedBy, and ID of the new SharePoint item.

4️⃣ Configure Power Automate to Trigger the Azure Function

Since Azure Functions don’t listen directly to SharePoint changes, use Power Automate to send data.

Create a Flow in Power Automate

  1. Go to Power Automate → Click Create.
  2. Select Automated Cloud Flow.
  3. Trigger: Choose When an item is created (SharePoint).
  4. Configure the Site URL and List Name.
  5. Click + New StepHTTP Request.
  6. Set HTTP Request Details:
    • Method: POST
    • URL: Copy the Azure Function URL (from Azure Portal → Function App → SharePointNewItemTrigger → Get Function URL).
    • Headers:
      • Content-Type: application/json
    • Body:
      json
      { "ID": "@{triggerOutputs()?['body/ID']}", "Title": "@{triggerOutputs()?['body/Title']}", "CreatedBy": "@{triggerOutputs()?['body/Author/DisplayName']}" }
  7. Save and Test the Flow.

5️⃣ Test the Solution

  • Add a new item in the SharePoint List.
  • Power Automate detects the new item and calls the Azure Function.
  • Check the Azure Function Logs in Azure Portal (Monitor section).
  • The function logs the item details.

✅ Summary

StepAction
1️⃣Create an Azure Function App
2️⃣Create an HTTP-triggered function
3️⃣Write code to process SharePoint list item data
4️⃣Set up Power Automate to trigger the function
5️⃣Test by adding an item to the SharePoint List

Would you like help with deploying the function in Azure or testing in Power Automate?

Comments

Popular posts from this blog

Sites.Selected | Graph API SharePoint Permission

Configure the SharePoint Online App Catalog