In this blog, we will take a high-level look at what Azure Functions are, why they might be a good choice for you, a couple of ways to make them and a brief overview of cost. As with all Introduction pieces, we won’t cover code but I will post a ‘Demo’ piece shortly.
What are Azure Functions?
First off, a nice simple introduction to the concept. Azure Functions are blocks of code that run on your Azure Environment in order to fulfil a single purpose. They run as a ‘Function as a Service’ (FaaS), which is very different to ‘Platform as a Service’ (PaaS), as it removes the need to build your environment entirely. They are triggered by events and can be grouped together in serverless workflows called Logic Apps to fulfil a complete business need.
Examples of possible use could be
- resize an image on upload
- categorise or score an input
- transform data for a 3rd party system
Why use Azure Functions?
Azure Functions are serverless, which does not mean they don’t use a server. What it means is that the developer simply provides the code and some logic via an Azure interface which speeds up your development massively and then Azure will take control of the infrastructure provided in order to fulfil the request. This means Azure will handle all kinds of complex work in order to scale your code automatically to ensure it will always run and has the benefit of only charging you for what you actually need.
- Focus on code, not infrastructure
- Automatic scaling to meet demand
- Usage-based billing to control cost
How do you use Azure Functions?
Azure Functions are triggered by an event of some kind. There are a few different events, like on receiving a message in a queue, on a timer (such as midnight), database events or from Http Requests which for me is the most powerful use as it allows us to interact with our existing web applications using serverless functionality.
You can build them directly from the Azure Portal, which is great for doing small-scale tests, modifications and learning how it all ties together.
Visual Studio 2017 supports the development of the Azure Functions, which is a great choice for developing business critical applications as It gives you all the control of debugging and testing tools you’re probably already familiar with
Finally, there is the Azure Functions Core Tools Command Line Interface which is cross-platform and free for those working outside of Windows.
How much does Azure Functions Cost?
According to the Azure website, the consumption plan is billed per second for resource consumption and executions. At the time of writing this in September 2018, it includes a free monthly grant of 1 million requests and 400,000 GBs of resource consumption per month. It is worth noting though, that this grant only covers the functions themselves and anything associated with it, like storage and networking, are still charged separately.
You can also tie it into an App Service Plan which is great if you already host your website within Azure as well as within a Docker container pretty much anywhere.
Either way, for home development or small-scale projects, the grant on the consumption plan will cover the bulk of standard execution requests, so it’s a great way to learn for free so let’s move on to a demo!
Azure Functions: Demo 1 – A scaffolded example