Azure
Intermediate 15 min read Azure

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.

App ServiceAzure Functionsdeployment slotsconsumption planPaaS
Before we start

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
In 60 seconds

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.

Introduction

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.

Motivation

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.
Think about it

Mental model

Imagine

A hotel with housekeeping and room service

Think of

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.

Mechanics

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.

Web app / API / long-lived
Event-driven / small bursts
Staging slots
Managed identity
App Insights
Real world

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

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.
Watch out

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.
Root cause analysis

Common issues

Error
Slot swap flips in errors
Root cause

Staging didn't warm the new code's connections/migrations

Fix

Enable warm-up (always on) and run a warmup probe; migrate schema before swap.

Error
Function hits timeout on heavy jobs
Root cause

Wrong plan for the workload

Fix

Move heavy work to App Service or use a dedicated plan with higher limits; keep functions light.

Error
App can't reach a database behind a private endpoint
Root cause

VNet integration missing on the app/Functions

Fix

Enable Regional VNet integration to the VNet hosting the DB private endpoint.

When things break

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

Interview checkpoint

Practice

Hands-on lab

Deploy an App and Swapping Slots
35 min · advanced
In progress
Objectives
  • 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

0/5 steps
0%
sandbox · Linux sandbox
$
Try these commands
Test yourself

Quick quiz

0/1
1

Which primitive fits a Queue-triggered invoice worker best?

Go deeper

Official documentation