It has been a couple of months since Microsoft announced the Logic and API apps as part of the Azure App Service suite. I've been wanting to take the new offerings for a spin to get an idea of whether this is something I can see myself using.
What are these apps?
Logic Apps allow you to create integration workflows by joining together a kind of API apps called "connectors". It provides a visual way of constructing integrations where one connector exposes some capability that after being triggered will be piped into other connectors. By chaining these triggers and connectors you can create potentially powerful integrations between applications.
If you want a bit more background before we continue I suggest you check out these articles from the Azure documentation.
Creating a Logic App with out-of-the-box connectors
You don't need to write a custom connector to get started. There are already quite a few connectors in the Azure Marketplace ready for you to use without writing a single line of code.
Let's take advantage of these ready made connectors to quickly set up an integration between Twitter and Twilio that will run a query for tweets periodically and use Twilio to send the result as a text message.
There aren't a ton of non-Enterprisey standard connectors available yet, so this post closely resembles the Create a Logic App example from the Microsoft Azure team, the only difference being that we will send our tweets as text messages rather than writing them to Dropbox.
So while this post might not bring that much new to the table, it will set us up nicely for "part 2", where we will extend our workflow with a custom connector.
If you want to code along you will need access to a Twitter and Twilio account.
First we need to create a new Logic App
Head over to the Azure Portal and create a new Logic App.
- Click "New"
- Choose "Web + Mobile" -> "Logic App"
- Fill in the form
You should press "Create" before pressing the "Triggers and Actions"-option in the form, because this will take you directly to the canvas where you can add connectors. It's less confusing if you just create the new Logic App before starting to add connectors to it.
We will be using a connector called "Recurrence" to trigger our Logic App to execute periodically. There are restrictions on recurrence intervals based on the pricing tier. Basic will only allow you to run the integration hourly, while Standard allows you to trigger the integration as often as every minute.
Connectors are apps that you can deploy to your own Azure account. Someone somewhere may have written an app and made it available to you through the marketplace, but in order for you to start using it, you need to deploy it to your own account.
When you create a Logic App for the first time you will see a blank canvas with no connectors available. Click the link to the Azure Marketplace in the pane on the right side.
From the Azure Marketplace you can add the two connectors for Twitter and Twilio.
As you can see, the connectors are deployed like any other app, giving you a choice of app service plans, pricing tiers, resource groups, data center etc.
Adding connectors to Logic App
When you return to the "Triggers and Actions" pane of your logic app you now have a set of connectors available. In addition to the Twitter and Twilio connectors you just deployed from the marketplace you also have a "Recurrence" and "HTTP" connector.
We will start by adding the three connectors we need, in the order we need them. When you click the connector, an instance of that connector called a "blade" is added to the canvas.
- Click the "Recurrence"-connector and set the desired interval at which to run the workflow
- Click the "Twitter"-connector and authorize it to access your Twitter account
- Click the "Twilio"-connector and provide it with your Twilio authentication details
After adding the blades, configure Twitter to do a search for tweets when it gets triggered by "Recurrence", and Twilio to send a text message to your number with the Twitter data.
What you have now is a workflow that will trigger a Twitter search at intervals, and send the first result as a text message. It should look something like this.
Save and run
Press save at the top of the screen to save your newly created Logic App. When you return to the overview page for your Logic App you can start it by pressing "Run" at the top of the screen.
Why is this not a good idea?
The functionality provided by the Twitter connector doesn't allow us to run a query and ignore tweets we have already seen. What I've created in the example above is a Logic App that will run every minute and return the most recent tweet containing the URL of my blog.
Since that query will always return a result, I have essentially created a Logic App that will spam my phone with a text message every minute. This is bound to get tiresome after a while.
Part 2: Creating a custom connector
Now we have a Logic App composed of standard connectors from the marketplace. I will be back shortly with a follow-up where I will try to solve the spamming problem using a custom connector for filtering.