Sunday, March 18, 2018

Getting Started with Logic Apps - Fundamentals

What is Logic App?


It is workflow, an orchestration in cloud (which is hosted on Microsoft Azure) with connections to systems, services.

It is an Offering from Microsoft primarily to cater the need of integrating and designing business workflow/process with orchestrating the SAAS services. It also now extends to services which are on premises.

It is one of the Service amongst the other Azure App Services (Web Apps, Mobile Apps, API Apps,Functions) and runs on top of Azure Service Fabric. It is a fully managed iPaaS (integration Platform as a Service) solution which allows developers to build highly scalable workflows and will automatically scale to meet demand. 


Logic app on Azure Service Fabric


In Layman term – Microsoft has provided a platform which is managed by them to enable a user to design/create a workflow which has a provision to connect services which are cloud based or also on premises (integrating various services) thus the name IPaas (integration Platform as a Service). You get a browser based designer (also available in visual studio), where you can design the workflow by selecting the appropriate Trigger (the way to start the workflow based on certain event ) thereafter adding new steps Action (it can be after a Condition) where you select the Connectors(the way to connect to data ,services or system). After you save the workflow, it gets deployed – ready to use. And you don’t have to worry about the load scenarios, it auto scales and you are charged only when it is executed (number of Actions).



It is also marketed by Microsoft as Serverless, by serverless it doesn't mean there are no servers, it just means the developers do not have to worry about the underlying infrastructure (there is an Abstraction) instead they just have to focus on the business logic (faster development). The other two offerings under serverless are Azure Functions and Event Grid


serverless offerings from Azure

Logic Apps is based on the Workflow Definition Language and provides a way to simplify, automate and integrate scalable workflows into the cloud, WDL is based on following basic structure
wdl basic structure


So whatever you create in Logic app Designer gets converted in JSON. JSON is used to define the workflow based on WDL, and same can be seen in Code view in Portal or in Visual Studio.


Thus from development perspective- Logic app is nothing but JSON definition along with ARM Template and from runtime perspective - Logic apps is a Job Scheduler with a JSON based DSL describing a dependency graph of actions.



Building Blocks of Logic Apps


Trigger

Logic Apps always start from a trigger and then execute a series of steps. As in BizTalk Message creates instance of Orchestration likewise trigger creates an instance of Logic Apps.

Push, pull, repeating and manual are way to trigger Logic Apps

Push – This is reactive type, where the consumer notifies the workflow or creates an event to start the workflow(logic app endpoint).

Poll(pull) – This is proactive type, where the workflow polls a system or service for notification or event.(Service endpoint)

Repeating(Recurrence) – Prescribed Schedule to start the workflow

Manual – Manually starting the Workflow(You can click Run now button in Portal)


Connectors

In my perspective, the base of Logic Apps is connector – everything in logic apps is around connectors (All components are api apps). All connectors are technically API apps that uses a metadata format named swagger, REST as pluggable interfaces and JSOn as the data interchange format. It can act as trigger and action, to connect with any service is via either  by Trigger or Action and both are api connections.. In other words, connectors is encapsulation of authentication, data validation in combination of Triggers and Actions.

It is on same line as that of Adapters in BizTalk. And at the time of writing this post there are 200+ connectors available, and every week there is addition to it.

     1.Standard connectors
    This are pre-included and are available in Logic App and does not cost extra.

     2.Integration account connector
It comes at extra cost as these connectors become available when you create Integration Account. It enables us to deal with complex integration scenarios where maps, trading partners management etc are involved .

Integration Account connector

3.On premise connector(Hybrid connector)
     This are the connectors used for connecting to systems which are on premises,
     and this is done with the help of on-premise data gateway.For now connectors for DB2, Oracle DB, SQL Server, FileSystem and Sharepoint server, Informix, Websphere MQ etc are available.

    4.Enterprise connectors
 It comes at extra cost for Enterprise level systems like MQ and SAP.

    5.Custom connector
 If none of above connectors satisfy the need, then there is provision to create a custom connector just like we have provision in BizTalk to create custom Adapter.


Action

Every step after in Logic App (even trigger) is called Action (condition can be before it). Action always mapped to operation in Managed Connector or web api.


Enterprise Integration Pack

Integration Account is required for Enterprise integration Pack. It enables to have BizTalk like power in cloud, where you get provision to store the artifacts (xsd, maps, trading partners etc) and use them to build Enterprise level B2B/EAI solution. It has supports for industry standard like AS2,EDI X12, EDIFACT , Flatfile,XML etc.

All the features around B2B/EAI solutions like validation, transformation, Encoding , decoding are made available through it enabling to have solutions build in Serverless fashion.

Flow controls


  • Scope
         Logical grouping of actions


  • Response
       For any request that comes in there can be response associated with it


  • Condition
     Evaluates an expression and executes the corresponding result branch


  • ForEach
     Will iterate over an array and perform inner actions for each item


  • Until
     Will execute inner actions until  a condition results to true


  • Switch Statement
     Only one branch will be executed corresponding to condition of the            particular   case


  • Calling another Logic App (Nesting)
     Workflows can be nested by making a workflow exposing a  callable endpoints (can be reached over an url)


  • Calling custom code via Azure function
     In a scenario where custom code is required to be executed, the code can be added as Azure function and can be called from Logic app


Security

Security in Logic app can be applied in various ways and on different levels like securing access to triggers, securing access to Run History, securing logic app editing etc.

Out of box we have provision of SSL(shared access signature) and restriction can be applied as to who all can call the logic app based on IP Addresses(IP Filtering), you can look at it at Settings->Access control configuration. Azure Role Based Access Control  and Azure Resource Lock can be used to prevent accidental/intentional editing or deleting of the logic apps.

If you think above aren’t enough, then we have option to leverage the power of APIM where Azure Active Directory, certificate, OAuth, or other security standards can be used.


Monitoring

For monitoring there is out of box feature which tracks and enables us to view the state of each logic app instance – Run history , it includes all the details like input and output of each step in the workflow. Through this we can check if workflow was successful or failed, how much time it took to complete, what was input received, what was the output, also exception details if there are any.

Also on same line we have tracking for Triggers – Trigger history which keeps state of triggers if they were successful, failed, skipped etc.

Apart from above two we can leverage  azure diagnositcs, api management, azure alerts for additional monitoring of Logic apps and implementing alert mechanism on top of it.


Related Post