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
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
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
Partner Zones AWS Cloud
by AWS Developer Relations
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
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

Trending

  • From On-Prem to SaaS
  • Essential Architecture Framework: In the World of Overengineering, Being Essential Is the Answer
  • The SPACE Framework for Developer Productivity
  • Implementing a Serverless DevOps Pipeline With AWS Lambda and CodePipeline

Trending

  • From On-Prem to SaaS
  • Essential Architecture Framework: In the World of Overengineering, Being Essential Is the Answer
  • The SPACE Framework for Developer Productivity
  • Implementing a Serverless DevOps Pipeline With AWS Lambda and CodePipeline
  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.

Gunnar Peipman user avatar by
Gunnar Peipman
·
Apr. 19, 17 · Tutorial
Like (0)
Save
Tweet
Share
8.90K 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.

Trending

  • From On-Prem to SaaS
  • Essential Architecture Framework: In the World of Overengineering, Being Essential Is the Answer
  • The SPACE Framework for Developer Productivity
  • Implementing a Serverless DevOps Pipeline With AWS Lambda and CodePipeline

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: