다음을 통해 공유


Azure Logic Apps - An Overview

In any enterprise, workflows and processes are important to run a business. Enterprises need a mechanism for automating different business processes and integrating multiple applications they have. With the increase in cloud adoption, there is a growing need for integrating applications, as well as data and workflows, in the cloud.

Microsoft Azure Logic App Services provides a mechanism for doing such integrations and business process automations, thereby creating workflows by orchestrating Software as a Service (SaaS) components.

In this article, I will provide an Overview, Key Components, Advantages and a Practical Scenario for using Azure LogicApps. 

What are Azure Logic Apps?

Azure Logic Apps provide a mechanism for application integration and workflow definition in the cloud. It provides a visual designer for configuring the workflows. You can define a workflow with connectors and logic creation using inbuilt standard connectors and enterprise integration connectors.

Logic Apps is a fully managed IPAAS (Integration platform as a service) with inbuilt scalability. You do not have to worry about hosting, scalability, availability and management. Logic Aps will scale up automatically to manage demand.

It is a Serverless application.

By serverless it doesn't mean there are no servers, it just means the developers do not have to worry about the underlying infrastructure. They just have to focus on the business logic. This results in a faster development and code simplicity.

At the sametime, it comes up with a consumption-based pricing plan, which means that the application is not charged if it is never used. All actions that run in a LogicApp are metered.

Azure LogicApp comes up with a workflow definition Language to describe its schema. The structure of the schema is as follows:

{

"$schema": "",

"contentVersion": "",

"parameters": { },

"triggers": [ { } ],

"actions": [ { } ],

"outputs": { }

}

Logic Apps Pricing

In Logic Apps, all the actions and trigger that are part of the workflow, are metered.

Logic Apps supports a volume based tiered model. The price is computed based on the actions executed.

Here is the pricing sheet for the Central US region and currency as INR.

 

The storage and networking cost would be charged separately.

Microsoft Azure LogicApps Components

Workflow – is used to define the different steps of your business process, using a graphical user interface.

Managed Connectors - are used to connect to different data sources and services. Azure LogicApps provide an in-built set of managed connectors that cover different areas like social media, file FTP and many more.

Triggers - initiate a workflow, and create a new instance of the workflow. A trigger can be an arrival of a file on FTP site or receiving an email. There are different types of triggers as mentioned below -

  1. Poll triggers: These triggers poll your service at a specified frequency to check for new data. When new data is available, a new instance of your logicapp runs with the data as input.
  2. Push triggers: These triggers listen for data on an endpoint, or for an event to happen, then triggers a new instance of your logicapp.
  3. Recurrence trigger: This trigger instantiates an instance of your logicapp on a prescribed schedule.

Actions - An action represents a step in the workflow. It can invoke an operation on your API.

Enterprise Integration Pack (EIP) Connectors - The EIP connectors provide functionality like BizTalk. These connectors are used for complex enterprise integration scenarios such as XML messaging and Validation. It supports exchange messages through industry-standard protocols, including AS2, X12, and EDIFACT. It requires an "Integration Accounts" to store different artifacts, like schemas, partners, certificates, maps and agreements.

Azure LogicApps – Advantages

Azure LogicApps have different advantages. I have mentioned some of these that I personally feel are important to know -

Inbuilt Connectors - There are plenty of inbuilt connectors, triggers and actions that cover many of the common business scenarios. An example is performing sentiment analysis for a topic on Twitter.

Minimal development efforts - With the graphical designer available in a browser as well as in Visual Studio, you can define and configure complex business processes with minimal development or no development efforts at all. The LogicApp automatically generates the code in the background.

Extensibility - If the list of connectors do not meet your need, you can create your own custom APIs, Azure Functions and integrate them to the workflow.

Integration - You can connect disparate systems together. You can integrate your on-premise legacy systems with the new ones in the cloud. Also, you can integrate different LogicApps together.

Templates - There are plenty of predefined templates that are available for common business cases, like HTTP Request-Response, that greatly simplify the work of the development team. Templates are the fastest way to get started with the power of LogicApps.

§ DevOps Support - It supports the continuous integration and continuous deployment methodology.

§ Advanced Integration - It supports mature integration scenarios with the power of XML messaging, trading partner management and more. You can leverage the power of BizTalk, which is a leading industry integration solution.

§ Inbuilt Diagnosis - For any issues related to LogicApps, the Azure portal provides many tools to diagnose each logicapp at each step. You can see the trigger history and drill into that to see why the trigger didn't instantiate a LogicApp.

Logic Apps - Practical Scenario

I will demonstrate the capabilities of Azure LogicApps using a practical scenario.

In any organization, the chief marketing officer (CMO) would like to understand the sentiments for their different products and services on any social media medium, for example Twitter. To achieve this requirement, we can use Azure LogicApps and other Microsoft Azure services, as mentioned below.

Goal

Our goal is to perform sentiment analysis for a hashtag on Twitter (say #Azure) and store the results into SQL database.

Proposed Solution

To implement this, we will develop an Azure Logic App that will use Azure Cognitive Services to perform sentiment analysis. We will also use Azure Functions to do some computation. Here is the schematic view of this scenario.

Solution Implementation

For implementing this scenario, you need a Microsoft Azure subscription. You can implement it through a trial subscription as well.

In a browser window, open Microsoft Azure portal – https://Portal.Azure.Com. Login using your credentials. Perform the steps mentioned below.

Step 1 – Create a new cognitive services of type Text Analytics (preview).

New > Data + Analytics > Cognitive Services.

This service will be needed as a step in the Logic App that we will create.

Step 2 – Create a new SQL database server.

New > Database > SQL Database.

We will need this to store the sentiment score and category.

Step 3 – Create a new Azure function by selecting the following:

New > Compute > Function App.

This function will compare the sentiment score returned by the cognitive service we created in Step 1 and give it a category – “Red” or “Green”. In this function, we will also save the sentiment category to SQL database we created in Step 2.

Step 4 – Create a new Azure Logic App by selecting the following

New > Web + Mobile > Logic App.

We will need this Logic App to glue the different services that we created in the steps above. Once the new Logic App is created, click on the Logic App Designer to add the different steps.

Workflow Steps

Mentioned here are the details for different steps in the workflow.

Step 1 – Twitter Trigger

This step will listen for the hashtag #Azure every hour. Once a tweet is posted, it will be passed to Step 2.

Step 2 – Azure Cognitive Services

Identify the sentiment associated with the twitter text. This will calculate the score and pass it to Step 3 - Azure Function.

Step 3 – Azure Function

Receive the score from the Step 2 and classify the score as Red or Green. For simplicity, I have classified the score of greater than 0.3 as Green. This function will also store score and classification details to SQL database.

Here is the code from the Azure function –

#r "System.Data"

#r "System.Configuration"

using System.Net;

using System.Data.SqlClient;

using System.Configuration;

 

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)

{

    log.Info("C# HTTP trigger function processed a request.");

    string category = "Red";

    dynamic data = await req.Content.ReadAsAsync<object>();

    log.Info(data.ToString());

    double sentimentScore;

    double.TryParse(data.ToString(),out sentimentScore);

    log.Info(sentimentScore.ToString());

    if (sentimentScore > 0.3)

        category = "Green";

    log.Info(category);

 

    var connString  = ConfigurationManager.ConnectionStrings["sqldb_connection"].ConnectionString;   

    using(SqlConnection logicAppsConnection = new SqlConnection(connString))

    {

        string insertCommand = "Insert into SentimentScore (score,category) values (@score,@category)";

        logicAppsConnection.Open();

        using (SqlCommand command = new SqlCommand(insertCommand, logicAppsConnection))

        {

            command.Parameters.Add("@score", sentimentScore);

            command.Parameters.Add("@category", category);

            command.ExecuteNonQuery();

        }

        log.Info("Score details added to database successfully!");

    }

    return req.CreateResponse(HttpStatusCode.OK,category);

}

Some of the sample records from the database are shown below -

..and this completes a practical scenario implementation of Azure Logic Apps.

Just a word of caution, if you are not using your Azure Function, please disable it. If you keep it enabled and if it is executing, you will be charged.

Conclusion

Azure Logic Apps is a powerful, extensible and user friendly platform for developing enterprise integration applications. In my opinion, it can be used extensively for scenarios we just saw.