App Service and Azure Functions
PaaS web apps and FaaS event handlers
App Service runs managed web apps with scaling, TLS and staging slots; Functions runs event-driven code with consumption pricing. Together they cover most PaaS/Serverless needs.
What you will learn
- Deploy and scale an App Service app
- Explain deployment slots and swap
- Choose between App Service and Functions by workload shape
App Service is managed hosting for web apps/APIs: automatic patching, load balancing, TLS, staging slots. Functions runs serverless code with per-execution billing and native bindings to queues/blobs/events.
What is this?
Azure App Service is a managed web-app platform: it runs your code, handles TLS, scaling and staging via slots (blue-green swaps), and can run containers or frameworks (Node, .NET, Java, Python). Azure Functions is FaaS: you deploy code, it scales per event with consumption/plan pricing, integrating natively with Service Bus, Event Grid, Blob and HTTP triggers. Both share Managed Identity auth and App Insights observability.
Why do you need it?
- App Service removes the VM you were patching and the load balancer you were hosting TLS on.
- Slots make zero-downtime deploys a config flag, not a ceremony.
- Functions gives event-driven glue without servers — cheap, scaling automatically.
- Both integrate natively with App Insights, Key Vault and VNet integration.
Mental model
A hotel with housekeeping and room service
App Service and Functions
App Service is the hotel: the building, cleaning and maintenance handled; you just check in your app. Functions is the kitchen cook you call only when an order (event) arrives — no kitchen staff paid while idle.
How it works
- App Service runs an app in an isolated worker plan (PaaS) or serverless consumption; scale-out adds workers automatically.
- Slots: deploy a staging slot, warm it, swap — instant, reversible release.
- Functions: a trigger (HTTP, Queue, Timer) invokes your handler; bindings simplify IO (input/output bindings to Storage/SQL).
- Both use managed identity to reach Key Vault/DBs without secrets.
- Observability via Application Insights out of the box.
Choosing App Service or Functions.
In production
- An API team deploys to App Service staging, runs load tests, then swaps — traffic moves without downtime.
- A billing pipeline uses a Queue trigger Function to process invoice jobs as they arrive.
- A SaaS exposes a web dashboard (App Service) and uses Functions for webhook integration.
Best practices
- Use slots for every release; make the swap the only release step.
- Keep Functions small and stateless; let storage own state.
- Wire managed identity + Key Vault instead of app settings secrets.
- Set an App Insights sampling tier so logs don't overwhelm the bill.
Common mistakes
- Cold swap with pending DB migrations — run migrations before swap or in a maintenance flutter.
- Using consumption Functions for long-running CPU-heavy jobs; they time out.
- Publishing directly to production slot and skipping staging warm-up.
- Ignoring autoscale config for App Service plans, paying for idle capacity.
Common issues
Slot swap flips in errorsStaging didn't warm the new code's connections/migrations
Enable warm-up (always on) and run a warmup probe; migrate schema before swap.
Function hits timeout on heavy jobsWrong plan for the workload
Move heavy work to App Service or use a dedicated plan with higher limits; keep functions light.
App can't reach a database behind a private endpointVNet integration missing on the app/Functions
Enable Regional VNet integration to the VNet hosting the DB private endpoint.
Debugging tips
- 500s in prod but fine in staging? Check the slot's app settings and environment.
- Function timing out? Look at the InvocationDetails timeout and function execution time.
- Cold start slow? Move a long-lived DLL/init out, or switch the plan tier.
- App Insights query: failures | where operation_Name ... to isolate the failing endpoint.
Interview checkpoint
Hands-on lab
- Create an App Service and deploy code
- Create a staging slot and swap
- Verify the swap behavior
Deploy an App and Swapping Slots
35 min · advanced
Quick quiz
Which primitive fits a Queue-triggered invoice worker best?