Deploying .NET Apps to Azure App Service

Learn deploying .NET apps to Azure App Service: az CLI zip deploy, GitHub Actions, app settings, deployment slots, health checks, and managed identity.

Executive Summary: Deploying .NET apps to Azure App Service is three moving parts: an app and its plan (the plan buys the hardware, and the cheapest tiers have real limits), a deploy step (zip from the az CLI or GitHub Actions), and configuration (app settings and connection strings as environment variables, never committed files). Deployment slots are the feature that makes the whole thing calm: deploy to staging, let the health check confirm the app is warm, swap to production with no downtime, and keep slot-specific settings from bleeding across.

The first deployment usually happens through the portal: thirty clicks, a name nobody remembers choosing, and a working app whose configuration exists nowhere but in Azure. The second deployment is when the pain starts, because nothing about it was written down. This page is the opposite path: the same result built from commands you can paste into a script and a pipeline.

Deploying .NET apps to Azure here means App Service, the managed platform for web apps: the App Service documentation is the official reference. The examples deploy the TaskApi built across this series and assume you have the az CLI authenticated.

The app runs on .NET 10, the current LTS. Confirm your app’s stack version against the platform before major upgrades, the cadence covered in the versions guide. Pricing for App Service plans changes, so this page names tiers and points at the pricing page instead of quoting numbers that rot.

I have been on both sides of a few App Service migrations, and my view is this: the platform is excellent and the portal is a trap. Do everything in commands from day one, and the portal becomes a read-only view of what your scripts already did.

The plan and the app: what you are buying

An App Service app is your web app. An App Service plan is the hardware it runs on, shared by every app you put on it. The plan choice is the pricing and capability decision:

Tier What it gives you Suited for
Free (F1) A shared instance with limits on compute minutes and custom domains (HTTPS) Experiments, nothing user-facing
Basic (B1) A dedicated instance, custom domains, manual scaling Small internal tools, proof deployments
Premium (P1v3 and up) More compute, autoscaling, deployment slots beyond the baseline Production web apps
Isolated Dedicated networking (App Service Environment) Compliance-constrained enterprise deployments

Two practical notes before choosing. Free and Basic tiers have no SLA options worth planning around and constrained slot support, so production conversations start at Premium. The numbers change; the pricing calculator is the real source, not a blog post (including this one).

Create and zip deploy with the az CLI

The infrastructure is three commands, in order:

az group create --name taskapi-rg --location westeurope

az appservice plan create --name taskapi-plan --resource-group taskapi-rg --sku P1v3 --is-linux

az webapp create --name taskapi-prod --plan taskapi-plan --resource-group taskapi-rg --runtime "DOTNETCORE:10"

The --is-linux flag is the default recommendation for .NET: Linux plans cost less for the same compute, and modern .NET runs there first-class. The runtime string pins the .NET stack your app hosts on. Verify the available stacks in your region with az webapp list-runtimes --os linux before creating the app.

Deployment is publish plus one command:

dotnet publish TaskApi.csproj -c Release -o ./publish
zip publish.zip -j ./publish/*

az webapp deploy --resource-group taskapi-rg --name taskapi-prod --src-path publish.zip
# expected output (trimmed):
Archive: publish.zip
Adding: TaskApi.dll
Adding: TaskApi.deps.json
...
Deployment has completed successfully

That zip contains the published output only, not the source, the same publish-what-you-ship principle as the container guide. The build is Release configuration on your machine (or CI), and App Service never compiles, which makes the app start faster and the deployment deterministic.

App settings and connection strings: configuration as environment

App settings arrive as environment variables, and ASP.NET Core reads environment variables into configuration by default. So no code change is needed to move values out of committed files and into Azure:

az webapp config appsettings set --name taskapi-prod --resource-group taskapi-rg \
  --settings TaskApi__DefaultOwner="imran" Jwt__Issuer="https://taskapi.example"

az webapp config connection-string set --name taskapi-prod --resource-group taskapi-rg \
  --settings TaskApi="Server=...;Database=...;" --connection-string-type SQLAzure

The double underscore (TaskApi__DefaultOwner) is how nested configuration keys are spelled in environment variables. It is the bridge between the options-pattern classes in the application and their per-environment values. Connection strings follow the same rule with a different command. Nothing belongs in appsettings.Production.json that is a secret. Committed files hold defaults, Azure holds truth, and the pattern is enforced by the settings commands being in your deployment script, not in a portal session you will forget.

Health checks: let the platform verify the app

App Service can probe a path of your choosing and treat an app that stops answering as unhealthy (removing it from load balancing, restarting it, and raising alerts). Point it at a real health endpoint rather than the homepage:

az webapp config set --name taskapi-prod --resource-group taskapi-rg \
  --health-check-path /health

The /health path is a real ASP.NET Core health check endpoint in the TaskApi, the implementation of which belongs to the Kubernetes guide in this series, which builds the endpoint once and reuses it everywhere. The health check only earns its keep if the endpoint checks something real (dependencies, beyond the process being alive). Or it will happily report a healthy app that cannot serve a single request.

Deployment slots: deploy, warm, swap

A deployment slot is a full copy of your app with its own hostname. The production flow that makes Friday deploys boring:

az webapp deployment slot create --name taskapi-prod --resource-group taskapi-rg --slot staging

# deploy the new build to staging (same commands as above, --slot staging)
# verify: https://taskapi-prod-staging.azurewebsites.net/health

az webapp deployment slot swap --name taskapi-prod --resource-group taskapi-rg \
  --slot staging --target-slot production

The swap is the point: Azure swaps the two slots’ pointers. This means production traffic starts hitting the already-running, already-warm staging instances instantly, and a failed swap is a no-op. Rollback is the same command with the slots reversed, which is the property that makes slots worth the minor complexity.

One setting makes or breaks the pattern: slot settings. Any app setting or connection string can be marked as sticking to its slot, and everything else swaps with the app. The convention is that infrastructure settings (database connection strings, external service keys) are slot settings. As a result, production always keeps its own database, while feature flags and configuration swap with the build. Mark them when creating them:

az webapp config appsettings set --name taskapi-prod --resource-group taskapi-rg \
  --slot staging --slot-settings TaskApi__DbMode="production"

Deploying from GitHub Actions

The zip deploy above is what the pipeline automates. The standard GitHub Actions setup uses the app’s publish profile, downloaded once and stored as a repository secret:

az webapp deployment list-publishing-profiles --name taskapi-prod \
  --resource-group taskapi-rg --xml > publish-profile.xml
name: deploy
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@<full-commit-sha>  # v5 (resolve the current SHA)

      - name: Setup .NET
        uses: actions/setup-dotnet@<full-commit-sha>  # v5 (resolve the current SHA)
        with:
          dotnet-version: '10.0.x'

      - run: dotnet publish TaskApi.csproj -c Release -o ./publish

      - name: Deploy to staging
        uses: azure/webapps-deploy@<full-commit-sha>  # v3 (resolve the current SHA)
        with:
          app-name: taskapi-prod
          slot-name: staging
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISH_PROFILE }}
          package: ./publish

Pin every third-party action to a full commit SHA with the version in a comment, as shown. Tags are mutable and a pinned SHA is what makes the pipeline reviewable and reproducible. The GitHub Actions deployment guide documents the publish profile and its permissions, and the full pipeline (test before deploy, migrations before the swap) is built end to end in this series’ CI/CD guide.

Managed identity at orientation level

App Service can have its own identity in Entra ID, so Azure resources can trust “this app” instead of a stored credential. Assign it with one command (az webapp identity assign), grant that identity access to the resource (Key Vault, SQL database, storage), and the app authenticates as itself. The deep configuration of identity and Key Vault references is beyond this page’s scope. What matters at orientation is the direction: fewer secrets stored, fewer secrets rotated, and connection strings that contain no passwords at all.

How real systems do this

  • Infrastructure as code, portal as a viewer. Every command in this page runs from Bicep or Terraform in the repository. The portal is where you read state, and any change made by hand is treated as drift to reconcile.
  • Migrations run before the swap. The pipeline applies EF Core migrations as a step against the production database before swapping the slot in, the pattern covered in the migrations guide. So the new code never starts against an old schema.
  • Staging gets the full production shape. The slot’s configuration matches production (minus slot-sticky secrets). As a result, “works in staging” predicts “works after the swap”, and the health check gate is part of the pipeline, not a human’s memory.

A review I remember well caught a committed appsettings.Production.json containing a working production connection string, “temporarily”, during the first deploy. The repository had contractor access, and the string had been there for weeks by the time it was noticed in a pull request diff. The fix was small: delete the file, set the values with the app settings commands, and add a CI check that fails on secrets in committed configuration. The lesson: the first deploy is when configuration habits are set. The portal-clicking version of that week leaves its habits in the worst place, the repository.

Decision framework: choosing the App Service shape

  1. Is this production or an experiment? Production starts at Premium (slots, autoscale, SLA). Experiments can live on Free or Basic, and the tier upgrade is one command, not a rewrite.
  2. Zip deploy, GitHub Actions, or container? Pipeline-less manual deploys: zip. Repository-driven deploys: Actions with the publish profile. You are already building container images: deploy the image (the platform can run containers, or the Kubernetes track applies). Image build and push specifics belong to the container guides in this series.
  3. How many slots? Staging at minimum; a third for a hot rollback target costs little. Each slot must be governed by the same slot-settings convention or swaps carry surprises.
  4. Does the health check tell the truth? A health path that returns 200 while the database is down lies to the platform. Wire it to real dependency checks.
  5. Which settings stick to a slot? Decide at creation time: infrastructure and secrets stick, build-delivered configuration swaps. Document the convention once, in the deployment script.

When NOT to choose App Service

  • You need container orchestration. Multiple services, autoscaling policies, and rolling updates across many apps are Kubernetes’ home turf. The .NET in Kubernetes guide covers that path.
  • Long-running background processing. App Service is built around HTTP. Dedicated worker services deploy better as containers or platform worker runtimes than they do as a web app that happens to host a loop.
  • Free-tier production. The price is attractive and the constraints (cold starts, CPU limits, no slot story) are not survivable for user-facing services. Use Free for demos only.

Common mistakes

  • Portal-only configuration. Settings made by hand drift from the script and vanish on the next automation run. The commands in this page belong in the deployment script from day one.
  • Secrets in committed files. Production values in appsettings.Production.json are repository leaks waiting for a reader. Settings and connection strings live in Azure, or better, behind managed identity.
  • Swapping without slot settings. Everything swaps by default, including configuration. The slot-sticky flag on connection strings is what keeps production pointed at production’s database.
  • A health check that checks nothing. The homepage as a health path proves the process answers HTTP, not that the app works; check dependencies.
  • Skipping the runtime check. Creating the app on an older stack than the code targets fails at startup; az webapp list-runtimes first, then create.
  • Deploying without running migrations. The swap brings code that expects schema the database does not have. Migrations run as a pipeline step before promotion.

App Service is not the only way to run on Azure. My write-up on high-availability WordPress on Azure shows a different workload on the same cloud.

Key takeaways

  • An app runs on a plan. The plan is the pricing and capability decision, production starts at Premium, and the pricing page is the source of truth for numbers.
  • Three commands create the infrastructure; dotnet publish plus az webapp deploy ships the build, with no compilation in Azure.
  • App settings and connection strings are environment variables (__ for nesting) set by the az CLI, never secrets in committed files.
  • Slots make deploys boring: deploy to staging, verify on its hostname, swap, and reverse the swap to roll back. Slot-sticky settings keep infrastructure from moving.
  • Point the platform health check at a real endpoint, and let the pipeline deploy via GitHub Actions with publish-profile auth and SHA-pinned actions.
  • Managed identity is the direction that removes stored credentials entirely; check the available .NET stack with az webapp list-runtimes before creating apps.

FAQ

How do I deploy a .NET app to Azure App Service?

Create a resource group, an App Service plan, and a web app with the az CLI. Then publish your project and deploy the zip with az webapp deploy. In a pipeline, the same deploy runs from GitHub Actions using the app’s publish profile as a secret. Verify with the app’s health path before pointing anything else at it.

Which App Service plan should I choose?

Free and Basic for experiments and internal tools. Premium for production, because that is where autoscaling, the SLA, and the full deployment slot story live. The compute tier can be changed later with one command. So start with the smallest tier that has the features you need and scale on measurement. Check current prices on the Azure pricing page rather than any article’s numbers.

What are App Service deployment slots?

Live copies of your app with their own hostnames. You deploy to a staging slot, verify it on its URL, and then swap it with production, which switches the traffic instantly with no restart. Swapping back is the rollback. Settings marked as slot settings stay with their slot, so connection strings can stick to production while the build configuration swaps.

How do App Service app settings work in ASP.NET Core?

They are injected as environment variables. The default configuration provider reads environment variables into your options classes, with double underscores mapping to nested keys (TaskApi__DefaultOwner becomes TaskApi:DefaultOwner). Set them with az webapp config appsettings set, keep secrets out of committed files, and prefer managed identity so fewer secrets exist at all.

What is managed identity for App Service?

An identity for the app itself in Entra ID, assigned with az webapp identity assign and granted access to resources like Key Vault or a SQL database. The app then authenticates as itself without stored credentials. At orientation level: it is the direction that removes connection strings containing passwords from your configuration.

Deploy with commands, promote with swaps

App Service rewards the same discipline the rest of this series does: commands in the repository, configuration as environment, verification by health endpoint, and promotion by swap. Build the CLI script once, let the pipeline run it, and the portal becomes what it should have been all along, a read-only view of a deployment you can reproduce from a clean checkout. The last stops in this series: running .NET in Kubernetes and the CI/CD pipelines that tie everything together, and every guide lives on the .NET series index. The rule of thumb: if the deployment cannot be rebuilt by pasting commands into a terminal, it does not exist yet.

Last updated on 29 November 2026

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *