Azure Functions Pricing

Understand the cost of running your serverless applications on Azure Functions.

Azure Functions Pricing Model

Azure Functions uses a consumption-based pricing model, meaning you only pay for the resources your code consumes. This model is designed to be cost-effective for event-driven and scalable applications. There are two main components to Azure Functions pricing:

1. Executions

Each time your function runs in response to an event, it counts as an execution. The first 1 million executions per month are free.

Pricing after free tier: $0.20 per 1 million executions.

Example: If your function runs 1.5 million times in a month, you will be charged for 0.5 million executions.

2. Compute Resources (GB-seconds)

This metric measures the amount of memory and the duration your function runs. It is calculated as:

GB-seconds = (Memory allocated in GB) x (Execution time in seconds)

The first 400,000 GB-seconds of compute resources are free each month.

Pricing after free tier: $0.000016 per GB-second.

Example: A function that uses 512 MB (0.5 GB) of memory and runs for 10 seconds consumes 0.5 GB * 10 s = 5 GB-seconds.

Pricing Tiers & Details

Azure Functions offers different hosting plans that affect pricing and features:

Consumption Plan

This is the default and most common plan. It offers automatic scaling and a pay-as-you-go model, making it ideal for workloads with variable traffic or unpredictable execution patterns. The free grants mentioned above apply directly to this plan.

Key Benefits of Consumption Plan:

  • Pay only for what you use.
  • Automatic scaling.
  • Ideal for event-driven scenarios.

Premium Plan

The Premium plan offers pre-warmed instances, VNet connectivity, and no cold starts. It's suitable for production workloads that require consistent performance and low latency. Pricing is based on reserved compute instances, with charges for both the pre-warmed instances and any additional scaling instances.

Pricing for the Premium plan is based on instance size and duration, and you are charged for the provisioned instances regardless of execution. A free grant is not typically associated with this plan in the same way as the Consumption plan.

App Service Plan

You can also run Azure Functions on an App Service plan. In this model, you pay for the underlying App Service plan, which provides dedicated resources. Functions running on an App Service plan do not incur separate execution or GB-second charges; they are included as part of the App Service plan's cost.

Free Tier Explained

Every Azure subscription comes with a generous free tier for Azure Functions on the Consumption plan. This includes:

These free grants reset at the beginning of each month. If you exceed these limits, you will be charged at the standard rates listed above.

Example Cost Calculation (Consumption Plan)

Let's assume a function runs 5 million times in a month, using 256 MB (0.25 GB) of memory and averaging 5 seconds per execution.

Metric Details Calculated Cost
Executions 5,000,000 total executions (5,000,000 - 1,000,000 free) executions = 4,000,000 charged executions.
4,000,000 executions / 1,000,000 = 4 units.
4 units * $0.20/unit = $0.80
Compute Resources (GB-seconds) Average execution: 0.25 GB * 5 seconds = 1.25 GB-seconds.
Total compute: 5,000,000 executions * 1.25 GB-seconds/execution = 6,250,000 GB-seconds.
(6,250,000 - 400,000 free) GB-seconds = 5,850,000 GB-seconds charged.
5,850,000 GB-seconds * $0.000016/GB-second = $93.60
Total Estimated Cost $94.40

Important Notes:

  • These prices are estimates and may vary based on region and any applicable discounts.
  • Other Azure services that your Functions might interact with (e.g., Storage, Cosmos DB, Service Bus) will have their own associated costs.
  • Always refer to the official Azure Functions pricing page for the most up-to-date information.

Optimizing Costs

To keep your Azure Functions costs manageable: