Azure Logic Apps - Post to Twitter
The final logic app is pretty straightforward and consists of a single trigger and action as shown below:
Creating the Logic App
Starting with an empty designer, an RSS trigger is supported that detects when a new post is published:
Configuring the trigger is pretty straightforward as only the URL and interval are required:
The next step is to add an action to post to Twitter:
The initial setup requires signing in to Twitter to authorize the Logic App to have access to post to Twitter:
After authorization has been granted, text in the tweet is specified by selecting content from the previous step (blog entry). Below shows both Feed title and Primary feed link being selected and illustrates the additional content that is available.
Exploring the Logic App
The following looks into different aspects of running Logic App.
Viewing a Logic App in the portal immediately provides some really helpful information. In the Essentials section, we have basic information as well as a summary of the definition (1 trigger and 1 action), the current status, and a summary of the last day of activity.
There are also several charts. The first is a summary of the runs (re., when the trigger condition was met) and includes the status, start time and the duration. In the example below it looks like the logic app is taking about 1/2 second to complete.
An interesting thing to note is after the initial setup was working (1/20/2017, 2:14 PM), the next tweet failed (1/21/2017). The chart provides a great way to trouble shoot the error. First the failure is selected which provides a view of the failed run:
By selecting the failure (clicking the red !), the issue is because Twitter responded with an Unauthorized code. See the Twitter section below for more information.
Another useful chart is the Trigger History showing the app is running every 10 minutes:
And the Billable executions in the past month showing a daily activity of both billable triggers and billable actions. Note: In the image below a single day is being hovered over to illustrate the dynamic chart.
The failed runs are interesting as the configuration did not change but the initial runs failed with an unauthorized response from Twitter. In investigating the error, the authorization was viewed by logging into the Twitter account and going to the Settings.
In the Apps tab the applications with access to the twitter account are shown.
In general the tweeting Logic App can be ignored except when there is a failure sending the tweet. To notify that there was a failure an alert was created. There are several places to add an alert and one is when viewing the Billable executions chart.
There are many metrics that could be selected as illustrated in the image below.
For the purpose of being notified of failures, an alert was created where Runs Failed was great than 0 as shown below:
Determining the cost of running the Logic App is straightforward. From the Pricing page, we can get a understanding of how the pricing model works for logic apps and does vary per region.
The key is determining the number of executions. As we determined from the Billable executions in the past month report, we average around 144 executions per day. Roughly that is mostly the first step checking if there are new blog posts every 10 minutes (6 per hour per day = 6 * 24 = 144). If we round up to 150 and take a 30 day month, we can use 4500 as a monthly total of executions which puts us all within the $0.0008 / action billing range for a total of $3.60 per month.