Creating an Azure Logic app that connects with SharePoint Online

Posted Thursday, March 26, 2015 12:51 PM by CoreyRoth

Logic apps are a great new feature in Microsoft Azure that lets you connect to a variety of systems and create triggers and events.  This allows you to reproduce some interesting light workflow functionality in an easy manner.  It comes with connectors for common Microsoft products like SharePoint Online, Yammer, and BizTalk.  However, it also includes connects to services like Twitter, SalesForce, SAP, and Dropbox.  It even includes a connector for on-premises SharePoint 2013 servers although it requires some additional configuration.

As Logic apps are part of Azure, this is definitely a developer focused feature.  I don’t see end users working with these directly.

Today, we’re going to look at expanding the Twitter / Dropbox example and expand that for use into SharePoint.  That example stopped at only inserting the first tweet into a file on Dropbox.  This example, will insert all tweets that have been returned from a user’s Mention timeline into a list on SharePoint Online. 

First, I started by creating a simple custom list on my SharePoint Online (Office 365) site.  I am just using the Title column as well as a custom column named TwitterAccount to capture who sent the tweet.

AzureLogicAppSharePointListColumns

Like in the Twitter / Dropbox example, we need to create our connectors first.  We’ll create the Twitter Connector first. Start by logging into the new Azure portal at http://portal.azure.com.  Then click New, Developer Services, Azure Marketplace, API Apps.

AzureLogicAppNewConnector

Select Twitter Service and then click Create.  Here you will be presented with some standard Azure settings that you will need to specify such as the App Service Plan, Resource Group, Subscription, and Location.

AzureLogicAppNewConnectorTwitterDetails

Now, we need to repeat the process for the SharePoint Online connector.  Select the SharePoint Online connector out of the API Services list.  Here you need to also specify the URL to your site as well as the relative URL to the list.  For example, for my Tweets list I created, I specified a relative URL of Lists/Tweets.

LogicAppsSPOConnector

Now that we have created our connectors, we can get started with our Logic apps.  Create a new one by choosing Logic app under the API Services list.  If you can’t find any of these connectors or apps you can always just search for them.  After you click Create, you will be prompted for some settings.

AzureLogicAppNewWithSettings

Give your app a name and then click Triggers and Actions to begin designing your app.  The canvas will appear and you can begin designing your app.

AzureLogicAppCanvas

To get started you simply click on the connectors you want to use.  The Twitter / Dropbox example starts with a recurrence connector to execute the task once an hour.  I didn’t want to accidently leave this app running so I checked the box Run this logic manually

Now we’ll click on the Twitter connector to pull data out of Twitter.  The first time you do this you will be prompted for authentication by Twitter.  Once you login, it will show a list of common actions.  However, you can click the “…” to see more.

AzureLogicAppCanvasTwitterDefault

In our case, we want to select Get Mentions Timeline.

AzureLogicAppCanvasTwitterGetMentions

Now, we need to add our SharePoint Online Connector by clicking on it.  It will also prompt you for authentication as well.  It will then present you with common actions that you can preform on your list.  It will mention your list directly by name.  Choose Insert into <listname> to continue.

AzureLogicAppSharePointConnectorDefault

We’ll be able to start mapping our data to the columns in the SharePoint list.  You can find the other fields by clicking on the “…” button.

AzureLogicAppSharePointConnectorInsertItem

Don’t do the mapping yet though.  In the online example, it only inserted the first list item.  We’re going to implement repeating functionality to insert all of the list items.  Click on the cogwheel and choose Repeat over a list.

 AzureLogicAppSharePointConnectorRepeaterMenu

You can also specify conditions from this menu but we’ll cover that in the future.  Now we want to specify the fields to use in our repeater.  In the Repeat Field click the … icon next to it and choose Get Mentions Timeline.  This will add the text @body(‘twitterconnector’) which is an internal syntax used by Logic apps.  Now we want to write the Tweet Text to the Title field and the Tweeted By field to the TwitterAccount field.  You can look at the options specified in the “…” menu but they don’t quite work right for repeaters.  You can start by picking This Action but we still have a bit of work to do.  It will add @repeatItem() to the box when you click it.

AzureLogicAppSharePointConnectorRepeatItem

Now we need to specify the field name.  We can actually infer this by looking at the Twitter Connector or by looking at the syntax it uses when we select a field from the “…” icon.  Since this is a preview release, the selectors for these fields don’t always give the same results.  Sometime if you select a field name it will do it correctly.  Other times it gives us the syntax that only returns the value from the first item returned.  Ultimately, I want to end up with a value of @repeatItem().TweetText for the Title field and a value of @repeatItem().Tweeted_By for the TwitterAccount field.  Here’s what the final settings look like.

AzureLogicAppSharePointConnectorRepeatingSettings

Click the checkbox to accept the values and then click Save at the top.  Finally you want to click Create to begin creation of your Logic app.  If you are going to make a lot of triggers and actions, I recommend you click Create first before you create them.  This will allow you save your progress as you work on things.  Nothing will be saved until you have created the Logic app itself first.

Now are ready to manually run the Logic app manually.  Click the Run Now button at the top to begin.  You’ll see the progress in the Operations section at the bottom.

AzureLogicAppSettings

Go back to the list on your SharePoint site to verify that the functionality worked.  You can see the list of tweets that mentioned me have been populated. 

AzureLogicAppTweetList

I noticed they didn’t necessarily come in the right order so it might be a good idea to bring in the date column as well.  When I made a schema change to my list earlier I had to recreate the SharePoint Online Connector for it to show up.  There might be a way to refresh it though.

Logic Apps are an interesting technology with a lot of promise.  It makes some scenarios rather easy to implement in a short time.  I’ll continue to work with the technology to get a feel for what it can do and what the limitations are.  Try it out for yourself and see what you can do.

Comments

# SharePoint 2013: Recopilatorio de enlaces interesantes (LXIII)!

Wednesday, April 1, 2015 6:06 AM by Blog de Juan Carlos González en Geeks.MS

Una vez más, y a la espera de que empiecen a aparecer las primeras noticias sobre SharePoint vNext, os

# Office 365 Developer Podcast: Episode 040 on Xamarin development with James Montemagno | POKORNY

Pingback from  Office 365 Developer Podcast: Episode 040 on Xamarin development with James Montemagno | POKORNY

# Office 365 Developer Podcast: Episode 040 on Xamarin development with James Montemagno | Nokipedia

Pingback from  Office 365 Developer Podcast: Episode 040 on Xamarin development with James Montemagno | Nokipedia

Leave a Comment

(required)
(required)
(optional)
(required)