App Service in Azure: A Ready-Made Home for Your Web Apps and APIs
An intermediate guide to Azure App Service. Learn how plans, workers, and apps fit together, how deployment slots, scaling, networking, identity, and monitoring work inside, and how to design web applications that are secure, fast, resilient, and affordable.
Imagine you want to open a restaurant. You could buy land, build the walls, install the kitchen, hire security, connect water and electricity, and repair everything yourself. Or you could rent a fully equipped restaurant space in a managed food court, where the building, the power, the cleaning, and the guards are looked after by the owner, and you simply bring your recipes and your cooks. Azure App Service is that food court for web applications. You bring your code, and Azure provides the servers, the operating system, the web server software, the security patches, the scaling machinery, and the certificates, so you can focus on what makes your application special.
1What Is Azure App Service?
Start with a plain definition, then add the details one layer at a time.
Azure App Service is a fully managed platform for hosting web applications, REST APIs, and the back ends of mobile apps. It is called a Platform as a Service, or PaaS. That means Microsoft manages the lower layers for you: the physical servers, the virtualization, the operating system, the runtime updates, and the web server. You manage the top layer: your application code, its settings, and its data.
You can write your application in many popular languages and frameworks, such as .NET, Java, Node.js, Python, and PHP, and App Service runs it for you. You can also bring your own packaged application as a container image. Once running, your app is reachable over the internet through a web address, and you can add your own domain name and a security certificate.
App Service sits in the middle of the Azure hosting spectrum. Virtual machines give you the most control and the most work. Serverless functions give you the least control and the least work, for small event-driven pieces of code. App Service balances the two: you get steady, always-ready hosting with simple scaling, without administering any servers.
A virtual machine is renting an empty plot of land and building everything yourself. App Service is renting a furnished shop in a managed mall, where the mall owner fixes the roof, the lights, and the locks. You decide what to sell and how to arrange the shelves.
2The Problem App Service Solves
A tool makes sense when you know the pain it removes.
Running a web application the traditional way involves a long list of chores that have nothing to do with the application itself. Someone has to set up servers, install the operating system, apply security patches every month, install the right runtime versions, configure the web server, manage certificates before they expire, handle load balancing, and plan for traffic spikes. If any of these chores is forgotten, the application suffers.
Server maintenance
Operating systems and runtimes need constant patching, and a missed patch becomes a security hole.
Scaling for traffic
Traffic rises and falls. Buying capacity for the peak wastes money, while buying for the average causes slowdowns at busy times.
Risky releases
Deploying straight to the live site can cause downtime, and a bad release is slow to undo.
Certificates and domains
Expired certificates and misconfigured domains cause embarrassing outages.
Sign-in and security
Every application needs authentication, secrets handling, and network protection, and building them from scratch is slow and error-prone.
Visibility
Without logs and metrics, finding why an application is slow or failing is guesswork.
App Service addresses each of these with built-in features: automatic patching of the platform, manual and automatic scaling, deployment slots with swap, managed certificates and custom domains, built-in authentication, managed identities, network integration, and deep monitoring.
3Core Concepts: App, Plan, and Worker
Three words explain the heart of App Service. Learn them well.
The most important idea in App Service is the difference between the app and the plan. They are separate Azure resources, and they have different jobs. Beginners often mix them up, and this causes confusion about cost and scaling.
App Service app
Your actual web application or API, with its code, settings, domain names, and deployment history. It is the thing visitors talk to.
App Service plan
The set of computing resources that apps run on. The plan decides the region, the operating system, the size of the machines, how many machines, and the price tier. You pay for the plan, not for each app.
Worker
A virtual machine instance inside the plan that actually runs your apps. If your plan has three instances, you have three workers, and every app in the plan runs on each of them.
Pricing tier
The family of the plan, such as Free, Basic, Standard, Premium, or Isolated, which decides features and the size of the workers.
Instance count
How many workers the plan has right now. Scaling out changes this number.
Runtime stack
The language and version your app uses, such as a particular .NET, Java, Node.js, Python, or PHP version, or a container.
flowchart TD
SUB["Azure Subscription"] --> RG["Resource Group"]
RG --> PLAN["App Service Plan: region, OS, size, tier, instance count"]
PLAN --> W1["Worker 1"]
PLAN --> W2["Worker 2"]
PLAN --> W3["Worker 3"]
RG --> APP1["App A: web site"]
RG --> APP2["App B: API"]
RG --> APP3["App C: back office"]
APP1 -.runs on.-> PLAN
APP2 -.runs on.-> PLAN
APP3 -.runs on.-> PLAN
The plan is the shopping mall building with a certain number of floors, and each floor is a worker. The apps are shops inside the mall. You pay the rent for the mall building, not per shop, and every shop is open on every floor. Adding more shops costs nothing extra until the building is full.
Because several apps can share one plan, you can host many small applications cheaply, as long as the plan has enough capacity for all of them together. This is one of the main cost advantages of App Service.
4Inside the Platform: How App Service Works Internally
A peek behind the curtain helps you reason about performance and problems.
App Service is built from several cooperating parts. Understanding them explains behavior that otherwise seems mysterious, such as why apps restart, why the first request after idle is slow, and how traffic reaches your code.
Front ends
Shared machines that receive all incoming web requests, handle secure connections, and apply routing rules. They act as load balancers that pick a worker for each request.
Workers
The virtual machines of your plan, where your application code actually runs inside an isolated sandbox.
Shared content storage
A shared file storage that holds your app’s files, so that every worker sees the same content. On Windows, this includes the web root. On Linux, the application files are mounted in a similar way.
Management and publishing services
Services that receive deployments, apply settings, and control the app’s lifecycle, including the Kudu management site.
Sandbox
An isolation boundary around each app, so apps sharing a worker cannot see or disturb each other, and limits protect the machine.
A visitor requests your site
The browser looks up your domain name and connects to App Service’s public address.
A front end receives the request
It ends the secure connection, checks the host name, applies access restrictions, and finds which app this request belongs to.
The front end picks a worker
It chooses one of the workers in the plan, using load balancing and, if enabled, session affinity to prefer the same worker for the same visitor.
The worker runs your code
Your application inside its sandbox handles the request, perhaps calling databases or other services.
The response travels back
The answer goes through the front end to the visitor, and logs and metrics are recorded along the way.
sequenceDiagram
participant V as Visitor Browser
participant FE as App Service Front End
participant W as Worker running your app
participant DB as Database or other service
V->>FE: HTTPS request to www.example.com
FE->>FE: Check host name, access rules, authentication
FE->>W: Forward to a chosen worker
W->>DB: Query data if needed
DB-->>W: Data
W-->>FE: Response
FE-->>V: HTTPS response
The front end is the reception desk of the mall, checking who may enter and pointing each visitor to the right shop. The worker is the shop floor where staff actually serve customers. The shared storage is the common stockroom that every shop floor can reach.
5Operating Systems and Runtime Stacks
You must choose what your app runs on, and this choice is fixed per plan.
An App Service plan runs either Windows or Linux, and all apps in the plan share that operating system. You cannot mix Windows and Linux apps in one plan, although you can have separate plans in the same resource group. Choose according to your technology and your team’s habits.
| Point | Windows plan | Linux plan |
|---|---|---|
| Typical technologies | .NET Framework, .NET, Node.js, Java, PHP | .NET, Node.js, Python, Java, PHP, Ruby, and custom containers |
| Classic .NET Framework apps | Supported | Not supported |
| Containers | Windows containers are supported on certain tiers | Linux containers are widely supported |
| Management site | Kudu with a Windows console | Kudu with a Linux console |
| Typical price | Usually higher because of license costs | Usually lower |
| Best for | Existing Windows-based applications | Open source stacks and new cloud-native apps |
Built-in runtime stacks
Microsoft maintains runtime images for popular languages. Updates to patch versions are applied by the platform, and you choose the major version.
Custom containers
You package your application and its dependencies into a container image, store it in a registry, and App Service pulls and runs it. This gives you full control of the runtime environment.
Code versus container
Code deployment is simpler to start. Containers give consistency between development and production and allow unusual dependencies.
Every language version has an end-of-support date. When a version goes out of support, App Service eventually stops offering it, and an app that stays on it loses security patches. Track the support dates of your runtime and plan upgrades ahead of time.
Choosing an operating system for the plan is like choosing the type of mall: one built for a certain style of shops, another for different styles. A container is like bringing your own pre-built shop on a truck and placing it inside the mall, with everything already arranged as you like.
6Pricing Tiers: Choosing the Right Size
The tier decides features, performance, scaling limits, and price.
App Service plans come in tiers. Lower tiers are meant for learning and light use, while higher tiers add scaling, slots, networking, and performance features. The names and details of tiers, sizes, and features evolve over time, and new generations appear, so use the following as a general map and confirm the current options in the documentation.
| Tier family | Typical purpose | Notable characteristics |
|---|---|---|
| Free and Shared | Learning and tiny experiments | Shared infrastructure with strict daily limits, no custom scaling, and limited features |
| Basic | Development, testing, and small low-traffic sites | Dedicated machines, manual scaling to a few instances, no deployment slots |
| Standard | Production apps with moderate needs | Autoscale, deployment slots, backups, and traffic routing |
| Premium | Production apps needing more power and features | More and faster instances, more slots, richer networking and zone redundancy options |
| Isolated | Strict isolation and compliance needs | Runs in a dedicated environment inside your own virtual network, with the highest scale limits |
Machine size
Each worker has a certain number of processor cores and amount of memory. Bigger sizes cost more per instance.
Instance count
The total price is roughly the price per instance times the number of instances, while the plan exists.
Operating system
Windows plans usually cost more than Linux plans of the same size.
Commitments
Reservations or savings plans can lower the price of steady plans in some tiers, and Hybrid Benefit may apply for certain licenses.
Start with the smallest tier that has the features you truly need, such as slots and autoscale for production, and measure real usage. Move up only when data shows a need. Always check current pricing with the Azure pricing calculator, because tiers and prices change.
Tiers are like hotel room classes. A budget room has a bed and a shower. A business room adds a desk and faster internet. A suite adds a separate living area. You pick the class according to what you need during your stay, not simply the biggest one available.
7Deploying Your App: Getting Code Into App Service
There are many ways in. Choose the one that fits your team and your process.
Continuous deployment from source control
Connect the app to a repository, for example on GitHub or Azure Repos. Whenever you push changes to a chosen branch, a pipeline builds and deploys them. This is the most common production approach, and it keeps a clear history of who deployed what.
Pipelines in GitHub Actions or Azure Pipelines
A workflow builds, tests, and deploys the app, and can deploy first to a staging slot, run checks, and then swap into production. It gives you full control over the process.
Zip deploy and package deploy
You upload a prebuilt package of your application. Run-from-package mode can mount the package as a read-only file system, which improves startup time and makes deployments more atomic.
Container deployment
You push an image to a registry, and App Service pulls it. Webhooks or pipelines can trigger a restart on a new image version.
Developer tools
Command-line tools, editor extensions, and the portal can publish directly. They are convenient for learning and quick tests, but production deployments should go through a repeatable pipeline.
FTP and manual methods
Older methods that copy files directly. They exist for compatibility, but they are easy to misuse and are best disabled or limited in production, in favor of secure, automated approaches.
Commit and push code
A developer pushes a change to the main branch after review.
The pipeline builds and tests
The code is compiled, unit tests run, and the package is created once.
Deploy to a staging slot
The package is deployed to a staging slot, where it can warm up and be tested without affecting visitors.
Verify and swap
Health checks and smoke tests confirm that staging works, and then the slot is swapped into production.
Monitor the release
Dashboards and alerts confirm the new version is healthy, and the swap can be reversed if not.
Deploying is like restocking a shop. You can carry boxes in through the front door during opening hours, which is messy and risky. Or you can prepare the new display in a back room and quickly swap it with the old one after closing the curtain for a moment.
8Deployment Slots: Safe Releases and Easy Rollback
Slots are one of the most valuable features for production apps.
A deployment slot is a live copy of your app with its own address, running in the same plan. A typical setup has a production slot, which serves real visitors, and a staging slot, where new versions are deployed and tested. Slots share the same plan resources, so they use the same workers, but they are separate apps with separate settings if you wish.
How a swap works
When you swap staging into production, App Service first applies the target slot’s settings to the staging instances and restarts them, then warms them up by sending requests, and once they respond correctly, it switches the routing so that production traffic goes to the new code. The old production code now lives in the staging slot, ready to be swapped back if a problem appears. Because the new version is already warm, visitors usually see no downtime and no cold start.
sequenceDiagram
participant Dev as Pipeline
participant Stg as Staging Slot
participant Prod as Production Slot
participant U as Visitors
Dev->>Stg: Deploy new version
Dev->>Stg: Run smoke tests
Dev->>Stg: Start swap: apply production settings and warm up
Stg->>Stg: Respond to warm-up requests
Note over Stg,Prod: Routing switches
U->>Prod: Requests now reach the new version
Prod-->>U: Responses from new code
Note over Stg: Old version waits in staging for instant rollback
Sticky settings
Settings marked as slot-specific stay with the slot and do not move during a swap, such as a test database connection for staging. Other settings travel with the code.
Swap with preview
A two-phase swap that first applies production settings to the staging slot so you can test with real configuration, before completing the swap.
Auto swap
Automatically swaps a slot into production after a successful deployment to it, useful for simple pipelines.
Traffic routing
Send a chosen percentage of production traffic to another slot for gradual testing, similar to a canary release.
Custom warm-up
Define which paths to call during warm-up, so caches and connections are ready before real traffic arrives.
Forgetting that slots share the plan’s resources. A busy staging slot, or a long load test against it, can slow down production because they run on the same workers. Also, a staging slot that is configured to use the production database can accidentally change real data during tests.
A slot swap is like a theatre with a hidden second stage. The crew builds and rehearses the next scene on the hidden stage, then rotates the stage so the audience instantly sees the finished set. If something looks wrong, they rotate back.
9Scaling: Up, Out, and Automatic
Handling more visitors means more power. There are two directions to grow.
Scale up (vertical scaling)
Change the plan to a larger size or higher tier, so each worker has more processor power and memory, or gains features. It requires a short transition, and every worker is bigger. It is useful when one request needs a lot of memory or processing, or when you need features of a higher tier.
Scale out (horizontal scaling)
Add more workers of the same size. Traffic is spread across them by the front ends. It is the usual way to handle more visitors, and it also improves resilience, because losing one worker leaves others running.
Autoscale
Rules that add or remove workers automatically based on metrics such as processor use, memory, or request counts, or based on a schedule. You set a minimum, a maximum, and a default instance count.
Automatic scaling (platform-managed)
On certain tiers, the platform itself can adjust the number of instances in response to HTTP load, with pre-warmed instances to avoid slowdown. It is simpler than writing rules, but available only for specific plans and options, so check current support.
flowchart LR
M["Metric: CPU, memory, or requests"] --> R{"Rule check"}
R -->|Above scale-out threshold| OUT["Add an instance"]
R -->|Below scale-in threshold| IN["Remove an instance"]
R -->|Between thresholds| KEEP["Keep the current count"]
OUT --> CD["Cooldown period"]
IN --> CD
CD --> M
| Approach | What changes | Best for | Watch out for |
|---|---|---|---|
| Scale up | Size or tier of each worker | Memory-hungry apps and needing higher tier features | Limited by the largest size, and a single worker remains a single point of failure |
| Scale out | Number of workers | More concurrent visitors and resilience | The app must work well with several instances running |
| Autoscale | Instance count, automatically | Variable traffic and cost control | Poor rules can scale too slowly or oscillate |
Designing apps that scale out
Keep the app stateless
Do not keep important user data in the memory or local disk of one worker. Store sessions and data in shared services such as a cache or database.
Use shared caching
A shared cache lets every worker see the same data, instead of each keeping its own version.
Make startup fast
New instances should become ready quickly, so autoscale helps in time.
Watch downstream limits
More workers mean more database connections and calls. Make sure the database and other services can handle the extra load.
Scaling up is replacing your shop counter with a bigger, stronger one. Scaling out is opening more counters side by side. Autoscale is a manager who opens extra counters when the queue grows and closes them when it shrinks, provided each cashier can serve any customer without needing to remember who was served before.
10Configuration: App Settings, Connection Strings, and Environments
The same code should run in many environments by changing settings, not code.
App Service lets you set application settings and connection strings in the portal or through automation. These values are provided to your app as environment variables when it runs. Changing a setting normally restarts the app. Settings are stored encrypted at rest and can be marked slot-specific, so that staging and production hold different values.
Application settings
Name and value pairs for your app, such as feature switches, endpoints, and mode names.
Connection strings
Special settings with a type, such as database connections, which some frameworks read in a special way.
General settings
Platform options such as the runtime version, startup command, always on, HTTP version, and minimum TLS version.
Path mappings and storage mounts
Ways to attach external storage, such as file shares, into the app’s file system for shared content.
Default documents and handlers
Which file is served when a folder is requested and how certain file types are processed, mostly relevant on Windows.
Keep environment differences in settings
Endpoints, feature switches, and limits live in settings so the same package runs everywhere.
Mark environment-specific values as slot settings
Values that must not travel during a swap, such as staging-only endpoints, stay with their slot.
Keep secrets out of plain settings
Use Key Vault references instead of copying passwords into settings, as covered in the security chapter.
Manage settings through automation
Store them in templates or pipelines so changes are reviewed and repeatable.
Treat the portal as a place to look, not as the source of truth. If settings are changed by hand in the portal and also defined in a pipeline, the next deployment may overwrite the manual change, causing confusing behavior.
Settings are the notes taped to the shop’s control panel: today’s opening hours, the supplier’s phone number, the price list in use. The shop itself is the same every day, but the notes change what it does in each branch.
11Custom Domains and Certificates
Your app starts with a default address, but customers expect your own name.
Every app gets a default address under the azurewebsites.net domain. To use your own name, such as www.example.com, you add a custom domain to the app and prove that you own it. You create DNS records at your domain provider that point your name to the app, and add a verification record. For the bare domain, you typically use an address record, while for subdomains you use an alias record that points to the default address. Check the current guidance for the exact record types the portal asks for.
Secure connections with certificates
App Service managed certificate
A free certificate that App Service creates and renews for supported custom domains. Simple, but with some limits, such as supported domain types.
Certificate from Key Vault
Import or reference a certificate stored in Key Vault, so renewals and rotation are managed centrally.
Uploaded certificate
Upload a certificate file that you bought from a certificate authority. You must renew and upload it yourself.
Certificate bought through App Service
A purchasable certificate option managed with Azure, useful when you want a paid, supported certificate and integration.
Choose a tier that supports custom domains
Free and Shared tiers have limits on custom domains and security features.
Create DNS records
Point your domain to the app and add the verification record requested by the portal.
Add the custom domain to the app
The portal checks the records and confirms ownership.
Bind a certificate
Select the certificate and the binding type so that the domain is served over HTTPS.
Require HTTPS and set a minimum TLS version
Redirect plain web traffic to secure traffic and refuse outdated, weak protocol versions.
Problem
Uploading a purchased certificate by hand and relying on someone to remember its expiry date.
Why It’s Harmful
When the certificate expires, browsers show frightening warnings, customers leave, and APIs that call your service start failing, often at the worst possible moment.
Correct Approach
Use managed certificates where they fit, or store certificates in Key Vault with automatic renewal and expiry alerts.
A custom domain is the signboard with your shop’s real name instead of the mall’s default address label. The certificate is the official license displayed in the window that shows customers you are who you claim to be. An expired license makes customers walk away.
12Networking: Controlling Who Can Reach Your App and What It Can Reach
Networking has two directions: inbound traffic to the app and outbound traffic from the app.
By default, an App Service app has a public address on the internet, and it can call out to the internet. In real projects you often need to limit who can reach the app, and to let the app reach private resources, such as a database that is not open to the public. App Service offers separate features for these two directions, and mixing them up is a very common source of confusion.
Inbound: who can reach the app
Access restrictions
Allow or deny traffic to the app by address ranges, virtual network subnets, or service tags. A simple firewall in front of the app.
Private endpoints
Give the app a private address inside your virtual network, and optionally turn off public access, so only private networks can reach it.
Front door and gateway services
Place Azure Front Door or Application Gateway in front, and restrict the app so it accepts traffic only from them, adding firewall and global routing features.
Client certificates
Require visitors to present a certificate, for strong, machine-to-machine style authentication.
Outbound: what the app can reach
Regional virtual network integration
Lets the app make outbound calls into a virtual network, so it can reach private databases and services, and use network rules such as routing and firewalls.
Hybrid Connections
A relay-based way to reach a specific host and port in another network, such as an on-premises server, without opening inbound firewall ports.
NAT gateway for stable outbound address
With virtual network integration, a NAT gateway can give all outbound traffic one predictable public address, helpful when partners allow only certain addresses.
Service endpoints and private endpoints on the target
The destination service, such as a database, can accept traffic only from your integration subnet or through a private address.
flowchart LR
USER["Users on the internet"] --> FD["Front Door or Application Gateway with firewall"]
FD -->|Only allowed source| APP["App Service app"]
subgraph VNET["Your Virtual Network"]
INT["Integration subnet for outbound calls"]
PEDB["Private endpoint: Database"]
PEKV["Private endpoint: Key Vault"]
end
APP -->|VNet integration| INT
INT --> PEDB
INT --> PEKV
| Need | Feature direction | Right tool |
|---|---|---|
| Only my office and a gateway may reach the app | Inbound | Access restrictions or a private endpoint |
| The app must call a private database | Outbound | Virtual network integration, with the database on a private endpoint |
| The app must reach one on-premises server | Outbound | Hybrid Connections, or virtual network integration with a VPN or private line |
| The partner needs a fixed address for my calls | Outbound | Virtual network integration with a NAT gateway |
| The app must not be visible on the public internet | Inbound | Private endpoint with public access disabled, or an isolated environment |
Believing that virtual network integration makes the app private. Integration only affects outbound traffic. Inbound traffic still reaches the public address unless you also add access restrictions or a private endpoint. Many “private” apps are, in fact, open to the internet because of this misunderstanding.
Inbound networking is who may come through the mall’s front door to visit your shop. Outbound networking is where your staff may go when they leave to fetch supplies. Locking the front door does nothing to control where your staff travel, and giving staff a private tunnel to the warehouse does not lock the front door.
13Identity: Managed Identities and Sign-In for Your Users
Identity answers two questions: how does the app prove itself, and how do users prove themselves?
The app’s own identity
A managed identity is an identity that Azure creates and manages for your app. With it, your app can sign in to other Azure services, such as Key Vault, Storage, and databases that support identity-based access, without storing any password. You give the identity the needed roles on the target service, and the app requests tokens from Azure at run time. There are system-assigned identities, tied to one app, and user-assigned identities, which can be shared by several resources.
Sign-in for your users
App Service has a built-in authentication feature, often called Easy Auth, which sits in front of your code and handles sign-in with identity providers such as Microsoft Entra ID and others. It can require users to sign in before they reach any page, or allow anonymous access and let the app decide. It passes the signed-in user’s information to your app in request headers, so your code does not need to implement the sign-in protocol itself.
Managed identity for outbound access
Passwordless access from the app to Azure resources, controlled by role assignments.
Built-in authentication
Sign-in handled by the platform, with support for several identity providers and token storage.
Authorization rules
Require sign-in for all requests, or only for some paths, and choose what to do for unauthenticated users, such as redirect or return an error.
Key Vault references
App settings that point to secrets in Key Vault, resolved by the platform using the app’s managed identity.
sequenceDiagram
participant U as User
participant FE as App Service with built-in authentication
participant IDP as Microsoft Entra ID
participant APP as Your application code
participant KV as Key Vault
U->>FE: Request a protected page
FE-->>U: Redirect to sign in
U->>IDP: Sign in
IDP-->>U: Token
U->>FE: Request with token
FE->>APP: Forward request with user information in headers
APP->>KV: Read a secret using the app's managed identity
KV-->>APP: Secret value
APP-->>U: Page for the signed-in user
Built-in authentication is a security guard at your shop door who checks each visitor’s ID and tells your staff only the name. The managed identity is your shop’s own staff badge, used to collect goods from the warehouse without carrying cash or keys.
Built-in authentication checks that someone is signed in, but your application still has to decide what each user may do. Authentication is not the same as authorization, so keep permission checks inside the app or through roles.
14Security: Layers of Protection
A secure web app is protected at many layers, not by one switch.
Platform security
Microsoft patches the operating system and runtime, isolates apps in sandboxes, and monitors the infrastructure.
Transport security
Require HTTPS only, set a modern minimum TLS version, and consider disabling unused protocols and old deployment methods.
Network controls
Use access restrictions, private endpoints, front door or gateway firewalls, and private outbound paths.
Identity and secrets
Use managed identities and Key Vault references. Avoid passwords in settings and code.
Application security
Validate input, protect against common web attacks, and keep libraries updated. The platform cannot fix insecure code.
Management access
Control who can change the app with role-based access control, and protect the Kudu management site and deployment credentials.
Monitoring and threat protection
Collect logs, and use security tools such as Microsoft Defender for App Service where enabled, to detect suspicious activity.
Require HTTPS and modern TLS
Switch on HTTPS only and set the minimum TLS version to a current one.
Disable basic publishing credentials and plain FTP
Prefer identity-based deployment methods, and turn off password-based publishing where possible.
Use managed identity and Key Vault
Remove passwords from settings and let the app authenticate to Azure services by identity.
Restrict inbound access
Put a protective service in front, and limit the app to accept traffic only from it or from private networks.
Limit who can manage and deploy
Assign narrow roles, protect production slots, and review role assignments regularly.
Log and alert
Turn on diagnostic logs, send them to a central workspace, and alert on unusual errors and sign-in activity.
Problem
Leaving the management site and deployment endpoints reachable from the whole internet, protected only by a shared publishing password.
Why It’s Harmful
Anyone who obtains the password can upload code, read files and settings, and take over the app. Shared passwords leak easily and cannot be tied to a person.
Correct Approach
Disable basic authentication, use identity-based deployments, restrict access to the management endpoints, and keep production changes inside an audited pipeline.
Securing an app is like securing a shop. There are locks on the doors, cameras, a guard at the entrance, a safe for the cash, and rules about who can enter the stockroom. A single strong lock helps, but thieves look for the unlocked back door.
15Reliability: Health Checks, Zones, and Regions
Plan for the day something fails, because eventually something will.
Health check
You give App Service a path to ping regularly. If an instance repeatedly fails the check, it is taken out of the load balancer rotation and may be replaced, so visitors reach only healthy instances.
Multiple instances
Running at least two instances means one failure or one update does not take the app down.
Always on
Keeps the app loaded so the first request after quiet periods is not slow. Available in tiers that support it, and important for apps with background work.
Zone redundancy
On supported plans and regions, instances are spread across separate data center zones, so the loss of one zone does not stop the app. It requires enough instances to spread across zones.
Multi-region deployment
Run the app in two regions, with a global traffic service in front, to survive a whole-region failure and to serve users from nearby locations.
Backups
Scheduled backups of app content and configuration, and sometimes connected databases, available on supported tiers.
flowchart TD
U["Users worldwide"] --> GF["Azure Front Door or Traffic Manager"]
GF -->|Primary| R1["Region 1: App Service with zone redundancy"]
GF -->|Failover| R2["Region 2: App Service with zone redundancy"]
R1 --> DB1["Primary database"]
R2 --> DB2["Replica database"]
DB1 -. replication .-> DB2
| Level of resilience | Protects against | Cost and effort |
|---|---|---|
| Single instance | Almost nothing | Lowest |
| Two or more instances | Single machine failure and rolling updates | Low |
| Zone redundancy | Loss of one data center zone | Medium, needs supported tier and instance count |
| Multi-region | Loss of a whole region | High, needs data replication and global routing |
Designing the web tier for high availability while leaving the database in a single location. The app is only as available as its weakest dependency, so plan resilience for every layer together, and test failover before you need it.
A single instance is a shop with one cashier. Two or more cashiers keep serving when one is sick. Zones are separate buildings of the same chain in one city, and regions are branches in different cities. The more spread out, the better the protection, and the higher the cost.
16Monitoring, Logging, and Diagnostics
If you cannot see what the app is doing, you cannot fix it quickly.
Platform metrics
Numbers such as processor use, memory use, request counts, response times, and error counts, for the app and the plan.
Application Insights
Application performance monitoring that records requests, exceptions, dependencies, and traces, and maps how components call each other.
Diagnostic logs
HTTP logs, application logs, platform logs, and console output, which can be sent to a Log Analytics workspace, storage, or an event hub.
Log stream
A live view of logs in the portal or command line, useful during troubleshooting.
Diagnose and solve problems
A built-in troubleshooting area with guided checks for common problems such as slow responses, crashes, and configuration issues.
Kudu and advanced tools
A management site with a file browser, process explorer, and options to capture memory dumps and profiling data for deep problems.
Alerts and availability tests
Rules that notify you when metrics cross a limit, and tests that call your site from several locations to check that it is reachable.
| Question | Where to look first |
|---|---|
| Is the app up and how fast is it? | Availability tests and response time metrics |
| Is the plan out of capacity? | Plan-level processor and memory metrics, and instance count |
| Why did this request fail? | Application Insights failures and exception details |
| Is a dependency slow? | Application Insights dependency timings |
| Why did the app restart? | Diagnose and solve problems, platform logs, and activity log |
| What happened after the last deployment? | Deployment history, error rates before and after, and logs |
Turn on Application Insights
Enable it on the app so requests, errors, and dependencies are recorded from the start.
Send diagnostic logs to a central workspace
Keep logs long enough for investigations, and filter noise to control cost.
Create alerts
Alert on failure rates, slow responses, high resource use, and failed health checks.
Add availability tests
Check the public experience from outside, not only internal metrics.
Review after every release
Compare key metrics before and after, and keep a rollback ready.
Monitoring a web app is like running a shop with a camera at the door counting visitors, a till record of every sale, and an alarm when the queue gets long. Without them, you only find out about problems when customers complain.
17Performance Tuning
Speed comes from a few well-understood habits.
Keep the app and its data close
Place the app, database, and cache in the same region, to reduce delay on every call.
Turn on Always On and warm-up
Avoid slow first requests after idle periods by keeping the app loaded and warming new instances before traffic.
Use caching
Cache results of expensive operations in a shared cache, and use caching headers for static content.
Use a content delivery network
Serve images, scripts, and other static files from locations near the visitors, so your workers handle only dynamic work.
Use run-from-package deployment
Reduces file system overhead and speeds startup for many apps.
Handle connections carefully
Reuse connections to databases and services, and avoid exhausting outbound connections by creating a new client for every request.
Disable session affinity if not needed
Affinity cookies pin a visitor to one worker, which can cause uneven load. Stateless apps often spread better without it.
Profile before guessing
Use Application Insights and profilers to find the slow step, rather than adding hardware blindly.
Measure the baseline
Record typical response times and resource use under normal load.
Find the slowest steps
Look at dependency timings and slow requests to see where the time goes.
Fix the biggest cause first
Common culprits are slow database queries, missing caches, chatty calls, and large payloads.
Load test in a safe environment
Test with a copy of the plan, not against the production plan that real users share.
Scale as the last step
Add capacity only after the app is efficient, because scaling a slow design just makes a slow design more expensive.
Tuning performance is like speeding up a restaurant. First you find out whether the delay is in the kitchen, in taking orders, or in delivering plates, and fix that. Hiring extra waiters will not help if the bottleneck is a slow oven.
18Background Work: WebJobs and Related Options
Web apps often need to run tasks that are not tied to a visitor’s request.
Many applications must send emails, process files, update reports, or clean data on a schedule. Running these tasks inside a web request makes pages slow and fragile. App Service offers WebJobs, which run background programs in the same plan as the app, and Azure offers other services designed for background work.
| Option | What it is | Best for | Watch out for |
|---|---|---|---|
| WebJobs, triggered | A program that runs on demand or on a schedule within the app’s plan | Small periodic tasks close to the app | Shares the plan’s resources with the web app |
| WebJobs, continuous | A program that runs all the time, waiting for work | Queue processors | Requires Always On, and runs on every instance unless limited |
| Azure Functions | Small serverless functions triggered by events, timers, or queues | Event-driven tasks with independent scaling | Different programming model and hosting choices |
| Container Apps jobs or other container services | Containerized background processing | Heavier or containerized batch work | Another service to manage |
| Message queues with worker apps | Requests placed in a queue and handled by separate workers | Reliable, scalable background processing | Needs design for retries and duplicates |
flowchart LR
WEB["Web app handles user request"] -->|Place work item| Q["Message queue"]
Q --> WK["Background worker: WebJob or Function"]
WK --> DB["Database or storage"]
WK --> MAIL["Email or notification service"]
Because every instance in a plan runs your app, a scheduled job inside the web app can run on several instances at once, causing duplicate work. Use a queue, a lock, or a single-instance mechanism so that each task runs once.
The web app is the front counter serving customers. Background workers are the kitchen staff who prepare orders from a ticket rail. The counter stays fast because it only writes the ticket and hands it over, instead of cooking while the customer waits.
19App Service Environment: The Isolated Option
Some organizations need a private, dedicated home for their apps.
An App Service Environment is a fully isolated and dedicated deployment of the App Service platform inside your own virtual network. Instead of sharing the multi-tenant front ends, you get your own, and you decide whether the environment is reachable from the internet or only from your private network. It supports very large scale and is used where compliance, network isolation, or high scale requires it.
Network isolation
The environment lives in your virtual network, with an internal or external address as you choose.
Dedicated infrastructure
Your own front ends and workers, not shared with other customers.
High scale
Higher limits on the number of plans and instances than the shared platform.
Higher cost and effort
There is a cost for the environment itself plus the plans inside it, and more networking design is needed.
| Point | Multi-tenant App Service | App Service Environment |
|---|---|---|
| Infrastructure sharing | Shared front ends, isolated apps | Dedicated environment |
| Network placement | Public service with private options | Inside your virtual network |
| Scale limits | Lower than isolated | Highest |
| Cost | Lower | Higher |
| Typical customers | Most web workloads | Strictly regulated or very large workloads |
Many requirements that used to need an isolated environment can now be met with private endpoints, access restrictions, and network integration on the multi-tenant service. Evaluate those first, and choose the dedicated environment only when you truly need it.
The shared service is a shop in a busy public mall with excellent security. The dedicated environment is your own private building inside a fenced campus. It is more private and bigger, but you pay for the whole building even when it is quiet.
20Cost Management for App Service
The plan is the bill. Managing it well saves real money.
You pay for an App Service plan for every hour it exists, regardless of how many apps run on it or how busy they are, based on its tier, size, instance count, and operating system. Extra costs arise from outbound data transfer, custom certificates, backups storage, private endpoints, logging, and connected services.
Consolidate apps onto fewer plans
Several small apps can share one plan if they fit together, instead of paying for many underused plans.
Right-size the plan
Check processor and memory use over weeks, and reduce oversized plans or move to a smaller size.
Autoscale instead of fixed peak capacity
Scale out for busy hours and in for quiet hours, with sensible minimums for resilience.
Stop or delete unused environments
Delete test plans and slots when not needed. Stopping an app does not stop billing for the plan. Only scaling down or deleting the plan does.
Use commitments for steady production plans
Reservations or savings plans can lower the price of steady capacity in eligible tiers. Check current options.
Control logging and data transfer
Filter verbose logs, use a content delivery network for static content, and keep dependencies in the same region.
Problem
Creating a new, separate plan for every tiny app and every environment, and believing that stopping an app stops the cost.
Why It’s Harmful
Each plan bills continuously, many plans run nearly idle, and the bill grows with the number of apps instead of the real workload.
Correct Approach
Group compatible apps in shared plans, right-size them, delete test plans when finished, and review plan utilization monthly.
Tier names, sizes, included features, and prices change over time, and new generations of plans appear. Use the official pricing page and calculator before deciding, and review your plan choice at least once a year.
Paying for a plan is like renting a mall unit. The rent is due whether the shop is busy or empty, and closing the shop door for a week does not reduce it. Sharing one unit among several small businesses, or moving to a smaller unit, cuts the rent.
21Design Patterns for Web Apps on App Service
Proven layouts solve common needs, so you do not have to invent them.
Simple web app with a managed database
One app in a plan, connected to a managed database, with a managed identity for access, Application Insights for monitoring, and a staging slot for releases. A solid starting design for many projects.
Front door pattern
Azure Front Door or Application Gateway in front of the app, providing a web application firewall, global routing, caching, and a single public entry point, while the app accepts traffic only from that entry point.
Private back end pattern
An app with virtual network integration reaching databases, caches, and storage through private endpoints, with the public access of those services disabled.
Backend-for-frontend with API apps
A web or single-page front end calls separate API apps, each in its own app or plan, so each can scale and release independently.
Queue-based background processing
The web app places work on a queue, and workers process it, which keeps the user experience fast and absorbs bursts of load.
Multi-region active-passive or active-active
Two regions with global routing and replicated data, giving resilience against regional failure and lower delay for far-apart users.
Blue-green with slots
Staging and production slots used for blue-green releases, with warm-up, smoke tests, swaps, and instant rollback.
flowchart TD
U["Users"] --> FD["Front Door with web application firewall"]
FD --> WEB["App Service: web front end"]
WEB --> API["App Service: API"]
API --> CACHE["Cache"]
API --> DB["Database via private endpoint"]
API --> Q["Queue"]
Q --> JOB["Worker: Function or WebJob"]
WEB -. identity .-> KV["Key Vault"]
API -. identity .-> KV
WEB --> AI["Application Insights"]
API --> AI
Patterns are like floor plans for shops. You can arrange a shop in a way that has been proven to work, with an entrance, a counter, a stockroom, and a security desk, instead of inventing a layout and discovering the problems after opening day.
22App Service Compared with Other Azure Hosting Options
Choosing the right host early prevents painful migrations later.
| Option | What it is | Control level | Choose it when |
|---|---|---|---|
| App Service | Managed platform for web apps and APIs | Medium | You want simple, always-ready web hosting with built-in scaling, slots, and security |
| Azure Functions | Serverless event-driven code | Lower | You have small, event-triggered pieces of logic with spiky use |
| Azure Container Apps | Serverless containers with microservice features | Medium | You use containers and want scaling to zero and microservice support without managing clusters |
| Azure Kubernetes Service | Managed Kubernetes | High | You need full container orchestration control and have the skills to run it |
| Virtual Machines | Servers you manage yourself | Highest | You need full operating system control or run unusual software |
| Azure Static Web Apps | Hosting for static front ends with serverless APIs | Lower | You build a static or single-page site with simple back-end functions |
flowchart TD
Q1{"Is it a web app or API?"}
Q1 -->|Small event-driven code| FUNC["Azure Functions"]
Q1 -->|Static site with small APIs| SWA["Static Web Apps"]
Q1 -->|Standard web app, code or container| Q2{"Need full container orchestration or special OS control?"}
Q2 -->|No| APPSVC["App Service"]
Q2 -->|Container microservices without cluster work| CA["Container Apps"]
Q2 -->|Full orchestration control| AKS["Kubernetes Service"]
Q2 -->|Full OS control| VM["Virtual Machines"]
If your application is a standard web app or API and you do not need special operating system access or container orchestration, App Service is often the simplest and cheapest-to-operate choice.
23Real-World Use Cases
See how different organizations use App Service every day.
An online store handling seasonal traffic
A retailer runs its storefront and API on App Service plans with autoscale. Traffic spikes during sales are handled by adding instances, a content delivery network serves images, and slot swaps allow releases during business hours without downtime.
A bank portal with strict security
A bank hosts an internal portal with private endpoints and access restrictions, built-in authentication tied to its corporate identity service, managed identities to Key Vault and databases, and detailed logging to a central security workspace.
A software company hosting a multi-tenant product
A company runs its product across several regions with global routing in front. Each release goes through staging slots, with canary traffic routing before the full swap.
A university running many small applications
A university places dozens of small department websites on a few shared plans, saving money, while central IT manages certificates, domains, and security settings consistently.
A healthcare provider connecting to on-premises systems
A provider’s patient app uses virtual network integration and a private connection to reach systems in its data center, with a stable outbound address that partners have approved.
A startup moving from virtual machines
A young company migrated its web servers from manually managed virtual machines to App Service, removing patching work, adding slot-based releases, and reducing both cost and outages.
24Advantages and Trade-offs
An honest look helps you decide with open eyes.
Advantages
- Fully managed platform, so no operating system patching or server administration
- Built-in scaling, with autoscale, and instance-level resilience
- Deployment slots for safe releases and instant rollback
- Managed identities, built-in authentication, and Key Vault integration
- Custom domains, managed certificates, and flexible networking options
- Many languages and container support, with strong monitoring tools
- Several apps can share one plan, which lowers cost
Disadvantages / Trade-offs
- Less control over the operating system and underlying machines than virtual machines
- Plan cost runs continuously, even when apps are idle, unless you scale down or delete
- Apps in a plan share resources, so a noisy app can affect neighbors
- Some features require higher tiers, which raises cost
- Networking choices are numerous, and inbound and outbound features are easy to confuse
- Not ideal for workloads needing custom drivers, unusual software, or advanced orchestration
25Best Practices and Mistakes to Avoid
Habits that keep your apps secure, fast, resilient, and affordable.
Use Standard or higher tiers for production
Choose tiers that provide slots, autoscale, backups, and the networking features you need, and keep Free and Basic for learning and testing.
Run at least two instances for important apps
Spread across zones where supported, and enable health checks so unhealthy instances are removed.
Release through slots and pipelines
Build once, deploy to staging, warm up, test, swap, and keep rollback ready. Avoid manual production deployments.
Design apps to be stateless
Keep sessions, files, and data in shared services so scaling out and instance replacement are safe.
Secure by default
HTTPS only, modern TLS, managed identities, Key Vault references, restricted inbound access, and private connections to data services.
Separate environments and plans
Use separate plans or subscriptions for production and non-production, so load tests and mistakes never touch live users.
Monitor everything that matters
Application Insights, diagnostic logs to a central workspace, availability tests, and alerts tied to clear owners.
Keep runtimes and dependencies current
Track end-of-support dates, update libraries, and test upgrades regularly instead of in a hurry.
Manage everything as code
Define plans, apps, settings, and networking in templates, so environments are repeatable and reviewed.
Review cost regularly
Consolidate plans, right-size, use autoscale, delete unused resources, and consider commitments for steady plans.
Problem
Storing user uploads, sessions, or other important data on the local disk or in the memory of a single instance.
Why It’s Harmful
When the app scales out, restarts, or an instance is replaced, the data is lost or visible to only some visitors, causing mysterious bugs such as users being randomly logged out.
Correct Approach
Keep state in external services such as storage accounts, databases, and shared caches, and treat each instance as disposable.
Problem
Putting production and non-production apps in the same plan, and running load tests against it.
Why It’s Harmful
Because apps share the same workers, tests or a runaway development app can consume processor and memory, slowing or crashing the production app.
Correct Approach
Separate plans, or even subscriptions, for production and non-production, and load test against a copy of the production design.
Problem
Running a single instance with no health check and no alerts for a business-critical app, and deploying straight to production by editing files.
Why It’s Harmful
Any restart, update, or failure causes visible downtime, a bad change is hard to undo, and nobody learns about problems until customers complain.
Correct Approach
Use multiple instances, health checks, slot-based releases, monitoring, and alerts, and make production changes only through reviewed pipelines.
Problem
Relying on the default settings of a new app for security and performance, such as leaving old TLS versions, plain FTP, and always-off idle behavior unchanged.
Why It’s Harmful
Defaults are designed for easy starts, not for hardened production. Weak protocols and slow cold starts show up at the worst times.
Correct Approach
Review and set security, TLS, deployment, and Always On options deliberately, and keep them in your templates.
26Frequently Asked Questions
The app is your actual web application with its code and settings. The plan is the set of virtual machines, with a region, operating system, size, and tier, on which apps run. You pay for the plan, and one plan can host several apps that share its resources.
No. Stopping an app does not stop the billing of its plan, because the plan’s machines still exist. To stop paying you need to scale the plan down to a free option where possible, or delete the plan. This is a common source of surprise charges.
A new version is deployed to a staging slot and warmed up with requests. During the swap, App Service applies production settings, makes sure the new instances respond, and then switches routing. Visitors are sent to already-warm instances, so there is usually no downtime, and the old version stays available for rollback.
No. Virtual network integration controls outbound traffic from the app into your network. To make inbound traffic private, you need access restrictions or a private endpoint, and you can disable public access. Many people confuse the two, so always check both directions.
Scale out when you need to serve more concurrent visitors or improve resilience, because it adds more workers. Scale up when each instance needs more memory or processing power, or you need features of a higher tier. Most web apps benefit from scaling out with autoscale, provided they are stateless.
Turn on a managed identity for the app, give it permission to read secrets in Key Vault, and use Key Vault references in application settings. The platform fetches the secret using the identity. Where possible, use identity-based access to databases and storage so that there is no password at all.
The app may have been unloaded because of inactivity, so the first request triggers a cold start. Turn on Always On in tiers that support it, configure warm-up paths, use health checks, and keep deployments warm using slots to reduce this effect.
Choose App Service when you have a standard web app or API and want the simplest management, with built-in scaling, slots, and security. Choose Container Apps or Kubernetes when you need microservice features, complex orchestration, or specialized container control, and you have the skills to operate them.
27Summary and Key Takeaways
Azure App Service is a managed platform for hosting web apps and APIs, where Azure looks after servers, operating systems, and runtimes, and you focus on your application. The key idea is the separation of the app from the plan: the plan defines the region, operating system, tier, size, and number of workers, and several apps can share it. Requests flow through shared front ends to your workers. Deployment slots allow warmed-up, reversible releases, while scale up, scale out, and autoscale handle growth when apps are stateless. Custom domains, managed certificates, and built-in authentication give a professional front, while managed identities and Key Vault references remove passwords. Networking has two separate directions, inbound access restrictions and private endpoints, and outbound virtual network integration. Reliability comes from multiple instances, health checks, zones, and regions, and good monitoring with Application Insights and alerts keeps you informed. Costs are driven by the plan, so consolidate, right-size, and clean up. Used with these habits, App Service is one of the quickest ways to run a secure, scalable web application in Azure.
Key Takeaways
- App versus plan — the plan is the paid set of workers and the apps run on it, so several apps can share one plan, and stopping an app does not stop plan billing.
- Choose the stack and tier on purpose — pick Windows or Linux, code or container, and a tier that provides the features you need, such as slots, autoscale, and networking options.
- Release safely with slots — deploy once to staging, warm up and test, swap into production, and keep the old version ready for instant rollback.
- Scale smartly — scale out with autoscale for traffic, scale up for memory or features, and keep the app stateless so extra instances are safe.
- Separate inbound and outbound networking — use access restrictions or private endpoints for who reaches the app, and virtual network integration for what the app reaches.
- Remove passwords — use managed identities, Key Vault references, built-in authentication, HTTPS only, and modern TLS, and disable weak deployment methods.
- Operate it like production — run at least two instances, enable health checks and zone redundancy where available, monitor with Application Insights and alerts, manage everything as code, and review cost and runtime support dates regularly.