Azure Logic Apps Integration With Microsoft Teams

In this article, we will go through a scenario where you can easily convert your RSS feed post URL(s) into short links and get notified on your Microsoft Teams channel and email whenever there is a new post on the RSS feed that you have subscribed.

Prerequisites for this exercise

To get this working, you need the following -
  • Microsoft Azure account - You can get started with a free Azure account from here.
  • bit.ly account - You will be requiring this while using the Azure Logic Apps bit.ly connector.
  • Microsoft Teams account - Microsoft Teams is the team chat-based software offering from Microsoft. With Microsoft Teams, you can create team chats and have dedicated channels for different teams/projects. 
  • Microsoft Teams Channel - For this exercise, you need to have a Microsoft Teams Channel; For example - "RSS Feeds from C-sharp Corner".
Assumptions

This article is written based on the assumption that you are aware of the basics of Azure Logic Apps. If not, please read the article first,
Scenario

As an author, I personally am new to C# Corner and I have been quite impressed with the quality of articles that get published every day on this website. I thought of this scenario — Why not create an Azure Logic App that will listen to C# Corner's RSS Feed URL and trigger me a notification on a Microsoft Teams channel with a nice shortlink to the URL and the name of the author? We use Microsoft Teams at work which is an excellent software for teamwork and collaboration. Later, I decided to extend the scenario one step further to trigger an email notification with the blog post details. That sparked the idea for me to set things up and get going with my first contribution for C# Corner! Let's start building our Azure Logic App!

Implementation
  1. Open Azure Portal. Click "+New" on the left dashboard menu and select "Web+Mobile" under Azure Marketplace. Select "Logic App" from the right menu options.

    Azure Portal - Logic App selection

  2. In the "Create Logic App" blade, enter the following details.

    1. Name of the Logic App
    2. Choose your appropriate subscription
    3. You can choose to create a new user group or choose an existing one
    4. Select a location from the dropdown
    5. Log Analytics - You can choose to turn on/off this depending on your requirement. Log Analytics helps in logging the diagnostics information of the Logic App that you can choose to view in detail on the Operations Management Suite (OMS) portal. 
    6. Select the "Pin to Dashboard" check box if you prefer to have the Logic App listed as a widget on your Azure Portal dashboard.

      Azure Portal - Create Logic App

  3. Once your Logic App is created and deployed, open the Logic App. In the Logic Apps Designer screen, select "Blank Logic App" under Templates (since we will be constructing our own workflow for this demo).

    Azure Portal - Blank Logic App

  4. In the "Search all connectors and triggers" box, enter the text as 'RSS'. Alternatively, you can choose the RSS Connector from the icon list shown below the text box. The list of triggers and actions for the connector will be displayed. Click 'RSS - When a feed item is published'. 

    Azure Logic App - Define RSS Connector

  5. Enter the RSS Feed URL of C-Sharp Corner in the text box (http://www.c-sharpcorner.com/rss/latestcontentall.aspx). Similarly, you can enter any RSS feed URL in this space provided depending on the scenario. Enter the duration at your preference. Say, I want to receive a Microsoft Teams + Email notification every one hour with the list of posts that have been published in that hour.

    Azure Logic App - RSS Connector

  6. Now that we have defined the trigger for the Logic App, let's create the action steps. First step is to convert the RSS Feed URL into a shortlink using the bitly connector. Click + New step button and select Add an action from the drop down. In the Search all connectors and triggers box, enter the text as 'bitly'. The list of triggers and actions for the bitly connector will be displayed. Click the Bitly - Create a bitlink action.

    Azure Logic App - Define Bitly Connector

  7. If it's the first time you are using the connector, you will be asked to create the connection for Azure Logic App to connect to bitly. Once you authenticate your credentials, you need to define what operations the bitly connector has to perform. In our case, the connector has to simply shorten the incoming URL from the trigger. Hence, we will select links - Item from the parameters section.

    Azure Logic App - Bitly Connector Sign In Option
    Azure Logic App - Bitly Connector

  8. Once you perform the previous step, you will see the real power of Logic Apps kicking in. The Logic App internal logic is able to identify that based on the output parameters that you selected, you are expecting multiple requests coming into the connector (every post in the RSS feed will have a separate URL and the bitly connector has to shorten them one by one). Therefore, Logic Apps automatically creates a For each action that enables you to perform actions on each individual item in a set of values. You will see a notification pop up conveying this message. Sounds cool, isn't it? Yes, Logic Apps is definitely maturing as a great functionality!

    Azure Logic App - Message Prompt

  9. Now that we have defined the URL shortlink action, let's get into the last phase of designing the Logic App - adding the Microsoft Teams connector! Click Add an action, enter Microsoft Teams in Search all connectors and triggers box. Select the Microsoft Teams connector and then we will Post the Message on Microsoft Teams. Please note that the Microsoft Teams actions are in Preview at the time of writing this article.

    Azure Logic App - Microsoft Teams Connector Actions

    As mentioned earlier in Step 7, if this is the first time you are connecting with Microsoft Teams, you will be asked to log into Microsoft Teams and connect with Logic Apps. Since I have already performed this step, I am proceeding directly to the step of posting the message on the Teams channel (RSS Feeds from C-Sharp Corner). Remember this was a prerequisite??

  10. Now that we have selected the Post the Message action, 

    1. Select the Team Id from the drop down (RSS Feeds from C-Sharp Corner)
    2. Select the Channel Id from the drop-down By default, a General channel will be created when you create the channel. If you created a new channel within the Team, you can select that from the drop-down.
    3. Define the message structure that you want to receive within Microsoft Teams

      Azure Logic App - Microsoft Teams Connector

  11. The final step - let's add a connector to receive an email notification about the RSS feed post being available with a bitlink. If you have an Office 365 Outlook account, you can use the Office 365 Outlook connector. Otherwise, you can use the Gmail connector. For this scenario, I will use the Office 365 Outlook connector and the Send an Email action to trigger an email notification.

    Azure Logic App - Outlook Connector Actions

  12. Once you sign in to your Outlook account, you can enter the recipient email address, subject of the email, and the body of the email (similar to Microsoft Teams)

    Azure Logic App - Outlook Connector

  13. That's it! We are done. Click Save on the top of the menu to save your Logic App. The entire Logic App looks as shown below.



  14. Depending on the trigger execution configuration setting (1 hour in our scenario), the trigger will execute and if there are any new RSS feed posts available, the trigger will perform the actions and trigger the notification to Microsoft Teams and Office 365 Outlook email. The screenshots of the results are shown below,

    Microsoft Teams

    Microsoft Teams Channel

    Office 365 Outlook email

    Email Output
There are endless possibilities with Azure Logic Apps that can help to automate a lot of redundant actions in mission-critical environments.

Up Next
    Ebook Download
    View all
    Learn
    View all