Azure Logic Apps : Presentation, Tips and Feedbacks
Logic Apps is a cloud-based platform (Azure) for creating and running automated workflows that integrate with applications, data, services and systems. With Logic Apps we can create complex workflows/orchestrations. An orchestration is a collection of actions that are executed to accomplish a specific task.
A workflow always starts with a single trigger, which specifies the condition to meet before running any action in the workflow. Each time the trigger fires, Azure Logic Apps creates and runs a workflow instance.
A trigger is usually an event or a HTTP request.
Below is an overview of the web-based interface of Logic Apps:
Dynamics 365 And Logic Apps
Current situation with Dynamics 365 is a little bit weird in Logic Apps.
Main connectors to interface with D365 (for instance with Power Automate) are Dynamics 365 and Common Data Service.
But if you type 'Dynamics 365' in Logic Apps to get the list of available connectors related to D365, you will see that:
- You get a deprecated version of Dynamics 365 connector
- The Common Data Service connector is not listed
In fact Dynamics 365 connector used for Logic Apps is officially deprecated by Microsoft. And Common Data Service connector was renamed to Microsoft Dataverse (legacy).
So Microsoft recommendation for Logic Apps is to use the Microsoft Dataverse (legacy) connector.
Note the term 'Legacy' in the name of the connector.
The Microsoft Dataverse (legacy) connector will eventually be deprecated in the feature and new Microsoft Dataverse connector will be used instead. Currently this new connector is not supported on Logic App and Microsoft team is working on provisioning that support. So wait and see...
A connector for Dynamics 365 for Finance and Operations (F&O) is available
It contains an event trigger:
And a set of actions :
Logic Apps workflows management
Available tools to design Logic Apps workflows
You can design a workflow in Logic Apps with several tools:
- Web-based designer in the Azure portal
- Microsoft Visual Studio Code
- Microsoft Visual Studio
When you design your workflow it is possible to access at anytime the JSON source code whatever tool you use.
Note that sometimes it is faster to modify JSON code to implement some changes (setting variables, calculations, ...).
Below is an overview of a Logic Apps workflow in Visual studio code : available triggers/actions on the left, graphical designer in the middle, JSON code on the right.
Create a Logic Apps workflow in Azure Portal
I describe below the method to create a workflow with the web-based designer.
To create a Logic Apps workflow connect to Azure Portal, go to Azure services and click on Logic Apps icon
You will have to select your Azure subscription, a resource group and a region and give a name to your Logic Apps
When your Logic App is successfully created then you have to create a workflow: select Workflows in the sidebar on the left, click on the Add button and set a name for your new workflow.
Note that a Logic Apps can contain several workflows.
Then you are ready to perform the first task: adding a trigger.
In the below example I select Azure connector 'Fin & Ops Apps (dynamics 365)' and select 'When a Business Event Occurs'
When your event is configured you can then add actions: below I added an action to parse the result of the business event and then I initialize a variable
There is a wild range of actions available in Logic Apps separated in two categories: built-in actions and Azure actions.
- built-in actions : control workflow (condition, For Each loop, switch, ...), manage or manipulate data (data operations, variables management, operations with timestamps, ...).
Below buit-in actions groups:
And for action group 'Variables' the list of available actions:
- Azure actions. More than 200 connectors are available (from Microsoft and third party providers). Below is a list of widely used connectors:
- Azure Blob Storage
- Azure Functions
- SQL Server
- SharePoint Online
- Service Bus
Some values can be set by built-in functions. Many functions (called expressions) are available:
• String functions : concat, split, startswith, substring, trim, length, ...
• Collection functions : contains, first, last, intersection, ...
• Logical comparison functions : and/or, equals, greater, less, ...
• Conversion functions: bool, float, int, ...
• Math functions : add, div, mul, min, max, ...
• Date and time functions : addDays, dayOfMonth, formatDateTime, ...
• Workflow functions
• URI parsing functions
• Manipulation functions: JSON & XML
An expression Editor is available to navigate through all functions.
Below I use the int() function to cast a string value (quantity) to an integer.
But if you know the name of the function you need it is usually easier to edit the JSON code.
Logic Apps and loop control
You have to be careful with loop control component (For Each).
By default, iterations in a loop run at the same time, or in parallel. This behavior differs from Power Automate's 'Apply to each loop' where iterations run one at a time, or sequentially.
Default value for degree of parallelism is 20.
It is possible to modify this value In the settings of the component and to set up sequential "For each" loop iterations.
Note that if the default behavior (loops running in parallel) is normally reliable for simple loops. But with nested loops you can get unpredictable results.
Always set degree of parallelism to 1 when you manipulate nested loops.
To get predictable results from operations on variables during each loop iteration, run those loops sequentially. For example, when a concurrently running loop ends, the increment, decrement, and append to variable operations return predictable results. However, during each iteration in the concurrently running loop, these operations might return unpredictable results.
According to Microsoft documentation iterations always run sequentially, not in parallel with nested loops. But based on my own experience it is not the case so always check that degree of parallelism is equal to 1 for nested loops.
Another situation where you need to set the loop to run sequentially is when you want to pause the next iteration in a "For each" loop by using the Delay action
Logic Apps and Power Automate
Logic Apps and Power Automate are both designer-first integration services that can create workflows. Both services integrate with various applications using connectors.
Power Automate is built on top of Logic Apps. They share the same workflow designer.
Key differences between Logic Apps and Power Automate:
- Logic Apps is part of the Azure platform. It requires an Azure subscription in order to build and run logic apps.
Power Automate is available as part of O365/Dynamics 365 applications
- Logic App is PaaS and Power Automate is SaaS
- There is the concept of standard and Premium connectors in Power Automate but not in Logic Apps.
Premium connectors require additional licenses.
- With Logic Apps you can manage the Office 365 platform and Azure platform. Logic Apps has a lot of actions to create, configure, connect and delete many kinds of Azure resources. They can connect to function apps, delete blob storage, create a virtual machine and so on.
Power Automate also has a lot of actions to manage Azure, but many of them require a premium connector. As discussed earlier, premium connectors are costly.
- You can work with Logic Apps in a browser (web-based designer) or with a development tool as Visual Studio or Visual Studio Code
Power Automate is a browser-based application so you can modify a workflow only in a browser
- Logic Apps and Power Automate generate JSON for created apps and workflows.
In Power Automate we can see the generated JSON but unfortunately we cannot edit the JSON.
In Logic Apps, we can see the generated JSON. But unlike Power Automate, we can edit the generated code. The edited JSON will be automatically converted into actions in the workflow. This feature allows us to copy content from one action to another, and we can even copy actions from one workflow to another.
- Logic Apps cannot be operated upon from mobile application
Power Automate can be accessed or modified in a mobile app
- For Logic Apps you pay as you use (whenever something runs: logic Apps, connectors, triggers, actions, ...). It is a consumption-based billing service, which requires an Azure Subscription in order to build and run logic apps
For Power Automate you pay per flow or per user basis (license assigned to a user)
- With Logic Apps you can create workflows with complicated requirements.
With Power Automate you create simple workflows.
Power Automate is used by business people to concentrate on their workflow. On the other hand, Logic Apps is used by people to run their apps and other services.
- Since Logic Apps is an Azure service, developers are able to take advantage of Azure Monitoring, which will raise alerts when there are failures that occur within Logic Apps or other Azure services.
Decision points between Logic Apps and Power Automate:
- If your workflow is mostly using Azure services then you should use Logic Apps. If you workflow is using Office 365/Dynamics 365 then you should use Power Automate.
- If your workflow is designed by a software developer you should use Logic Apps. Integration with Visual Studio is an advantage.
For non-developer audience you can use Power Automate.
- You should also check if the connector you need is provided in both environments. Even if Microsoft claims that connectors are available in both Azure Logic Apps and Power Automate, reality is slightly different.
What about Azure Function ?
But in a Logic Apps workflow it is possible to call an Azure function. For instance if you have a complex calculation with many operators you will write an Azure Function to perform this complex task and then you will call the Azure Function in your Logic Apps workflow to get the result.
And if in your calculation you have to implement loops and check conditions (IF... ELSE) it is definitively a good idea to use Azure Function.
As explained previously all those tasks are possible with Logic Apps but you will save time if you embed all this logic in an Azure Function.
If you have a complex logic a Logic Apps workflow diagram can be difficult to read in the designer. And maintainability of the Logic App can be a problem.
Perhaps Microsoft should have chosen another name than "Logic Apps"...
Another advantage of Azure Function is execution speed: calculations and complex logic (conditions, loops) run faster in an Azure Function than inside a Logic App workflow.
Logic Apps can be a great tool if you have to interface an application with another third party application if a Logic App connector exists for that third party app.
For example a scenario could be to add a button in your application to connect to another application in order to get data you finally display in your application.You simply have to generate a Business event and write a logic Apps workflow with a couple of components: a Business event trigger, a connector to the third party application, some basic logic and it's done...
Logic Apps is perfect for that scenario.
But if your have a complex logic you will probably have to additionally use Azure Functions to get better performance.
Concerning the choice between Logic Apps and Power Automate:
If you have to interface with Office365 / Dynamics 365 the choice is easy : use Power Automate.
Otherwise Logic Apps is probably a better choice : main argument is that what you can do with Power Automate can be done with Logic Apps. But the opposite is not always true.
If you have an Azure subscription and are familiar with Azure services Logic Apps is also probably a better choice.
Another advantage of Logic Apps: the possibility of modifying the generated JSON code. If you are a software developer you will save time and will be more productive.
Add new comment