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:

Consumption Plan

functions_colorWith 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

appservice_colorWith 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.

Posted by Chris Pietschmann

Chris is a Microsoft MVP and has 15+ years of experience building enterprise systems both in the cloud and on-premises. He is also a Microsoft Certified (MCSD) Azure Solutions Architect. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.

10 Comments

  1. […] How Azure Functions Pricing Works (Chris Pietschmann) […]

    Like

    Reply

  2. […] How Azure Functions Pricing Works and Manage Azure App Service Deployments with Deployment Slots (Chris Pietschmann) […]

    Like

    Reply

  3. […] How Azure Functions Pricing Works by Chris Pietschmann […]

    Like

    Reply

  4. […] service offering in the Microsoft Azure cloud platform is the Azure Functions service. Azure Functions allow for Serverless architecture to be built out on the Microsoft Azure platform. It also supports many different platforms and frameworks, like .NET, Java, Python, and Node.js. […]

    Like

    Reply

  5. I updated the article to reflect “Consumption Plan” naming instead of the older “Dynamic” since it’s been since changed after Azure Functions have gone GA.

    Like

    Reply

  6. Hi Chris, I have a question as we are moving some of our functions to production. We have a scenario where we need a single global point of entry. For our app servers running > S plans we leverage GTMs (nested GTMs) so that it can route directly to the app service / function based on geographic metric.

    Naturally we are also wanting to benefit from the consumption model. Are there plans or do you know of a way to leverage GTMs to route between two functions in different regions performing the same task?

    Like

    Reply

    1. I assume you’re calling the Azure Functions with a Webhook or HTTP endpoint. With this you should be able to configure Azure Traffic Manager with the Azure Functions endpoints and then load balance across them just fine.

      Like

      Reply

      1. Yes, we are using standard http (s) endpoint. However when the app service is running under the consumption plan it doesn’t appear in the options under the traffic manager.

        Unless of course I am missing something?

        Like

      2. Oh I see what you mean. You could get around that by setting up Traffic Manager by configuring an External Endpoint and entering the HTTP URL in. Traffic Manager can be used with HTTP endpoints that are not hosted in Azure.

        Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s