Compare App Service and Azure Functions
Choose between App Service and Functions by plan, trigger, slots, cold starts and runtime limits.
By Invicly Tech, , in Microsoft Azure Cloud Engineering. About 12 minutes to read.
In short
Azure App Service runs web apps and APIs on managed servers: you deploy code or a container, and Azure handles the OS, runtime patches and load balancing. Azure Functions runs small pieces of code in response to triggers such as HTTP requests, queue messages or timers, and can scale to zero. The hosting plan you choose decides price, scaling, cold starts, deployment slots and how long code may run.
Think of it like this: App Service is a shop that stays open all day; Functions is a taxi rank where cars appear when passengers arrive.
Explained simply
Azure App Service runs your website or API without you looking after servers. You upload code, or a container image, and Azure keeps the operating system and language runtime patched, spreads traffic across instances and gives you an HTTPS address. You pay for an App Service plan, which is a set of servers of a chosen tier, whether or not anyone visits.
Azure Functions is for small pieces of code that run when something happens. That something is the trigger: a web request, a new message on a queue, a file landing in Blob Storage or a timer. On the serverless plans, Azure adds instances as events arrive and can drop to zero when nothing is happening, so you pay mostly for real use.
Scaling to zero has a cost: the first request after a quiet spell may wait while a new instance starts. That wait is called a cold start. You can reduce it by keeping some instances warm, which costs money, or by using an always-on plan.
App Service has a handy release feature called deployment slots. A slot is a second live copy of your app, such as staging, with its own address. You deploy there, test it, then swap it with production. Azure warms the new version first, so users do not see downtime, and you can swap back if something breaks.
Cost note: App Service has a Free tier for experiments, but slots and autoscale need Standard or higher. Functions on Flex Consumption include a monthly free grant. For a no-cost option, run Functions locally with Azure Functions Core Tools and the Azurite storage emulator.
Press Play on a diagram to walk through it one step at a time.
- Always-running web app or API
- Pay for the plan, even when idle
- Deployment slots from Standard tier up
- No cold start with Always On
- Good for steady HTTP traffic
- Code runs per trigger: HTTP, queue, timer, blob
- Flex Consumption bills per use and scales to zero
- Bindings read and write other services
- Cold starts possible when scaled to zero
- Good for bursty, event-driven work
- Flex Consumption
- Recommended serverless plan
- Linux only
- Always-ready instances optional
- No deployment slots
- Premium
- Prewarmed instances
- VNet integration
- 3 slots per app
- Dedicated (App Service plan)
- Shares a web app plan
- Predictable price
- Needs Always On
- Container Apps
- Functions in your own image
- Consumption (legacy)
- 5 min default, 10 min max timeout
- Step 1Always-on web app or API?
Yes: App Service plan, Standard or above for slots.
- Step 2Event-driven and bursty?
Yes: Functions on Flex Consumption.
- Step 3Needs zero cold start?
Add always-ready instances or use Premium.
- Step 4Runs longer than 230 s per request?
Queue it or use Durable Functions.
In depth
App Service plans and what each tier unlocks
An App Service plan defines the region, operating system, tier and number of instances. All apps in a plan share those instances, so a busy app can slow its neighbours. Tiers go from Free and Shared, which run on shared machines with daily CPU quotas, to Basic, Standard, Premium v3 and Isolated v2.
Features arrive with tiers. TLS bindings for custom domains start at Basic. Deployment slots and rule-based autoscale start at Standard. Premium adds more slots, bigger and faster instances, and automatic scaling based on HTTP load. Isolated v2 runs in an App Service Environment inside your own virtual network. Always On, which stops the app from being unloaded when idle, is not available on Free or Shared. Check the current pricing page for exact quotas, because they change between tier generations.
- Free and Shared: experiments only
- Basic: dedicated instances, manual scale
- Standard: slots and autoscale
- Premium v3: more slots, faster hardware
- Isolated v2: single-tenant in your VNet
Functions hosting plans and runtime limits
The hosting plan decides how a function app scales and how long code may run. Flex Consumption is the recommended serverless plan: Linux only, per-function scaling up to 1,000 instances, VNet integration, optional always-ready instances and a choice of instance memory. The older Consumption plan is now legacy, with a default timeout of 5 minutes and a maximum of 10. Premium keeps at least one instance warm, supports VNet integration and longer runs. A Dedicated plan runs functions on an App Service plan you already pay for. Functions can also run on Container Apps.
One limit applies everywhere: an HTTP-triggered function must reply within 230 seconds, because of the front-end load balancer idle timeout. For longer work, accept the request, put a message on a queue and return 202 Accepted, or use Durable Functions.
- Flex Consumption: 30 min default timeout, no slots
- Premium: prewarmed instances, up to 3 slots per app
- Legacy Consumption: 10 min maximum
- HTTP response limit: 230 seconds on every plan
Triggers and bindings
Each function has exactly one trigger. Bindings are optional declared inputs and outputs, so the runtime fetches and saves data for you. In the Python v2 programming model, both are decorators on the function. A queue trigger hands you the message; a blob output binding writes whatever you assign to it into a container.
Connections are named in app settings, not in code. AzureWebJobsStorage is the storage account the Functions host itself uses. For production, use identity-based connections: set the setting with a __accountName suffix (or a service URI) and grant the function app's managed identity a data role such as Storage Queue Data Contributor, so no connection string or key is stored. Triggers on queues retry failed messages and then move them to a poison queue, so write handlers that are safe to run twice.
- 1Message arrives
API puts a job on the thumbnails queue.
- 2Trigger fires
Host leases the message and calls your function.
- 3Function runs
Your code resizes the image.
- 4Output binding
Result is written to a blob container.
- 5Message completed
Deleted on success; retried, then poison queue on failure.
Deployment slots and swaps
A slot is a full app with its own hostname, such as contoso-api-staging.azurewebsites.net, running on the same plan. Standard tier gives 5 slots and Premium v3 gives 20, including production. When you swap staging into production, App Service first applies production's sticky settings to the staging instances, warms them up by sending requests, then switches the routing. Nothing restarts in production during the switch.
Settings either move with the code or stay with the slot. Mark environment-specific values, such as a database name or a feature flag for staging, as slot settings so they stay put. A swap with preview lets you apply settings first and check the app before completing. Rolling back is just swapping again. Function apps support slots on Premium and Dedicated plans, but not on Flex Consumption.
- Pipeline to Staging slot: Deploy version 2 and run smoke tests1Deploy version 2 and run smoke tests
- Pipeline to App Service front end: Start swap staging to production2Start swap staging to production
- App Service front end to Staging slot: Apply production settings, send warm-up requests3Apply production settings, send warm-up requests
- Staging slot to App Service front end: Instances respond healthy4Instances respond healthy
- App Service front end to Users: Route production traffic to version 25Route production traffic to version 2
Learn it in 5 short steps
About 35m each. Track them with a timer in your plan.
- 1Compare App Service plans~35m
- 2Compare Functions hosting plans~35m
- 3Use triggers and bindings~35m
- 4Swap deployment slots~35m
- 5Account for cold starts and limits~35m
Key points
- An App Service plan is the set of VMs you pay for; every app in the plan shares them.
- Deployment slots let you warm up a new version and swap it into production with no downtime (Standard tier and above).
- A trigger starts a function; bindings connect it to storage, queues or databases with little code.
- For new serverless function apps Microsoft recommends Flex Consumption; the old Consumption plan is legacy.
- An HTTP-triggered function must respond within 230 seconds; longer work belongs in a queue or Durable Functions.
Key terms
Tap a card to flip it. 0/6 known
Examples
import azure.functions as func
app = func.FunctionApp()
@app.route(route="health", auth_level=func.AuthLevel.ANONYMOUS)
def health(req: func.HttpRequest) -> func.HttpResponse:
return func.HttpResponse("ok", status_code=200)
@app.queue_trigger(arg_name="msg", queue_name="thumbnails",
connection="AzureWebJobsStorage")
def make_thumbnail(msg: func.QueueMessage) -> None:
job = msg.get_json()
print(f"resize {job['blob']}")Python v2 programming model: one HTTP trigger and one queue trigger in the same function app.
Release a web API through a staging slot
Prerequisites: a Standard (S1) Linux plan, which is paid; for a design-only run, read the steps and draw the swap. Step 1: create the plan and app. Step 2: create a staging slot. Step 3: deploy a zip to staging and check its health URL. Step 4: swap. Evidence: the production URL now returns the new version string, and the staging URL returns the old one. Rollback: run the same swap again. Cleanup: delete the resource group.
az appservice plan create -g rg-lab-web -n plan-web --sku S1 --is-linux
az webapp create -g rg-lab-web -p plan-web -n contoso-api-lab --runtime "PYTHON:3.12"
az webapp deployment slot create -g rg-lab-web -n contoso-api-lab --slot staging
az webapp deploy -g rg-lab-web -n contoso-api-lab --slot staging --src-path app.zip --type zip
curl -s https://contoso-api-lab-staging.azurewebsites.net/health
az webapp deployment slot swap -g rg-lab-web -n contoso-api-lab \
--slot staging --target-slot production
curl -s https://contoso-api-lab.azurewebsites.net/healthRun a queue-triggered function locally for free
Prerequisites: Python 3.12, Azure Functions Core Tools v4 and Node.js for Azurite. Step 1: start Azurite, the local storage emulator. Step 2: create a project and add the queue trigger from the explainer. Step 3: set AzureWebJobsStorage to UseDevelopmentStorage=true in local.settings.json. Step 4: run func start, then add a message with the Azure CLI against Azurite. Evidence: the terminal logs the function run. Nothing is billed. Cleanup: stop both processes.
npx azurite --silent --location ./.azurite &
func init thumbs --python && cd thumbs
# paste the function code into function_app.py
func start &
az storage queue create -n thumbnails --connection-string "UseDevelopmentStorage=true"
az storage message put -q thumbnails --connection-string "UseDevelopmentStorage=true" \
--content "$(echo -n '{"blob":"cat.jpg"}' | base64)"Quick reference
- Deployment slots and autoscale need App Service Standard tier or higher
- HTTP-triggered functions must respond within 230 seconds on every plan
- Flex Consumption: recommended serverless plan, Linux only, no deployment slots
- Legacy Consumption timeout: 5 minutes default, 10 minutes maximum
- Mark environment-specific app settings as slot settings so they do not swap
- Local Functions: func start plus Azurite with UseDevelopmentStorage=true
- Use identity-based connections instead of storage connection strings in production
Common mistakes
- Putting a 10-minute report behind an HTTP trigger. The front end cuts the request at 230 seconds whatever the timeout says.
- Forgetting that app settings swap with the slot. Mark environment-specific settings as slot settings so they stay put.
- Choosing a Free or Basic App Service tier and then needing slots or autoscale, which start at Standard.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
List the slots of a web app and show which settings are marked as slot settings.
- Exercise 2medium
Add a sticky setting DB_NAME=appdb-staging to the staging slot, swap, and prove production kept its own DB_NAME.
- Exercise 3hard
Redesign an HTTP function that takes 8 minutes so callers never time out. Describe the flow and write the HTTP part.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Is Azure Functions cheaper than App Service?
- For spiky or low traffic, usually yes, because Flex Consumption bills per use and can scale to zero. For steady all-day traffic, a fixed App Service plan is often cheaper and avoids cold starts.
- Can I run a container on App Service?
- Yes. App Service can run a custom Linux container image. If you want scale to zero and revisions for containers, compare Azure Container Apps.
- What is Always On?
- An App Service setting that keeps the app loaded even with no traffic, so the next request is not slow. It needs Basic tier or above.