Understand Azure Logic Apps
What is Azure Logic Apps
Azure Logic Apps is a workflow which helps to automate the business process. Logic Apps is a serverless application which means no need to manage infrastructure, auto-scaling, and billing based on execution. Logic Apps make easier how to design and create scalable solutions for data integration, app integration, system integration, enterprise application integration (EAI), and business to business communication whether it is in the cloud, on-premises or both. Logic Apps uses pre-built connectors to connect the services. There are three main steps to automate your business, first one is select the connectors for your business or you can make custom connectors, the second one is using the design tool to build your workflow from the components and the third one is save your design, it will run automatically in the cloud. The Logic Apps is totally based on design not code base app building but you can write simple code on azure function and execute it in Logic App.
Example, how you can automate workload using Logic App
- You can send an email notification with Office 365 when events happen.
- You can monitor tweets for a specific subject and perform sentiment analysis.
Let’s understand the above diagram to monitor social media for a reaction of a new product launch by a company. Here we are using twitter connector.
- Step1: When the new tweets come, it detects the sentiments.
- Step2: There is a conditional operation that checks it is positive or negative.
- Step3: If it is positive, it will store in documentDb.
- Step4: If it is negative, will trigger an email to the customer.
Let’s understand how logic Apps work
Behind the scene, there is the following three components work
- Connectors
- Triggers
- Actions
Connectors: Logic App hundreds of pre-build connectors including Azure Service Bus, Functions, and Storage, SQL, Office 365, Dynamics, Salesforce, BizTalk, SAP, Oracle DB, file shares. A connector is a component that provides an interface to external service. The connector is nothing but it uses the external service REST API or SOAP API to do its work. For example, you want to send an email when an event occurs, So to do this you can automate this by using Office365 connector, using this connector you can manage emails, calendar, and contacts.
Also, you can write a custom connector if you do not have a pre-built connector as per your business need. So, you can write your own connector but it must have a REST or SOAP API as pre-build connectors are nothing but a wrapper of REST or SOAP API. To write a custom connector, you have to follow the following procedure
- Generate an OpenId or Postman description of API.
- Use that API description to create a Custom Connector resource in the Azure portal.
- You can give an icon to your connector.
You can share your custom connector to other organization’s business process or also you can submit this to Microsoft’s for certification, after getting certification from Microsoft, they include your custom connector as a pre-built connector.
Triggers: Business workflow has a different type of task first comes trigger, a trigger occurs when an event happens or we can say a specific set of conditions met or satisfied. This trigger activate automatically when the condition met.
Actions: In your business processes, action performs the operation that executes the tasks. An action executes when a trigger activates or finishes another action.
Let’s understand the triggers and actions by the following diagram:
One more thing in this process called “Control” action; business workflow needs different actions based on data being processed. So there are following few control actions have in Logic Apps:
- Condition statements controlled by a Boolean expression.
- Switch statements.
- For each and Until loops.
- Unconditional Branch instructions.
How to decide to use Logic Apps
There are some scenarios, so you can decide when to use Logic Apps. Logic Apps is not a good option for real-time processes and complex business rules. Here are some points, based on these you can decide when to use Logic Apps:
Integration: Logic Apps designed for multiple applications, it works well with multiple applications that work together. If your application using a single external application then Logic App is not fit in your business process.
Performance: For any business process, performance is a key part. The Logic Apps can process large data set in parallel to get achieve your throughput. The Logic Apps execution engine scales your apps automatically.
Conditionals: As we discussed above control action, Logic Apps provide conditional statements like Boolean expressions, switch statements, and loops so your application can make decisions based on your data being processed. You can build highly complex and nested conditionals logic in your Logic Apps. It is not best to fit when you think that your conditional statements can be writing easier in code instead of Logic Apps Designer but the other option is there to write your code in a function app and invoke the function app using Logic Apps.
Connectors: Your business workflow met the requirement to use pre-build connectors, if not then you have to create a custom connector, to do so, your service has the REST or SOAP API then you can create the connector without writing code. If your service has not REST or SOAP, then you will need to create the API first before making the connector.
In this article, I have completed almost a conceptual part of the Logic App. A few more articles will write as the next parts of Logic Apps that will be on the hands-on of Logic Apps.