Skip to main content
Microsoft Azure
CHAPTER 09

Azure App Service

Updated: May 15, 2026
25 min read

# CHAPTER 9

Azure App Service

1. Introduction

Managing Virtual Machines requires constant maintenance: patching Windows or Linux, installing web server software (IIS/Nginx), and configuring network security. If you are a software developer, you want to write code, not manage infrastructure. Azure App Service is a fully managed Platform as a Service (PaaS). It allows you to simply upload your C#, Java, Python, or Node.js code, and Azure autonomously provisions the servers, configures the load balancers, and handles the OS updates invisibly. In this chapter, we will deploy a web application without ever touching a command line.

2. Learning Objectives

By the end of this chapter, you will be able to:
  • Define Platform as a Service (PaaS) and its developer benefits.
  • Differentiate between an App Service and an App Service Plan.
  • Deploy a web application via the Azure Portal.
  • Understand Autoscaling (Scale up vs. Scale out).
  • Utilize Deployment Slots for zero-downtime updates.

3. Beginner-Friendly Explanation

Imagine opening a restaurant.
  • IaaS (Virtual Machines): You rent an empty building. You have to build the kitchen, buy the stoves, hire the plumbers, and cook the food.
  • PaaS (App Service): You rent a fully staffed, fully equipped kitchen. You literally just walk in and hand them your recipe (your Code). They cook the food perfectly every time. You don't have to worry about fixing the stoves or cleaning the floors.

4. App Service vs. App Service Plan

This is the most confusing concept for beginners. They are two separate resources that work together:
  • App Service Plan (The Hardware): This represents the invisible underlying servers. You choose the pricing tier (e.g., "I want 2 cores and 4GB of RAM"). *You pay for the Plan.*
  • App Service (The App): This is your actual website code running *on top* of the Plan.

*Crucial Architecture Note:* You can run 5 different web apps on a single App Service Plan! They will all share the CPU and RAM of that plan, saving you massive amounts of money.

5. Deployment Slots (Blue/Green Deployments)

When you update a website on a Virtual Machine, you usually have to take the site offline for 5 minutes. App Service offers Deployment Slots.
  1. 1. Your live website is running in the "Production" slot.
  1. 2. You create a "Staging" slot. It gets a hidden URL (e.g., myapp-staging.azurewebsites.net).
  1. 3. You upload your new, risky code update to the Staging slot. You test it secretly.
  1. 4. When you are happy, you click "Swap". Azure instantly flips the routing. Staging becomes Production, and Production becomes Staging, with Zero Downtime. If the new code breaks, you just click Swap again to instantly roll back!

6. Mini Project: Deploy a PHP Web App

Let's launch a live website in 60 seconds.

Step-by-Step Tutorial:

  1. 1. In the Azure Portal, search for App Services.
  1. 2. Click + Create > Web App.
  1. 3. Resource group: rg-webapp-demo.
  1. 4. Name: Give it a globally unique name (e.g., my-cool-php-app-1234).
  1. 5. Publish: Choose Code.
  1. 6. Runtime stack: Select PHP 8.2 (or Node.js, or .NET).
  1. 7. Operating System: Linux.
  1. 8. Region: East US.
  1. 9. Pricing plan: Azure creates a new Plan automatically. Click "Explore pricing plans" and select the Free (F1) tier so we don't get charged!
  1. 10. Click Review + create, then Create. Wait 1 minute.
  1. 11. Go to the resource. Click the Default domain URL (e.g., my-cool-php-app-1234.azurewebsites.net).
  1. 12. *The Result:* You are looking at the default Azure splash page! Your PaaS infrastructure is live. From here, you can connect your GitHub repository, and every time you push code to GitHub, Azure will automatically deploy it to this URL.

7. Real-World Scenarios

A startup builds a highly successful Node.js application on App Service. On Monday, they average 100 users. On Friday, they get featured on national television and expect 10,000 users. Because they are on PaaS, they do not need to build new servers. They simply navigate to the App Service Plan and configure Autoscaling (Scale Out). They set a rule: "If CPU hits 70%, automatically add 5 more server instances. When CPU drops below 30%, remove them." Azure handles the scaling autonomously, saving the startup from crashing on live TV.

8. Best Practices

  • Environment Variables: Never hardcode database passwords in your GitHub repository! In the App Service menu under "Configuration", you can securely enter your passwords as "Application Settings". Azure securely injects them into your code at runtime.

9. Cost Optimization Tips

  • Consolidate Apps: If your company has 10 small, low-traffic internal web apps, do not put them on 10 different App Service Plans! Put all 10 apps onto a single Standard App Service Plan. They will share the compute resources, and you will only pay one flat monthly fee.

10. CLI Examples

To deploy a Web App using the Azure CLI:
bash
1234
az webapp up \
  --resource-group rg-webapp-demo \
  --name my-cli-app-9988 \
  --runtime "NODE:18LTS"

11. Exercises

  1. 1. Explain the financial and operational benefits of PaaS (App Service) compared to IaaS (Virtual Machines).
  1. 2. What is the architectural relationship between an App Service and an App Service Plan?

12. FAQs

Q: Does App Service give me an SSL Certificate automatically? A: Yes! By default, your azurewebsites.net domain is fully secured with HTTPS. Furthermore, Azure now offers Free Managed Certificates if you bring your own custom domain (like mycompany.com).

13. Interview Questions

  • Q: Describe the mechanics of a "Blue/Green Deployment" utilizing Azure App Service Deployment Slots. How does this feature mitigate risk during production releases?
  • Q: Explain the difference between "Scaling Up" (Vertical) and "Scaling Out" (Horizontal) within an Azure App Service Plan. Which method provides true High Availability?

14. Summary

In Chapter 9, we elevated our infrastructure by abstracting the Operating System. We embraced Azure App Service as a powerful PaaS solution, allowing developers to focus entirely on application code rather than server patching. We distinguished the billing container (App Service Plan) from the application itself, configured autonomous scaling to handle traffic spikes, and mitigated deployment risk by utilizing Deployment Slots for zero-downtime releases.

15. Next Chapter Recommendation

App Service is fantastic for simple web apps. But what if your application is incredibly complex, consisting of 20 different microservices built in different languages? We need a more advanced orchestration platform. Proceed to Chapter 10: Azure Kubernetes Service (AKS).

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·