Deploying Web Apps with Azure App Services: A Complete Beginner's Guide

5.72K 0 0 0 0

📘 Chapter 1: Introduction to Azure App Services and Setup

🔍 Overview

Deploying modern web applications requires speed, security, scalability, and minimal infrastructure overhead. Microsoft Azure App Services provides exactly that—a fully managed Platform-as-a-Service (PaaS) solution to host web apps, REST APIs, and backend services with support for multiple languages and frameworks.

This chapter introduces you to Azure App Services, walks you through setting up your environment, and guides you step-by-step to creating your first web app on Azure.


🧠 What is Azure App Service?

Azure App Service is a cloud platform for building and hosting web apps in a fully managed environment. You don't have to worry about infrastructure, patching, or scaling. Instead, focus on code, configuration, and continuous delivery.

Key Features

  • Host web apps, APIs, backend services, or containers
  • Supports .NET, Java, Node.js, Python, PHP, Ruby
  • Built-in autoscaling, load balancing, and SSL
  • Seamless CI/CD integration with GitHub, Azure DevOps
  • Built-in authentication, monitoring, and backup

🧱 App Service Architecture Overview

Component

Description

App Service Plan

Defines compute resources for one or more apps

Web App

The actual application hosted within the plan

Deployment Slot

Staging/testing environment with quick swap feature

Resource Group

Logical container for Azure resources


🛠️ Step 1: Set Up Azure Environment

Before deploying, you need:

  • An Azure subscription (Free Tier available)
  • Azure CLI or Azure Portal access
  • (Optional) Visual Studio Code or Visual Studio

Install Azure CLI

bash

 

# Windows/macOS/Linux

https://learn.microsoft.com/en-us/cli/azure/install-azure-cli

Log in:

bash

 

az login


📦 Step 2: Create a Resource Group

A resource group is a logical container for resources like your web app, app service plan, and database.

bash

 

az group create --name MyResourceGroup --location eastus

Parameter

Description

--name

Resource group name

--location

Azure region (e.g., eastus, westus2)


️ Step 3: Create an App Service Plan

The App Service Plan determines the pricing tier, OS, and performance level.

bash

 

az appservice plan create --name MyAppServicePlan \

  --resource-group MyResourceGroup \

  --sku B1 --is-linux

Tier

Description

Cost

F1

Free (shared)

$0

B1

Basic (dedicated)

~$13/month

P1V2

Premium (autoscale, high perf)

~$70+/mo


🌐 Step 4: Create Your Web App

Now create your actual web app linked to the plan:

bash

 

az webapp create --resource-group MyResourceGroup \

  --plan MyAppServicePlan \

  --name myfirstwebapp123 \

  --runtime "NODE|18-lts"

Replace myfirstwebapp123 with a globally unique name.

💡 Runtime Options

Runtime

Value Example

Node.js

`NODE

Python

`PYTHON

Java (Tomcat)

`JAVA

.NET Core

`DOTNETCORE


🚀 Step 5: Deploy Your Code

Option A: Deploy via Local Git

bash

 

az webapp deployment source config-local-git \

  --name myfirstwebapp123 \

  --resource-group MyResourceGroup

Azure will return a Git URL. Push your code using:

bash

 

git remote add azure <GIT-URL>

git push azure main

Option B: Deploy via ZIP Package

bash

 

az webapp deployment source config-zip \

  --resource-group MyResourceGroup \

  --name myfirstwebapp123 \

  --src path/to/yourapp.zip


🔄 Step 6: Test Your Web App

Open your browser:

text

 

https://myfirstwebapp123.azurewebsites.net

Your app should be live!


🔧 Step 7: Configure App Settings and Environment Variables

You can configure environment-specific settings:

bash

 

az webapp config appsettings set \

  --name myfirstwebapp123 \

  --resource-group MyResourceGroup \

  --settings NODE_ENV=production API_KEY=123456

🔒 For secrets, use Azure Key Vault.


🔐 Step 8: Enable HTTPS and Custom Domain

HTTPS

Azure enables HTTPS by default. To enforce HTTPS:

bash

 

az webapp update \

  --name myfirstwebapp123 \

  --resource-group MyResourceGroup \

  --set httpsOnly=true

Custom Domain (via Portal)

  1. Go to your App in Azure Portal
  2. Navigate to “Custom Domains”
  3. Add your domain (verify via TXT/CNAME)
  4. Bind SSL certificate

📊 Step 9: Monitor and Diagnose Issues

Enable Application Insights for real-time performance monitoring.

bash

 

az monitor app-insights component create \

  --app MyInsights \

  --location eastus \

  --resource-group MyResourceGroup \

  --application-type web

Then connect it to your web app:

bash

 

az webapp config appsettings set \

  --resource-group MyResourceGroup \

  --name myfirstwebapp123 \

  --settings APPINSIGHTS_INSTRUMENTATIONKEY=<your-key>


📋 Summary Table – Azure App Service Setup Steps


Step

Tool/Command

Create Resource Group

az group create

Create App Service Plan

az appservice plan create

Create Web App

az webapp create

Deploy Code

git push or az webapp deployment source config-zip

Configure Settings

az webapp config appsettings set

Enforce HTTPS

az webapp update --set httpsOnly=true

Monitor App

az monitor app-insights

Back

FAQs


❓1. What is Azure App Service?

Answer:
Azure App Service is a fully managed Platform as a Service (PaaS) from Microsoft that allows you to host web applications, RESTful APIs, and mobile backends. It supports various languages like .NET, Node.js, Python, Java, and PHP.

❓2. What types of applications can I deploy on Azure App Service?

Answer:
You can deploy web apps (e.g., React, Angular, .NET MVC), APIs (Node.js, Flask, Express), static sites, background jobs, and containerized applications. Azure App Service supports both Linux and Windows environments.

❓3. Does Azure App Service support custom domains and SSL?

Answer:
Yes. You can map a custom domain to your web app and enable HTTPS using either App Service-managed SSL certificates or your own custom certificates.

❓4. How do I deploy my application to Azure App Service?

Answer:
You can deploy using:

  • Visual Studio or VS Code
  • Azure CLI (az webapp deploy)
  • GitHub Actions or Azure DevOps
  • FTP/Zip deploy
  • Docker and Azure Container Registry

❓5. Can Azure App Service scale automatically?

Answer:
Yes. App Services can scale vertically (increase compute resources) or horizontally (add instances). Autoscaling rules can be based on CPU usage, memory, or HTTP queue length.

❓6. What is the difference between App Service Plan and App Service?

Answer:
An App Service Plan defines the region, OS, pricing tier, and resource allocation (CPU/RAM) for one or more web apps. The App Service is the actual web application hosted within that plan.

❓7. How does deployment slot swapping work?

Answer:
Deployment slots (e.g., staging, production) allow you to deploy your app to a staging environment, test it, and then swap it into production without downtime.

❓8. What pricing options are available for App Services?

Answer:
Azure App Services offer:

  • Free Tier: for learning and testing
  • Shared and Basic: for small workloads
  • Standard and Premium: for production apps with scaling, staging, and high availability
    Pricing depends on compute size, number of instances, and features.



❓9. Is Azure App Service secure?

Answer:
Yes. It offers built-in security features such as HTTPS, DDoS protection, Azure Active Directory authentication, integration with Azure Key Vault, and compatibility with Azure Defender.

❓10. Can I use Azure App Service for CI/CD?

Answer:
Absolutely. Azure App Service integrates with GitHub, Bitbucket, and Azure DevOps for automated deployments and pipelines. It also supports custom scripts and Docker builds.