Skip to main content

Should I use Logic Apps or Azure Functions?

There are multiple ways to resolve the same business problems using Azure Services. Numerous times I was involved in a discussion where Azure Logic Apps and Azure Functions were put side by side.
In this post I would like to build another perspective of these two Azure services and when we shall use one or another, taking into account our functional needs and expectations.
Service Overview
Azure Logic Apps allows us to build workflows that are runnings as a service inside Azure, that can scale automatically and can be integrated with a high number of services from Azure or on-premises systems.
Azure Functions are the serverless offer from Microsoft that are highly scalable, well integrated and ready to respond to our future need.
Why is it hard to decide?
A part of the functionality offered by these two services overlaps or are similar. Decided on what business scenarios we shall use one or another it is not easy. Besides this, both services are so well integrated, that you have the feeling that you don't know which one shall integrate the other one.
Perspectives

1. Pricing
The price model for both of them is similar. Most of the costs are coming from the computation side, where you pay per usage and number of triggers. Both services can be hosted inside a dedicated App Services environment together with other services that you might have.
Inside Logic App, when you want to use Integration Account, an additional fee needs to be paid every month (fixed price/month).

2. Security
The Logic Apps can be accessed over HTTP triggers using a Shared Access Signature (SAS) similar to the one that we are using for Azure Storage., generated on top of the secret key, that can also be regenerated. There are other security layers supported by IP restrictions. In most of the cases, API Management is put in front of the Logic Apps to manage the security access and provide a stable API.
The Azure Functions are based on API keys, that can be defined at Azure Function instance level or per each function, depending on our needs. Additional security layers can be added using API Management or using a simple Azure Functions Proxies, that is more simple than API Management but can provide us with the right security functionality for HTTP triggers. When we host them in inside dedicated App Services env. We can add AD, Facebook, Google or other providers without code change, using the functionality that already exists inside App Services.

3. Networking
Except for the default consumption plans, Azure Functions are well integrated with VNETs. It enables us to integrated them with our existing on-premises (Site-to-Site VPN or ExpressRoute) or Azure infrastructure and to avoid to expose public endpoints - hybrid connectivity.
Logic Apps have a particular functionality to integration point for on-premises endpoints using On-premises Data Gateway. The solution needs to be installed on-premises and connect directly to our Logic App instance. There is no magic behind the scene; the gateway is using Azure Service Bus Relay to provide the secure tunnel between our on-premises system and Logic Apps.

4. Error management
Because Azure Functions are just a place where we run our code, there is no specific functionality for it. As for a typical application, we need to manage the exceptions and error by yourself. Retry mechanism needs to be integrated by yourself. Both retries and exceptions handling mechanism can be differed based on the language that we are using.
Azure Logic Apps are more user/develop friendly and provide us with support for exception handling that can catch the error and log it. There is an automatic retry mechanism can be used customised based on our needs. The retry mechanism is not perfect, and there are situations when human intervention is required to continue the flow after an error. This is caused because Logic Apps are workflows with a state.

5. Stateful (State)
Logics Apps are stateful by design. It goes hand in hand with workflow support and with excellent web and Visual Studio interface that allows the user to define the flow.
Azure Functions are a serverless approach for computation, and by design they are serverless. Using Durable function approach we have a framework that enables us to have business flows inside Azure Functions that have an internal state. This framework will allow us to run multiple functions in parallel and have long running functions. The state is stored inside Azure Storage and sometimes can create confusion and buggy code, but a strong development team can handle and resolve these issues. 

6. Developer perspective
Inside Azure Functions, we need to do all by code. There is no drag and drop support. Multiple programming languages are supported and more flexibility to the developer. In contrast, Logic Apps can be defined using a friendly interface where we can connect to external services, implement business logic and many more. You can define a Logic App without running a line of code. This feature is powerful, but in complex business scenarios, this can be tricky to manage.

7. External Connectivity
Azure Functions are built around the concept of output and input bindings and triggers. Most of Azure Services can be integrated directly with Azure Functions and all the time HTTP binding and triggered can be used to integrated provides that are not supported by default.
In contrast, Logic Apps are well integrated with a high number of applications and systems using connectors. There are not only cloud connectors, but also a high number of on-premises connectors, making Logic Apps appealing for enterprises that don't want to implement custom connectors. Connectors are designed smartly by storing the credentials and connectivity information inside them. Another cool feature is the possibility to reuse the same connector to multiple Logic Apps - define one and reuses as much as possible.

8. CI/CD and Deployment
Initially, the integration of Logic Apps with Azure DevOps and ARM was not the best - or better say it was almost none. A lot of things changed from then, and now both services are well integrated inside Azure DevOps. The automation and deployment part can be done using ARM template.
The most notable difference between them is the support of slots that it is available only for Azure Functions. This allows us to do fast switches between different versions of our functions. Even so, if you put an API Management in front of Logic Apps or use parallel instances of Logic Apps for different versions, you might not feel the lack of slots.

9. Cloud / On-premises environment
The current runtime of Logic Apps can be run only from Azure. You can use a dedicated environment inside App Services, but you cannot run them on-premises. This might change in the future, but for now, you are restricted to run them only from Azure.
Azure Functions are different from this perspective. The runtime supports different environments including Azure Stack. A more exotic location where you can run them is Windows Containers, where you would need an SQL Server for storage. This enables us to design a serverless solution that could run inside other cloud providers, like AWS or Google Cloud.

10. Maintenance
When you need to monitor Azure Functions, your first option is Application Insights from where you can fully monitor your functions (latency, status, errors and many more). There is also a dedicated tab inside the portal where you can find metrics about your functions and excellent integration with logging mechanism.
The Logic Apps provide us with historical information of previous runs from the same dashboard from where we define the workflows. This is super useful for business people that don't have technical knowledge. Each action from the workflow provides information related to what was the input, output and execution status. There is no integration with Application Insights, but it is well integrated with Azure Operation Mangement Suite (OMS).

Comparison
The below tables compare both services from 6 different perspectives. 
Perspective
Logic App
Azure Functions
Monitoring
Azure Portal / OMS
Azure Portal / Application Insights
Development
Declarative
Imperative (code-first)
Execution
Collections of actions
Separate actions that can call each other
Integration
High no. of connectors (including on-premises)
Basic bindings and extensibility using HTTP
Control
Azure Portal / PowerShell / VS / REST API
Azure Portal / REST API / Visual Studio
Running environment
Azure only
Azure / locally / other clouds

Final conclusion
Logic apps are suited when you develop integration solutions (strong connectors) that reduce the time to market and has a rich visual tool that can be used to build and manage the workflows. Suitable for business process automation where reliable processing is mandatory.  
Azure Functions together with Durable Functions are more flexible and the technical team has full control and power. They are more powerful and portable. Can be used with success for complex logic when you have more than a few IFs conditions.   

Azure Functions:
  • Code triggered by an event
  • Runs on different environments, including local workstations
  • Synchronous request/response calls
  • Complex logic
Logic Apps are:
  • Workflows triggered by an event
  • Runs only in code
  • Asynchronous integration
  • Fire and forget where reliable processing is mandatory 
  • Business process automation
  • Well integrated with on-premises systems 


























Comments

Popular posts from this blog

Windows Docker Containers can make WIN32 API calls, use COM and ASP.NET WebForms

After the last post , I received two interesting questions related to Docker and Windows. People were interested if we do Win32 API calls from a Docker container and if there is support for COM. WIN32 Support To test calls to WIN32 API, let’s try to populate SYSTEM_INFO class. [StructLayout(LayoutKind.Sequential)] public struct SYSTEM_INFO { public uint dwOemId; public uint dwPageSize; public uint lpMinimumApplicationAddress; public uint lpMaximumApplicationAddress; public uint dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public uint dwProcessorLevel; public uint dwProcessorRevision; } ... [DllImport("kernel32")] static extern void GetSystemInfo(ref SYSTEM_INFO pSI); ... SYSTEM_INFO pSI = new SYSTEM_INFO(

Azure AD and AWS Cognito side-by-side

In the last few weeks, I was involved in multiple opportunities on Microsoft Azure and Amazon, where we had to analyse AWS Cognito, Azure AD and other solutions that are available on the market. I decided to consolidate in one post all features and differences that I identified for both of them that we should need to take into account. Take into account that Azure AD is an identity and access management services well integrated with Microsoft stack. In comparison, AWS Cognito is just a user sign-up, sign-in and access control and nothing more. The focus is not on the main features, is more on small things that can make a difference when you want to decide where we want to store and manage our users.  This information might be useful in the future when we need to decide where we want to keep and manage our users.  Feature Azure AD (B2C, B2C) AWS Cognito Access token lifetime Default 1h – the value is configurable 1h – cannot be modified

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine: threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration: TeamCity .NET 4.51 EF 6.0.2 VS2013 It see