Monday, 26 October 2026

What is Azure App Service, and how do you deploy a .NET application to it?

Azure App Service

Azure App Service is Microsoft's fully managed platform-as-a-service (PaaS) for hosting web apps, REST APIs, and mobile backends. You supply the code (or a container), and Azure handles the servers, OS patching, load balancing, and scaling.

Key features:

  • Runtimes: .NET, Java, Node.js, Python, PHP, or custom containers
  • Scaling: manual or autoscale, up and out, based on rules or schedules
  • Deployment slots: staging environments you can swap into production with no downtime (Standard tier and above)
  • Built-in extras: custom domains, free managed TLS certificates, authentication (Entra ID, social logins), VNet integration, and Application Insights monitoring
  • App Service Plan: the underlying compute (region, VM size, and tier) that one or more apps share. You pay for the plan, not per app.

Deploying a .NET app

Option 1: Azure CLI (quickest)

From your project folder:

az login

# Create resource group, plan, and web app
az group create --name my-rg --location centralindia
az appservice plan create --name my-plan --resource-group my-rg --sku B1
az webapp create --name my-unique-app-name --resource-group my-rg \
  --plan my-plan --runtime "dotnet:8"

# Deploy straight from source (builds and publishes for you)
az webapp up --name my-unique-app-name --resource-group my-rg

Check which runtime strings are available with az webapp list-runtimes, and pick the one matching your project's target framework. If az webapp up doesn't suit your setup, publish a zip instead:

dotnet publish -c Release -o ./publish
cd publish && zip -r ../app.zip .
az webapp deploy --resource-group my-rg --name my-unique-app-name \
  --src-path ../app.zip --type zip

Option 2: Visual Studio or VS Code

  • Visual Studio: right-click the project → Publish → Azure → Azure App Service, then pick or create the app and click Publish.
  • VS Code: install the Azure App Service extension, sign in, right-click your app under the extension's tree, and choose Deploy to Web App.

Option 3: CI/CD with GitHub Actions (recommended for real projects)

In the Azure Portal, open your app → Deployment Center → choose GitHub, and it generates a workflow for you. A typical one looks like:

name: Deploy to Azure
on:
  push:
    branches: [main]

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '8.0.x'
      - run: dotnet publish -c Release -o ./publish
      - uses: azure/login@v2
        with:
          client-id: ${{ secrets.AZURE_CLIENT_ID }}
          tenant-id: ${{ secrets.AZURE_TENANT_ID }}
          subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
      - uses: azure/webapps-deploy@v3
        with:
          app-name: my-unique-app-name
          package: ./publish

Azure DevOps Pipelines work similarly using the AzureWebApp task.

After deploying

  • Configuration: set connection strings and secrets under Settings → Environment variables (they override appsettings.json). For secrets, use Azure Key Vault references.
  • Logs: enable App Service logs, or stream them with az webapp log tail.
  • Safer releases: deploy to a staging slot first, test it, then swap.
  • Health checks: configure a health check path so unhealthy instances are removed from rotation.


No comments:

Post a Comment

Note: only a member of this blog may post a comment.