Why and When to use Azure Functions
Azure functions and lambda functions are two new serverless technologies that are growing faster than anything else in the cloud development. You can see more and more azure functions applications are being developed every day and there is a fair reason for that. If you are new to Azure functions, I highly recommend reading What is Azure functions.

When architecting a new cloud software or applications, one of the key decisions architects and developers must make is a way to connect to the backend services, running backend tasks, and background processing, and even some simple tasks such as scheduling and sending emails without affecting the main application processing. This is where azure functions app can come handy and useful.
This article focuses on deciding when and why you should use Azure functions instead of Web API and other services.
Before we start with when and why Azure functions, let us try to understand key characteristics of Azure functions.
- Azure functions are language independent. Azure functions is a piece of code that is written to do a specific tasks. Azure functions is platform and language agnostic. You can write an Azure functions in one of the popular programming languages including C#, Java, JavaScript, TypeScript, and Python. You can deploy and execute Azure functions on any platform that can run .NET Core.
- Azure functions are scalable. Azure functions uses compute-on-demand, which is scalable by design. When demand of execution increases, more resources are allocated automatically to the service and when requests fall, all extra resources and application instances drop off automatically.
- Azure functions are lightweight and serverless. An Azure functions app is designed to a specific task and hence it is lightweight by design. Azure functions are serverless and do not require any Web servers or virtual machines to deploy and run.
- Azure functions are platform agnostic and run in their own process and environment. You can deploy Azure functions in any kind of configurations including Linux, Windows, or containers but Azure functions are available and can be consumed from any applications as long as they have access to the function.
- Azure functions are easier to write and deploy. Because of the nature of the Azure functions, they are easy to code, test, debug, and deploy. You don’t need a large team of developers to do that. A single developer can do everything.
- Azure functions are fast to execute because there is no large application, startup time, initialization, and other events fired before the code is executed.
- Azure functions’ execution is triggered when an event is fired. Azure functions setup provides dozens of triggers that can be configured when an azure functions is executed.
- Azure function can be built, tested, and deployed in Azure portal using a browser.
- Azure functions are independent. Azure functions are easy to upgrade and doesn’t affect other parts of a website or other applications.
- Azure functions use industry standard and can communicate with other APIs, databases, and libraries. This makes Azure functions more accessible in cloud native applications.
- Azure functions can be cost effective because if their nature of running on demand.

Eranda NandaseanaPosted Jul 18, 2022, 6:59 AM
As my understanding and experience, Azure function is a perfectly a good solution to build web API and backend API. Event-Driven application might be the ideal candidate for the FaS compute runtime BUT not ONLY candidate application type.1. With the introduction of the Azure function Isolated process, you could get almost all the features available in the dotnet Core we app if you are into DotNet and C# - 2. Azure function is a Microsoft offering of the Serverless Computing model, AWS do have Lamda, I’m trying to point out the serverless is more general computing model for future of the Cloud computing, So we can consider example from the AWS as well. Writing web API on AWS also well supported, Look the Chalice web framework build by AWS specially for lambda https://github.com/aws/chalicehttps://youtu.be/gEiULhbHKQI?t=1215 -- https://docs.microsoft.com/en-us/azure/architecture/reference-architectures/serverless/web-app 3. Azure function and lambda is perfect runtime to build microservices that truly communicate asynchronously each other. Checkout out Azure functions Durable frameworks and AWS step functions to spawn workload from HTTP to background orchestrations 4. Implementing API with Azure functions and Lambda doesn’t necessarily require you to write one function per every API call. It’s depends on the framework you use to implement web API on serverless environment. 5. Cost is mostly depend on hosting model. For instance, consumption-based pricing cost only for your API consumption. So implementing you API as one function app or implementing the same API as 10 function app doesn’t have any significant cost differences.
Amir HajihaPosted Jan 2, 2022, 11:42 PM
Is Azure Function a good candidate for having microservice pattern or do you still recommend Web APIs?
Hamid KhanPosted Feb 26, 2021, 8:06 PM
Very very useful article.............
Steve MontgomeryPosted Feb 24, 2021, 7:56 AM
Thanks, why are Azure Functions not a replacement for WebAPI? Can they not fulfil the same role? For example why not build a complex command domain api using Azure Functions and API manager to be consumed by a front end CDN? With CQRS I see the advantage or running queries through functions, but am unsure if the Command side architecture should be Azure Functions or WebAPI.The limitations I see are not being able to easily use a third party IoC container for more advanced dependency injection and not having access to HttpContextAccessor to be able to inject user authorisation permissions into a domain layer.