Try RevDeBug in action for free. Jump into our interactive demo >

Azure Functions: Overview and Common Use Cases


By RevDeBug

Azure Functions was designed as serverless architecture that allows the application development process to be quick, painless and less costly. 

Traditionally, application development required complex IT infrastructure which made for a slightly complicated, expensive and time-consuming affair.

In this article, we’re going to explain what Azure Functions is, how it works and what you canand cannotuse it for.

What is Azure Functions?

Azure Functions (from Microsoft Azure) is a cloud-based serverless service that allows running event-triggered code in a scalable way without providing or managing infrastructure. It enables the capability to run a script or piece of code in response to a variety of events and doesn’t need to run continuously.

They can be written in several languages, including C#, F#, Java, JavaScript, Python, TypeScript, and even PowerShell. They’re also scalable, and when the demand for code execution increases, the necessary resources are automatically allocated for the request. Any leftover resources that responded to the server requests are also automatically disposed of.

For example, let’s say you’re a web developer. You want to send out emails or notifications to customers after specific steps, for instance Packed or Sent for delivery, are completed in an ecommerce order. Instead of building an entire system with your own infrastructure, you can simply use Azure Functions.

All you need to do is just write your code for the specified actions and deploy it to Azure cloud. Azure Functions will run only when triggered by your ecommerce system, automatically scaling to current needs, for instance on a Black Friday. You will be charged for the number of invocations and the time of their execution only. That means you only pay when you process your orders. On top of that, you don’t need to anticipate the traffic that could be generated by the next promotion and pay for servers that won’t be used in their whole capacity most of the time.

Some of the most common use cases include sending emails, starting a backup, file processing, report generating, order processing, and scheduling tasks such as notifications, messages, database cleanup, and IoT data processing. But, we’ll get to that later.

Generally speaking, Azure Functions is better suited for the parts of your app that can be executed as separate processes, often run multiple times in parallel, and are triggered by specific events that could require rapid scaling from time to time.

When should you use Azure Functions?

Azure Functions is a lightweight serverless service. It has its own specific uses, and you can’t just replace an entire website simply by using it. 

The most common use cases of Azure Functions include:

  • Reminders and notifications
  • Scheduled tasks and messages
  • File processing
  • Data or data streams processing
  • Running background backup tasks
  • Computing backend calculations
  • Lightweight Web APIs, proofs of concept, MVPs

Importantly, not all applications can or should use Azure Functions as it’s a service that uses triggers. Once an event has been triggered, the task is executed in the background.

It’s worth keeping in mind that Azure Functions is not a replacement for Web APIs. Web applications tend to use Web APIs as the middleman to bunch together data and business logic tasks, while Azure Functions receives input, runs its logic and provides output. Nevertheless, it could be a great extension for Web APIs for specific use cases.

Importantly, Azure Functions is not designed to carry out multiple tasks. The service was created to perform one or very few tasks as fast as possible. 

Azure Functions is not recommended for infrequent, time-sensitive or long and computationally intensive tasks. Since Azure Functions is a compute-on-demand service, attempting to replace any APIs with multiple Azure functions could result in severely increased costs in terms of development, maintenance and computations.

To sum up, Azure Functions was designed to accelerate the application development process. With serverless architecture, you can quit worrying about the infrastructure challenges and focus on creating code but, of course, bearing in mind its costs and limitations.

If you’d like to find out how to start using Azure Functions and set up comprehensive monitoring, watch the video below in which our colleagues explain the basics. 

Related to this