Microsoft Azure Functions
What are Azure Functions?
Azure Functions are “serverless” solution for running small applications in the cloud. This Microsoft Azure service allows you to run small pieces of code in Node.js, C#, Python, PHP and Java without any infrastructure configurations. The whole principle of Azure Functions is that you write code in the language you prefer, publish the code to the cloud, run it and just pay for what you use while the function is executed. Azure functions can be manually scheduled or triggered by other Azure Services.
- scheduled or trigger by events
- write code in different programming languages
- pay per function execution
- parallel execution when multiple triggers occur
- support for continuous integration and deployment
- integration with other Azure and third-party services (e.g Blob, Azure Data Factory, Twillio etc.)
- can run Azure Functions on Kubernetes clusters
- integration with Azure Application Insights for monitoring
- Azure Functions now supported as step in Azure Data Factory
What are Durable Functions?
Durable functions are extension of Azure Function that allows you to develop stateful functions in a serverless environment. In case of growing application, you will have small logical pieces of code in different functions that you would like to integrate together and specify the order in which they need to run. For this, you need Durable Functions because you will need to orchestrate the functions run.
You can use Durable Functions in the following scenarios:
- Need to chain functions together
- Need to execute functions in parallel
- Query status of long-running processes
- Need human interaction with the functions
When to use Azure Functions?
- For smaller tasks that should be run on a schedule
- Building APIs
- Building microservices
- Real-time stream processing
- Event processing
- Data processing
Concepts in Azure Functions
- Function code is the code that Azure Function will run on the cloud. The code is written in a programming language of the user’s choice and is stored in a same folder with a JSON config file
- Function app is a collection of more functions that are managed together
- Function runtime is the part of the solution that actually runs your code, listens to events that are set as triggers for the function, sends and ingest data to/from various data sources
- scales automatically based on the number of incoming events
- charged only when functions are being executed, don’t pay for idle VMs
- each instance of the Functions is limited to 1.5 GB of memory
- default timeout for functions execution is 5 min, but can be increased to 10 min
Azure App Service plan
- functions run on dedicated VMs
- function can run continuously
- can use more CPU and memory if needed compared to the consumption plan
Azure Functions vs Azure Logic Apps
- Azure Functions is code triggered and Azure Logic Apps is workflow triggered by event
- With Azure Functions the actions are written in code allowing for more flexibility and building more complex solutions, actions in Azure Logic Apps are pre-defined which can sometimes be a limitation
- Azure Functions can be tested locally or in cloud, Azure Logic Apps can run only on the cloud
- In Azure Functions the development is through code mostly, for Logic Apps this mostly drag-and-drop through the UI
element61 has worked with Azure Functions on many occasions either to just create an API which when called is triggering a script, making predictions on real-time coming data, as a connector between different Azure services etc. We have the knowledge to choose in which cases a serverless service like this can be of a great benefit for the client, and to quickly build a solution without building a whole infrastructure.
Azure Functions and Durable Functions as their extension are a great way to run pieces of code written in different languages in the cloud without the need to deal with any infrastructure setup.
More information is available at the Microsoft website.
Contact us for more information on Azure Functions!