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

1.73K 0 0 0 0

📘 Chapter 2: Deploying Applications Using Different Methods

🔍 Overview

Azure App Services supports multiple deployment methods, allowing developers to push code to production through the path that best suits their workflow—whether it's from a local machine, GitHub, Azure DevOps, VS Code, or Docker containers.

This chapter covers all supported deployment strategies, step-by-step examples, and best practices for each.


🧠 Supported Deployment Methods in Azure App Services

Method

Best Use Case

Local Git

Developers who want control over manual deployments

GitHub Actions

Automating deployments with version control triggers

Azure DevOps

Enterprise CI/CD pipelines with artifacts and testing

FTP / Zip Deploy

Quick updates or legacy workflows

Visual Studio / VS Code

Windows/.NET developers or modern JS developers

Docker / Container Registry

Container-based applications


📘 Method 1: Deploy via Local Git Repository

🔧 Setup

  1. Enable Local Git on your App:

bash

 

az webapp deployment source config-local-git \

  --name mywebapp \

  --resource-group MyResourceGroup

  1. Azure will return a Git endpoint. Add this remote to your local repo:

bash

 

git remote add azure https://mywebapp.scm.azurewebsites.net:443/mywebapp.git

  1. Push your code:

bash

 

git push azure main

️ You'll be prompted for deployment credentials (set in Azure Portal).


📘 Method 2: Deploy with GitHub Actions (CI/CD)

Advantages

  • Automatic deployment on push
  • Built-in rollbacks
  • Environment-based workflows (staging, production)

🔧 Setup via CLI

bash

 

az webapp deployment github-action add \

  --repo "username/repo-name" \

  --branch main \

  --name mywebapp \

  --resource-group MyResourceGroup \

  --login-with-github

📄 Example azure-webapps-node.yml (Auto-generated)

yaml

 

on:

  push:

    branches:

      - main

 

jobs:

  build-and-deploy:

    runs-on: ubuntu-latest

    steps:

      - uses: actions/checkout@v2

      - name: Set up Node.js

        uses: actions/setup-node@v3

        with:

          node-version: '18'

      - run: npm install

      - run: npm run build --if-present

      - uses: azure/webapps-deploy@v2

        with:

          app-name: mywebapp

          slot-name: production

          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE }}

🔐 You'll need to store the publish profile in your repo's GitHub secrets.


📘 Method 3: Azure DevOps Pipelines

When to Use

  • Enterprise-level CI/CD needs
  • Structured build + test + deploy stages
  • YAML or GUI pipeline editors

🔧 Setup:

  1. Create a new Azure DevOps Project
  2. Connect your GitHub or Azure Repos
  3. Create a new Pipeline → YAML-based
  4. Use the Azure Web App Deploy task:

yaml

 

trigger:

  - main

 

pool:

  vmImage: 'ubuntu-latest'

 

steps:

  - checkout: self

  - task: NodeTool@0

    inputs:

      versionSpec: '18.x'

  - script: |

      npm install

      npm run build

    displayName: 'Build Project'

  - task: AzureWebApp@1

    inputs:

      azureSubscription: '<azure-service-connection>'

      appName: 'mywebapp'

      package: '$(System.DefaultWorkingDirectory)/**/dist'


📘 Method 4: FTP and ZIP Deploy

FTP Deployment

  1. Go to Azure Portal → Web App → Deployment Center → FTP
  2. Note your FTP host, username, and password
  3. Use FileZilla or command line:

bash

 

ftp ftp://mywebapp@ftp.azurewebsites.windows.net

Zip Deploy

bash

 

az webapp deployment source config-zip \

  --resource-group MyResourceGroup \

  --name mywebapp \

  --src ./webapp.zip

🔁 Fast for uploading builds without needing source control.


📘 Method 5: Visual Studio and VS Code

Visual Studio (for .NET)

  1. Right-click on project → “Publish”
  2. Choose Azure App Service (Windows/Linux)
  3. Select or create a web app
  4. Click Publish

Visual Studio Code (Node.js, Python, Static Apps)

  1. Install Azure App Service extension
  2. Sign in to Azure
  3. Right-click folder → “Deploy to Web App”

VS Code automatically detects runtimes and pushes via Kudu.


📘 Method 6: Docker and Container Registry

Use Case

  • Full control over the environment
  • Dependencies bundled inside containers

🔧 Setup

  1. Create Dockerfile (Node.js example):

Dockerfile

 

FROM node:18

WORKDIR /app

COPY . .

RUN npm install

CMD ["node", "server.js"]

  1. Build and push to Azure Container Registry (ACR):

bash

 

az acr login --name myregistry

docker build -t myregistry.azurecr.io/myapp:v1 .

docker push myregistry.azurecr.io/myapp:v1

  1. Create Web App from ACR image:

bash

 

az webapp create \

  --resource-group MyResourceGroup \

  --plan MyAppServicePlan \

  --name mydockerwebapp \

  --deployment-container-image-name myregistry.azurecr.io/myapp:v1


📊 Deployment Method Comparison Table

Method

Automation

Ideal For

Setup Time

CI/CD Ready

Local Git

Manual

Small teams, hobby projects

Fast

GitHub Actions

Auto

Modern DevOps & version control

Moderate

Azure DevOps

Auto

Enterprises, structured CI/CD

Moderate

FTP/Zip

Manual

Legacy or fast patching

Fast

Visual Studio Code

Manual

Devs using VS Code for quick deploy

Fast

Docker/Containers

Semi-Auto

Custom runtimes, microservices

High


💡 Best Practices for Deployment


  • Use deployment slots for zero-downtime deployments
  • Set environment-specific variables (prod/dev/staging)
  • Monitor builds with Application Insights
  • Automate rollbacks using GitHub Actions or DevOps triggers
  • Use ARM templates or Bicep for reproducible infrastructure

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.