Ten years ago when I was an avid blogger, I relied quite heavily on Feedburner to consume my RSS feed and distribute to subscribers. That worked, but social media wasn’t really a thing yet and readers relied quite heavily on feed readers for news. Today, most “subscribers” follow content using social media, such as Twitter or LinkedIn, or content aggregators, such as Reddit or Medium. So, when building my new blog, I thought about how I can best communicate posts that I make to others. Traditionally, I could use something like IFTTT or Zapier. Microsoft also has a competing product called Microsoft Flow. However, I may want to add some additional logic before communicating to the world. For this, I can use the product that power Microsoft Flow called an Azure Logic App.

(above – an example of a Logic App design)

Azure Logic Apps are similar to Microsoft Flow in that they allow you to add an action using one of the pre-defined connectors to accomplish a task. The example I posted above reads the RSS feed contained within my blog. For each of the feed links it finds that has been added since the last time the app was executed, it will create a bit.ly link using my custom bit.ly domain as a short URL for the post, convert the post to plain text so the raw HTML isn’t carried over to Twitter or LinkedIn, then posts to Twitter, LinkedIn, and Medium before finally sending an email from my Gmail account back to myself summarizing the links at each of the social media locations.

Step 1: Create a new Logic App

The cost of the logic app that I have designed above will end up being around $3 per month (US cost). Start off by logging into the Azure portal, choosing to Create a Resource, and typing Logic App. The logic app icon appears like this:

Name the logic app, choose a Resource Group, and continue. After it is created, you should be able to navigate to the Logic App and choose the menu option called the Logic App Designer located under the Development Tools menu grouping.

Step 2: Adding your source

When the Logic App designer loads, you’ll notice that you can do all sorts of things such as Starting with a common trigger such as a predefined recurrence or starting with a predefined template. For this purpose, we’ll start with a Blank Logic App template.

After the template loads, you’ll be able to search for connectors and triggers. In the search box, type ‘RSS’. You’ll see an item appear under Triggers that reads ‘When a feed item is published.’

We’ll choose this. We can then add in our RSS feed URL and change the frequency of the new item check. Since this is an RSS feed, I’m likely not publishing new items more frequent then every 15 minutes, but I do want to publish to social media fairly frequently so I am going to set this at every 15 minutes.

Step 3: Create actions on each feed item

Now that we can connect, we’ll update our app by choosing a new action using the link below our trigger. In the search bar, enter ‘For each’. We’re going to add a loop through any RSS items posted in the past 15 minutes and perform a series of actions on each item. When we add the For each control, we’ll notice that there is a tooltip window that appears that contains Dynamic content. Within the Dynamic content view, choose the ‘See more’ link next to ‘When a feed item is published.’

This allows us to see the option ‘Feed links’. Choose that option. Then, in the control itself, choose ‘Add an action.’ Then type in ‘HTML’ into the search box. Choose the HTML to Text option in the action window.

Then, click in the content window and choose the ‘Feed Summary’ field from the tooltip.

Then, we’re going to click ‘Add an Action’ button again. This time we’ll type in ‘Twitter’. Scroll until you find ‘Post a Tweet’ in the action window.

After you choose the ‘Post a tweet’ action, you’ll see a ‘Sign In’ button. Press to sign into Twitter, use your Twitter account to authenticate giving Microsoft Azure Logic Apps permissions, and then configure the Tweet message in a similar fashion to this:

Now that we’ve configured Twitter, we can repeat by clicking ‘Add an Action’ for the other services we may have such as LinkedIn, Facebook, Medium, and others.

Summary

We can use Logic App triggers and actions to create an application that can have a decision tree, repeater, and more without writing a single line of code. Since it’s serverless, we can scale our logic app by using a slider in Azure. While there are plenty of other ways you can post your latest blog posting to social media, Logic Apps definitely make it easier. I’d be interested to hear how you’re using Logic Apps to solve problems.

The 2018.2 Philly.NET Code Camp tickets are now on sale for both Friday and Saturday starting at just $20 for Saturday alone. If you obtain a Friday ticket, you will also receive access for the Saturday sessions. Friday is structured very similar to the workshops you would expect to see at TechBash. These workshops are all day workshops and cover a variety of the hottest topics ranging from Bots, AI, and Machine Learning to Mastering Git and GitHub with DevOps. The Friday workshops range from $76-$116.

You can register for the Code Camp and any of the nine Friday workshops by visiting https://www.meetup.com/Philly-NET/events/.

If you concern yourself with security, you probably have heard of Troy Hunt. Over the years, Troy has blogged about numerous free SSL services including Let’s Encrypt and Cloudflare. He’s also blogged a lot about why static websites need HTTPS. I’ve long been a fan of Let’s Encrypt and use Azure WebApps for many of my projects, especially those that are supporting non-profit organizations, such as TechBash, or those for personal use such as my own blog. So, while this post will specifically target those using Azure, you can and should use Let’s Encrypt or Cloudflare regardless of your hosting provider.

For purposes of this post, I’m going to use:

  • Azure Active Directory and Service Principal Accounts*
  • Azure Function app
  • Azure Web app
  • Let’s Encrypt

*Note: It is recommended that to be a global administrator in Azure or other role with elevated privileges to properly create the service principal account and role.

In addition, you do not have to be a developer to complete this. The average Azure user will most likely complete these tasks in 20 minutes.

Step 1: Create a Service Principal Account in Azure

Rather than providing screen shots that will become outdated, I recommend following the procedure documented on the Docs.Microsoft.com website here.

When going through the process, I’d recommend choosing a display name should be something that’s easy to understand. I tend to use the name of the application along with letsencrypt so I can easily identify this service account. Also, the login/home page value doesn’t really matter for this purpose as this will only be used for the function. However, the important thing to note is that this URL will allow users to login against Azure AD. So, I typically use an endpoint that is still valid, but is not publicly accessible.

Step 2: Install and Auto-Renew Certificates

Simon J.K. Pederson is the primary author of an Azure site extension called the “Let’s Encrypt Site Extension.” Last year, he wrote a blog post explaining how to use an Azure function to create, install, and auto-renew your Let’s Encrypt certificate. While the post gets you 90% of the way there, I had discovered that some of the named parameters do not match the parameter in Azure very well. So, I’ve created a quick GitHub repository that contains the Azure function (run.csx file) available at https://github.com/jasongaylord/LetsEncryptFunctionDemo. I highly recommend copying the code in this file as opposed to what Simon has posted as this replaces the soon to be deprecated TraceWriter class. In addition, I’ve provided hints for 13 variables that are defined within the README.md file.