DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Data Mining in IoT: From Sensors to Insights
  • Comparing Managed Postgres Options on The Azure Marketplace
  • AWS to Azure Migration: A Cloudy Journey of Challenges and Triumphs
  • Auto-Instrumentation in Azure Application Insights With AKS

Trending

  • How to Create a Successful API Ecosystem
  • Apple and Anthropic Partner on AI-Powered Vibe-Coding Tool – Public Release TBD
  • Code Reviews: Building an AI-Powered GitHub Integration
  • Using Java Stream Gatherers To Improve Stateful Operations
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Triggering Azure Functions From SharePoint Using Microsoft Flow

Triggering Azure Functions From SharePoint Using Microsoft Flow

If you miss SharePoint's workflows, then good news! You can create your own flows with custom code using Azure Functions and Microsoft Flow.

By 
Gunnar Peipman user avatar
Gunnar Peipman
·
Apr. 19, 17 · Tutorial
Likes (0)
Comment
Save
Tweet
Share
9.7K Views

Join the DZone community and get the full member experience.

Join For Free

We cannot use classic SharePoint workflows on Office 365, but using Microsoft Flow, we can create modern flow applications that are triggered by events that happen in different sources. This blog post shows how to use Microsoft Flow and Azure Functions to send out an e-mail when a new meeting is added to a SharePoint list. The idea is to illustrate how to create the flow where custom code takes over at some point.

If you want to try these things out, you need valid Office 365 and Microsoft Azure subscriptions

Azure Functions

We start with creating a default Azure Functions HTTP-function. It accepts name as a parameter and returns a greeting. If you are not familiar with Azure Functions, then please see my blog post HTTP-Triggered Azure Functions for more details about the code below.

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
    log.Info($"C# HTTP trigger function processed a request. RequestUri={req.RequestUri}");// parse query parameter
    string name = req.GetQueryNameValuePairs()
        .FirstOrDefault(q => string.Compare(q.Key, "name", true) == 0)
        .Value;       // Get request body
    dynamic data = await req.Content.ReadAsAsync<object>();// Set name to query string or body data
    name = name ?? data?.name;       return name == null
        ? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a name on the query string or in the request body")
        : req.CreateResponse(HttpStatusCode.OK, "Hello " + name);
}


This function accepts a name as a parameter and returns “Hello name” as the output.

SharePoint

On the SharePoint site, we need a list for meetings.

flow-sharepoint-meetings-list

This is a simple list, and it is more than enough for our simple example in this blog post.

Creating the Flow

We start creating a flow by registering our SharePoint site as a new connection. For this, we open the settings menu at the top of the page, select Connections, and click "Create connection". Then, we select SharePoint and log into our SharePoint account.

Connecting SharePoint to Microsoft Flow

To send an email, we a need connection to Office 365 Outlook. I don’t go through these steps here because the process is almost the same as with SharePoint.

Let’s create our new flow now. The first step in the flow will be a trigger for a new item in our meetings list. This is the page we see when adding a new step to the flow.

Microsoft Flow: Add new trigger

For some reason, when clicking on SharePoin,t we see only four file related triggers and not all the triggers that Flow supports. Click on the blue triggers link and scroll down to where the SharePoint triggers start.

Microsoft Flow: Select trigger

Click on SharePoint – When a new item is created. We are asked for our list location.

Microsoft Flow: SharePoint list location

Fill in the site address, select the list name, and click on the "+ New step" button. We need at least one action to save our flow.

Type HTTP in the actions search box and select HTTP.

Microsoft Flow: Select HTTP application

The HTTP action needs some configuring. Insert your Azure Function URL here and, at the end, add the name parameter that gets its value from the creator display name of the newly created list item.

Microsoft Flow: Configure HTTP action

Let’s add one additional step: email to manager.

Microsoft Flow: Send mail action

After configuring the mail action, it’s time to save the flow by clicking on the checkmark at the top of the page.

Running Meetings Flow

Now let’s add a new meeting to the SharePoint meetings list. After waiting for a few moments, we get an email that looks like this:

Microsoft Flow: E-mail from flow

For every run of our meetings flow, we can also check how much time it took to process every single step in the flow.

Microsoft Flow: Flow log

There is a list of all flow runs available at the Microsoft Flow site, and it is easy to filter out the flows that failed.

Wrapping Up

Although we don’t have support for classic workflows available on Office 365, we can use Microsoft Flow to mimic workflows for SharePoint. Microsoft Flow is not just about SharePoint. It is a rich service that allows us to build automated flows for many other types of sources and targets. We are able to connect Microsoft Flow to a SharePoint list on Office 365 and trigger a function running on Azure when a new item is added to that SharePoint list. It is an example of how it is possible to react to events on Office 365 SharePoint by using custom code.

azure Flow (web browser) SharePoint

Published at DZone with permission of Gunnar Peipman, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Data Mining in IoT: From Sensors to Insights
  • Comparing Managed Postgres Options on The Azure Marketplace
  • AWS to Azure Migration: A Cloudy Journey of Challenges and Triumphs
  • Auto-Instrumentation in Azure Application Insights With AKS

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!