When you need to integrate SharePoint, Power Automate, or other systems with small pieces of custom logic, Azure Functions are a perfect fit. They allow you to run lightweight code in the cloud, triggered by events such as HTTP requests.
🚀 How to Create an Azure Function and Call It from Power Automate
When you need to integrate SharePoint, Power Automate, or other systems with small pieces of custom logic, Azure Functions are a perfect fit. They allow you to run lightweight code in the cloud, triggered by events such as HTTP requests.
In this article, I’ll guide you through the process of creating a basic Azure Function with an HTTP trigger and consuming it from Power Automate.
🔹 Step 1 – Create the Function App
First, you need an Azure Function App in your subscription.
- Go to the Azure Portal
- Create a new Function App resource
- Choose the runtime .NET 6 or .NET 8
- Select a hosting plan (Consumption or App Service Plan)
This Function App acts as a container where you can host multiple Azure Functions.
🔹 Step 2 – Create a Function Project
You can build your function locally with Visual Studio or VS Code.
- Create a new project:
- Type: Azure Functions
- Runtime: .NET 6/8
- Trigger: HTTP trigger
- Authorization: Function (for better security, but you can start with Anonymous for quick tests)
- Name the project something like
DemoFunctionApp.
🔹 Step 3 – Add the Basic HTTP Function
Here’s a minimal example in C#:
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;
namespace DemoFunctionApp
{
public static class HelloWorldFunction
{
[FunctionName("HelloWorldFunction")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", "get", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("HelloWorldFunction processed a request.");
string name = req.Query["name"];
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name ??= data?.name;
return name != null
? (ActionResult)new OkObjectResult($"Hello {name}, your function executed successfully.")
: new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}
}
}
This function accepts GET or POST requests and responds with a simple message.
🔹 Step 4 – Test Locally
Run the project locally:
func start
The terminal will show a URL, for example:
http://localhost:7071/api/HelloWorldFunction
Test it in a browser:
http://localhost:7071/api/HelloWorldFunction?name=Test
You should see:
Hello Test, your function executed successfully.
🔹 Step 5 – Publish to Azure
Publish your project to the Azure Function App created in Step 1.
In Visual Studio:
- Right-click the project → Publish
- Select your Azure subscription and the Function App
- Deploy
Now your function is live with a public URL like:
https://my-function-app.azurewebsites.net/api/HelloWorldFunction?code=XYZ
🔹 Step 6 – Call the Function from Power Automate
In Power Automate:
- Create a new Flow.
- Add the HTTP action.
- Configure it like this:
- Method: POST
- URL: Function URL (including
?code=XYZ) - Headers:
Content-Type: application/json - Body:
{ "name": "Power Automate" }
- Run the flow → it will call your Azure Function and return the response.
🔹 Step 7 – Next Steps
Once you have this working, you can:
- Secure it with Azure AD authentication (Client ID & Secret).
- Replace the “Hello World” logic with real business logic (e.g., calling SharePoint REST APIs).
- Add multiple functions inside the same Function App.
✅ Summary
| Step | Action | Result |
|---|---|---|
| 1 | Create Function App in Azure | Hosting environment ready |
| 2 | Create local Function project | Development environment ready |
| 3 | Add HTTP trigger function | Code to handle HTTP requests |
| 4 | Test locally with func start | Validate function works |
| 5 | Publish to Azure | Public endpoint available |
| 6 | Call from Power Automate | Integration established |
| 7 | Enhance security & logic | Ready for production use |
💡 With this setup, you now have a serverless function that can be triggered from Power Automate or any external system. This is a solid starting point to build more advanced SharePoint or enterprise integrations.
