Why this matters
Serverless bills feel cheap until something loops. On Azure, Functions on the Consumption plan charge for executions and for memory multiplied by run time. A function that retries a failing call, or one that triggers itself through a queue or storage write, can run millions of times overnight. Nobody sees it until the invoice shows up.
The cost is also spread across services you might not think of as part of the function. Storage transactions, Application Insights ingestion, Service Bus operations, Event Hubs throughput units and outbound data all grow with execution count. The function itself is often the smallest line.
Predictable doesn't mean cheapest. It means you can say what next month will cost within a reasonable range, and you'll get an alert before a bug becomes a surprise. That's mostly about limits, scaling caps and visibility, not about rewriting code.
Before you start
List every serverless resource first. In the Azure portal, filter your subscription by type for Function apps, Logic Apps, Event Grid topics, Service Bus namespaces and Event Hubs. Note which hosting plan each Function app uses: Consumption, Flex Consumption, Premium or a dedicated App Service plan. The plan decides which controls you have.
Check that resources are tagged with an owner and an environment. Without that, Cost Management can tell you something is expensive but not who should fix it. Group by resource group at minimum if tags are missing.
You'll need Cost Management Reader on the subscription to view spend, and Contributor on the apps to change scaling and logging settings. If one person holds only one of those, loop in the other now, because the steps below move between both.
How to do it
Work from the biggest risk down. Start with caps on scaling, then fix the supporting services that quietly add up, then put guardrails around spend itself. The numbered steps below follow that order.
Expect to make small changes in many places, not one big change. Most of the savings come from stopping waste in the supporting services and from making scale-out finite. Do these on a non-production app first so you can see what each setting does before you apply it to anything customer-facing.
- Inventory every serverless resource. List Function apps, Logic Apps, Event Grid, Service Bus and Event Hubs across your subscriptions. Record the hosting plan and the owner for each. Anything with no owner gets one before you continue.
- Cap scale-out on each Function app. On the Consumption plan, set the WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT app setting. On Flex Consumption, set the maximum instance count. Pick a number based on what a downstream database or API can handle, not the platform maximum.
- Limit concurrency per instance. Tune batch size and maxConcurrentCalls in host.json for queue and Service Bus triggers. Lower concurrency keeps a backlog from fanning out into a huge number of parallel runs and overwhelming whatever sits behind the function.
- Set retry and dead-letter limits. Configure a maximum delivery count on Service Bus queues and a retry policy with a fixed number of attempts on triggers that support one. Send failures to a dead-letter queue. This stops a single bad message from running forever.
- Tame Application Insights ingestion. Enable sampling in host.json and lower the log level for noisy categories. Set a daily cap on the Log Analytics workspace. Telemetry is a separate meter from compute and often the surprise line.
- Review Logic Apps pricing mode. Check whether each Logic App is Consumption or Standard. Consumption bills per action run, so loops and polling triggers add up fast. Lengthen polling intervals and trim actions inside loops.
- Create budgets and anomaly alerts. In Cost Management, create a budget scoped to your serverless resource groups with alerts at several thresholds. Turn on cost anomaly alerts for the subscription. Send them to a shared mailbox, not one person.
- Tag and review weekly. Apply owner and environment tags, then add a short weekly look at cost analysis grouped by tag. Catching a trend in days is far cheaper than catching it at invoice time.
How to check it worked
Give it a full week of normal traffic, then compare. In Cost Management, use cost analysis grouped by resource, filtered to your serverless resource groups. Look at the daily view, not the monthly total. A flat or gently rising line with no spikes is what you want. A spike that matches a deploy date points to the cause.
In Application Insights, check the Live Metrics and Performance blades for function execution counts and duration. Executions per minute should track real demand, such as orders or messages, and not climb while demand is flat. Compare the sampled telemetry volume to what you ingested before the sampling change.
Trigger the safety nets on purpose in a test app. Send a burst of messages and confirm scale-out stops at your maximum instance count. Push a deliberately failing message and confirm it lands in the dead-letter queue after the set number of attempts instead of retrying forever. Fire a test of your budget alert and confirm it reaches a real inbox someone reads.
Mistakes to avoid
Don't treat the free grant as a plan. The monthly free allowance on Consumption is fine for light use, but it tells you nothing about what a retry storm costs. Build limits as if the free grant isn't there.
Don't leave verbose logging on in production. Application Insights charges by data ingested, and a chatty function logging every payload can cost more than the compute it runs on. Log errors and key events, sample the rest, and set a daily cap on the workspace.
Don't forget the triggers that write back to where they read from. A blob trigger that writes its output to the same container, or a queue function that re-enqueues on every failure, is the classic runaway. Review any function whose output could fire its own input.
Don't move to Premium just to get control without checking the math. Premium gives you always-ready instances and predictable cold starts, but you pay for those instances whether or not they're busy. It suits steady traffic. For spiky, low-volume work, a capped Consumption or Flex Consumption app is usually the better fit.
If your serverless spend is mixed in with a bigger Azure bill and you can't tell where it's going, an outside review can help. Cloudverg offers a Cloud cost audit at $4,500/month (fixed scope, two weeks, renews monthly until cancelled), which is a read-only review of up to three subscriptions with a ranked savings report. It's one option next to doing the review yourself with Cost Management and Azure Advisor.
Frequently asked questions
Is the Azure Functions Consumption plan always the cheapest option?
No. It's often cheapest for spiky or low-volume work because you pay only when code runs. For steady, high-volume traffic, Premium or a dedicated plan can cost less per run and give steadier performance. Compare your real execution pattern against each plan before switching.
How do I stop an Azure Function from scaling out too far?
Set a maximum scale-out limit. On Consumption, use the WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT setting. On Flex Consumption, set the maximum instance count. Choose a ceiling your downstream systems can actually handle.
Why is my Application Insights bill higher than my function compute cost?
Application Insights charges by data ingested, and verbose logging in a busy function can produce a lot of it. Turn on sampling, raise the log level for chatty categories and set a daily cap on the workspace. Then check ingestion volume again after a week.