Serverless computing is a growing trend in cloud computing, and it’s a natural next step in the Platform as a Service (PaaS) area. First PaaS allowed applications to be hosted without requiring Virtual Machines to manage, then serverless computing further removes the construct of a server. Azure Functions is the service within the Microsoft Azure cloud that offers serverless hosting and execution of application code. With serverless architecture removing the construct of a server from the equation of application hosting the concept of pricing begins to get a little fuzzy. This articles explains how Azure Functions pricing works.
Azure Functions is available with the 2 following pricing methods:
With Consumption Plan hosting, Azure Functions completely abstracts away the server construct. You no longer pay for reserving CPU Cores and RAM of the underlying Virtual Machine (VM). You only pay for the time your code runs, and not for the time it remains idle.
When provisioning Azure Functions in Microsoft Azure, the Hosting Plan option of Consumption Plan will configure the use of the Consumption Plan. Rather than specifying the CPU Cores and RAM of the underlying VM, the Consumption Plan specifies the Memory Allocation to reserve for the Azure Functions service while it is running.
The options for Memory Allocation range from 128 MB on the bottom all the way up to a maximum of 1.5 GB of memory.
You only pay when the Azure Function is run.
When Azure Functions execute the scalability of the application code is handled automatically behind the scenes by the service without the need to configure any Autoscaling or even manually scaling the App Service Instance like would be needed if the same code were hosted in an Azure App Service WebJob.
Further details on the specifics of Azure Functions pricing can be found on the official Azure Functions pricing page.
App Service Plan
With App Service Plan hosting, Azure Functions runs on top of an Azure App Service Plan. With this method the Platform as a Service (PaaS) Virtual Machine (VM) under the covers remains reserved. The CPU Cores and RAM of the VM still need to be specified as they are reserved for the instance size the same as with any other Azure App Service; such as Azure Web Apps or API Apps.
When provisioning Azure Functions in Microsoft Azure, the Hosting Plan option of App Service Plan will configure the use of an App Service Plan for hosting the Azure Functions. The underlying Virtual Machine (VM) will be reserved just like any other Azure App Service Plan service (Web Apps, API Apps, and Mobile Apps).
Azure Functions can run in an App Service Plan of another resource without incurring additional compute costs.
The App Service Plan hosting plan option for Azure Functions exists for the purpose of hosting Azure Functions along-side other App Service resources running in an App Service Plan. While it may not be practical to host Azure Functions in a VM Instance in an App Service Plan if that’s the only resource being hosted, since it would cost much more than if Consumption Plan were used instead.
By using App Service Plan hosting plan, the Azure Functions can run within an App Service VM Instance, thus allowing for even further cost savings by utilizing over provisioned resources of an existing App Service Plan VM Instance. In other words, if the Azure Web App being hosted doesn’t exactly need all the CPU Cores and RAM allocated to it, then hosting Azure Functions here will utilize what’s already being paid for without incurring additional computer costs.
Further details on the specifics of Azure App Service pricing can be found on the official Azure App Service pricing page.