Azure Logic Apps

Introduction

Logic Apps is a part of Azure App Service and it is basically used to automate the access and use of data across clouds without writing code. Logic Apps is basically designed to orchestrate Business processes and System Integration based on some workflow defined according to the process by the user. Logic Apps is a fully managed iPaaS (integration Platform as a Service) which allows developers to not worry about building hosting, scalability, availability, and management; in fact, Logic Apps will scale up automatically to meet demand. Such applications are “no code” solutions that are authored by dragging and dropping elements onto a design canvas. This empowers developers and IT pros alike to create useful integration workflows that solve a variety of needs. 

It’s suitable in the scenarios like when you have a predefined series of events that need to be followed in a business process, such as - if you want to replicate records from a line of business systems back to a SQL database and notify the front desk via an email; Send an SMS notification when a certain condition is met; Identify negative Tweets and post into a Slack channel. Logic Apps can help each of these scenarios and more. 

Workflows are initiated with a “trigger” event, such as a particular email, or a change in an Azure Storage account. Workflow steps then take place as “actions”, which operate against a series of “connectors” for data flow. To get going even more quickly, check out the numerous pre-built Logic app templates in the Azure Marketplace.

Azure Logic Apps Workflow

Let us discuss about a few of the terminologies we used above :

  • Workflow
    It is a graphical representation of a series of steps required in a business processes. Constructing such workflows is now super easy with Azure App Services. You can define a workflow either declaratively using a JSON file (which you can check-in as source code) or using the new Logic/Workflow designer introduced today within the Azure Portal.
  • Parameters
    are things that you want to reuse across workflows. Re-using values or even complex objects throughout the definition makes it easier to comprehend. Separating out configuration from the definition itself makes sharing easy as well across different environments.

  • Managed Connectors
    Connectors are the pre defined APIs that you used in your processes. They are created specifically to aid you when you are connecting or working with your data. Some of the most common connectors are Bing, Google sheets, Search, Facebook, Twitter, Twilio etc. You can find the whole list of connectors here. If your needs are not fullfilled using the existing connectors, you can always roll on your own API app and integrate it with your logic app.
  • Triggers
    A trigger is an event that starts the new instance of a workflow on a specific event like adding a new record in the database or arrival of an email. You can poll for a trigger or manually initiate it or schedule it as per your need.

  • Actions
    Each step after the trigger in a workflow is called an action. Each action typically maps to an operation on your managed connector or custom API app.

Advantages of using Logic Apps include the following,

  • Easy and convenient to design complex processes using user friendly design tools.
  • Logical Implementation of workflow without code.
  • Many templates available for common scenario.
  • Easy to customize logic app with your own custom APIs, code, and actions
  • Can work seamlessly with On-prem and cloud Services.
  • Build off of BizTalk server, API Management, Azure Functions, and Azure Service Bus with first-class integration support

Shortcomings of the Azure Logic Apps

  • Logic App Designer is not present in Visual Studio which is painful if you’re directly working with Visual Studio.
  • Triggers on Cutom API only support the POST verb as of now.
  • Batch facility is not present as of now which means if there are multiple records that are validating the conditions in that case the trigger will be triggered that no of times only instead of grouping them and process them in one batch Example: if there are multiple tweets with some hastag and you want to see the tweets in a mail then it will trigger multiple mails instead of one mail with all the tweets.

Cost

Cost of the logic app is directly related to the actions and based on the slab below it will be charged.

Note

Even polling for a new record is considered as an action. In our example we are polling for new Instagram media upload every minute so if this logic apps runs for 7 days then it will be 7(days) * 24 (hours) * 60 (minute) = 10080 actions for the polling. In addition to that Posting on Facebook will also be considered as an action and will be charged according to the plan below. However if the condition dissatisfies or fails it will not be charged.

Azure logic app cost

Developer Tools Required

  • An Azure Subscription(Mandatory)
  • Visual Studio 2013/2015 (Optional)
  • Azure SDK for .Net (Optional)

Working Demo

We will create a sample Logic App in our Azure Portal that’s going to look out for new media in my Instagram account and post it to facebook .

  • Go to Azure Portal and login with your credentials.
  • Click on the + Button on the top left to add a new resource in your azure subscription and select Web + Mobile and then Select Logic Apps.

    Azure Portal

  • Give the suitable App Name along with subscription and location. You can select from multiple Data Centers where you want to host your logic apps. At present it supports 15 data centers across the globe with the majority of them located in US, Asia, Europe and Australia. You can select the nearest location in order to minimize network latency.

    Also, Create a new resource group if you don’t have an existing resource group( Resource Group are a logical and physical grouping of all type of resources required in a project environment like webapps, mobileapps, databases, caches etc)

    Create logic app
  • Click on Create button and it will start the deployment of logic apps into your resource group. In my case I used the resource group called Test and the resource is created inside that resource group.

    deployment of logic apps

  • Click on the Edit button on the Top or Go to the Development Tools and launch the Logic App Designer

    Logic App Designer
  • There are multiple templates that are already present to make use of like Copying a new file from DropBox to OneDrive as soon as there is a new file upload to the dropbox account. For our example, we need to use the blank Logic App.

    blank Logic App
  • Here we can use the Managed APIs from the set of available connectors like Office 365, VSTS, DropBox, YouTube, CRM, SalesForce etc. As we discussed if we don’t want to use the Managed APIs we can use our custom APIs hosted as Azure API APPS or Azure API Management.

    Managed APIs
  • As we need to check if there is anything new added to the Instagram account, we need to use Instagram Connector and here it will be triggered whenever I am going to upload a new Media so this connector will keep on polling the Instagram account once and trigger this logic app when this conditions satisfies.

    Instagram Connector

  • Click on Sign In and Authorize the LogicApp to use your Instagram account by logging in into the Instagram account and clicking on Allow Access.

    LogicApp
  • You can choose to add a new Condition or an action and as we discussed,  action can act as a Trigger for another action or condition in a workflow. In our demo we are going to check if the new media has a hastag #Facebook associated with it then I am going to post it to my Facebook account, otherwise not.

    Azure Logic App
  • Here we have added a condition that Tags on the media containing Facebook, then we are going to post on Facebook, otherwise not. We followed the same steps that we used in step #7 & #8 but instead of Instagram we used the Facebook Connector which posts the content to Facebook.

    Azure Logic App
  • Now you can control what you want to post on Fb using this connector. I am going to post a status message “Heya!! I just posted a new Pic on Instagram” along with the Image URI. You can also customize with your privacy settings with that post from the API settings itself. For that Just Click on the Show Advanced Options in the Facebook Connector and Enter the suitable information.

    Azure Logic App

    Azure Logic App
  • Now our workflow is completed so we can click on Save Button on the Top Left of the Designer. It will complete our Workflow and In our case we have 1 Trigger (new upload on Instagram account) and based on condition we have two actions (post it to fb and do nothing)

    Logic Apps Designer
  • Run the Trigger to run the LogicApp Manually and it will start polling the Instagram account

    Logic Apps Run Trigger

  • Now as we setup it will keep on polling my Instagram account every 1 minute and It will trigger this logic app whenever there is a new upload in my account. You can see that there is new job that Runs and the status of the Run is in the All Runs summary window

    Logic Apps Trigger

  • Click on the Run to see the details of all the steps and see if our demo is successful or not.

    Run Logic Apps

I can further drill down to see the details of the Media in each step
Azure
Azure Logic Apps

Code

The Designer has generated a code for the work that you have done and you can go back to the Developer Tools blade and select Logic App Code View. The code is stored in the JSON format and you can directly create this JSON Template from Visual Studio and publish it to azure directly instead of using the designer on the Azure Portal.

Logic App Code View

Conclusion

Azure Logic Apps is the part of the Azure App Service and its one of the most important additions for the Enterprise Applications. Logic Apps are basically designed to orchestrate Business processes and System Integration. Logic App service is a Code-less integration service for communicating with different services or platforms. It is fully managed and with a lot of connectors available and custom APIs and you can design and orchestrate your complete business workflow.


Similar Articles