At Enable, we use Microsoft Azure to host our applications. We make sure to utilize the wide variety of resources that Microsoft Azure has to offer so that we can continue to improve the quality and performance of our applications. To provide and maintain the standard of our products, we require our solutions to automate and integrate seamlessly with each other, and one of the ways we achieve this is by using Azure Functions.
Azure Functions is a serverless computing service, also known as Function-as-a-Service, that is hosted on Microsoft Azure public cloud. It is an event driven programming model where each function runs in response to an event happening, called a *trigger*. In addition to triggers, they also support *bindings*, which are ways to simplify solutions for data input and output.One of the common examples of using Azure Functions is for executing tasks at a predefined time, such as a database clean-up task or other batch tasks. Scheduled jobs would likely use a TimerTrigger that leverages CRON expressions to define the timer information. A simple Azure Function for a clean-up job in C# may look like this:
There are many other ways to trigger an Azure Function including HTTP triggers, changes in Azure Queues, messages from Service Bus, changes in Azure Storage Blob containers and many more. These Azure resources have been widely used across our solutions, which makes it seamless for us to adopt Azure Functions across our applications, allowing us to simplify integration between our solutions in order to assist our customer's business needs. HTTP triggers also allow Functions to react to HTTP requests from virtually any SaaS product that supports Web Hooks.
Function bindings are used to access, process and persist data. Data sources and services can simply be connected to an Azure Function, which would then allow the function to access the data from those services and process it according to the required business logic. An example of a function triggered by a queue may be to save the messages in the queue to a Blob container, and might look like this:
Since Azure Functions are a serverless computing service, they can be written and executed without needing to manage any web servers or containers. This allows small pieces of code to be run without worrying about the underlying infrastructure or platform required to execute it. With Azure Functions, we can simply create and upload the code with the events defined that will trigger the function to run. Further, the Functions Runtime is portable, meaning that they can be built and deployed on any public cloud or internal network and they can execute in Azure, a data centre or any other clouds.
Azure Functions can be developed in a variety of programming languages including C#, JavaScript, Python, and PHP, among others. This gives the engineering team the freedom to write an Azure Function in their choice of language, depending on whichever best fits the task at hand. What’s more is that Azure Functions also supports the Node and NuGet open source package manager for JavaScript, allowing engineers to utilise well-established libraries in their functions.Azure Functions has helped to simplify many solutions to complex business requirements. One of those requirements is ensuring that integration between solutions operates smoothly. Function bindings have made it simpler for engineers to achieve this by allowing connections between data sources, services or messaging solutions to be established easily, without worrying about the flow of data and how the services are implemented. This is beneficial for scalability as engineers can use different services and still achieve the same result. Using these triggers and input or output bindings, engineers can react to any data retrieved from other services and process this data, as well as persisting the processed data in storage within the same function.
An advantage of Azure Functions is that it has native support for scaling out - if a function is under heavy usage, Azure will automatically provision additional instances to handle the load. Costs for Azure functions are based primarily on usage; it is determined by calculating the amount of time the function runs within a particular billing cycle. This allows the freedom to scale up or down as necessary, without incurring any additional costs.However, this also means that the costs can increase indefinitely if the function is under very heavy usage. To prevent this from occurring, we can configure a limit on the function itself such as a daily quota to limit the maximum consumption, and hence the maximum cost. This will allow us to maintain the high performance of our solutions while minimizing the running costs.There are some functions where we do not want to scale out. For example, having multiple instances of a function that queries a SQL database may run the risk of overloading or deadlocks. Enable has prevented this by introducing another custom limiting factor to our Azure functions to prevent it from overwhelming other resources under heavy load.
Azure Functions has simplified the process of application development through its serverless, scalable and portable features whilst maintaining the quality and performance of applications. At Enable, we thrive on continuing to make our applications operate and integrate as seamlessly as possible. With the implementation of Azure Functions and other Microsoft Azure resources on top of the exceptional skills of our team, we have been able to continuously deliver high quality solutions to all business requirements, no matter how complex.
Resources
https://azure.microsoft.com/en-gb/blog/introducing-azure-functions
https://azure.microsoft.com/en-gb/services/functions