Skip to main content

How to Deploy ASP.NET Core to Azure App Service (2026)

Learn how to deploy your ASP.NET Core app to Azure App Service in 10 minutes. Step-by-step C# tutorial with CLI, CI/CD, and best practices. Start now!

Learning how to deploy ASP.NET Core to Azure App Service is one of the most valuable skills a .NET developer can have in 2026. Azure App Service is a fully managed platform-as-a-service (PaaS) that lets you host web apps, REST APIs, and backends without managing servers, patching operating systems, or configuring load balancers. In this hands-on tutorial, you'll deploy a working ASP.NET Core app to the cloud in about 10 minutes — using the .NET CLI, the Azure CLI, Visual Studio, and a fully automated GitHub Actions CI/CD pipeline.

By the end of this guide you'll understand not just how to ship your app, but why each step matters — including configuration, connection strings, logging, and the common pitfalls that trip up developers when they first deploy ASP.NET Core to Azure App Service.

What Is Azure App Service and Why Use It?

Azure App Service is Microsoft's managed hosting platform for web applications. Instead of provisioning a virtual machine and installing the .NET runtime, IIS, and security updates yourself, you hand Azure a compiled app and it runs it for you. This is why thousands of teams choose Azure App Service deployment over raw VMs.

  • Zero infrastructure management — Azure handles OS patching, runtime updates, and scaling.
  • Built-in autoscaling — scale out to more instances automatically under load.
  • Deployment slots — push to a "staging" slot, test it, then swap into production with zero downtime.
  • First-class .NET support — App Service is built and tuned by Microsoft for ASP.NET Core.
  • Integrated CI/CD — connect GitHub, Azure DevOps, or Bitbucket for continuous deployment.

For most web apps and APIs, this PaaS model removes weeks of DevOps work, which is exactly why "deploy ASP.NET Core to Azure App Service" is such a high-traffic search among USA, UK, and Indian developers.

Prerequisites Before You Deploy

Make sure you have these installed and ready:

  • The .NET 8 SDK (or .NET 9) — check with dotnet --version.
  • An Azure account — the free tier (F1) is enough to follow along.
  • The Azure CLI — verify with az --version.
  • Optionally, Visual Studio 2022/2026 or VS Code with the C# Dev Kit.

Step 1: Create a Sample ASP.NET Core App

If you already have an app, skip ahead. Otherwise, spin up a minimal API in seconds:

// Create a new minimal web API and run it locally
// Run these in your terminal:
//   dotnet new webapi -n AzureDemoApi
//   cd AzureDemoApi
//   dotnet run

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () => "Hello from ASP.NET Core on Azure App Service!");

app.MapGet("/health", () => Results.Ok(new { status = "healthy", time = DateTime.UtcNow }));

app.Run();

Confirm it works at https://localhost:5001 before deploying. The /health endpoint is a best practice — Azure can use it for health checks and you can use it to confirm a successful deployment.

Step 2: Sign In and Create Azure Resources with the CLI

The fastest, most repeatable way to deploy ASP.NET Core to Azure App Service is the Azure CLI. First, authenticate:

// Sign in to Azure (opens a browser)
//   az login

// Create a resource group (a logical container for your resources)
//   az group create --name rg-azuredemo --location eastus

// Create an App Service plan (the compute tier that runs your app)
//   az appservice plan create \
//     --name plan-azuredemo \
//     --resource-group rg-azuredemo \
//     --sku B1 \
//     --is-linux

// Create the Web App itself, targeting the .NET 8 runtime
//   az webapp create \
//     --name azuredemo-app-2026 \
//     --resource-group rg-azuredemo \
//     --plan plan-azuredemo \
//     --runtime "DOTNETCORE:8.0"

Why these three resources? The resource group groups everything so you can delete it all in one command later. The App Service plan defines the pricing tier and the underlying VM size (B1 is a cheap "Basic" tier; use F1 for free). The web app is your actual deployment target. Note that your --name must be globally unique because it becomes part of https://<name>.azurewebsites.net.

Step 3: Publish and Deploy Your App

Now build a production-ready release and push it to Azure. The dotnet publish command compiles your app and bundles its dependencies:

// Build a release-mode publish output
//   dotnet publish -c Release -o ./publish

// Zip the published output (PowerShell)
//   Compress-Archive -Path ./publish/* -DestinationPath ./app.zip -Force

// Deploy the zip to Azure App Service
//   az webapp deploy \
//     --resource-group rg-azuredemo \
//     --name azuredemo-app-2026 \
//     --src-path ./app.zip \
//     --type zip

That's it. Within a minute or two, your app is live at https://azuredemo-app-2026.azurewebsites.net. Visit the /health endpoint to confirm. This "zip deploy" approach is reliable, fast, and works identically across Windows, macOS, and Linux build agents.

Alternative: Deploy from Visual Studio

If you prefer a GUI, right-click your project in Visual Studio and choose Publish → Azure → Azure App Service (Linux/Windows). Visual Studio walks you through selecting (or creating) the web app and pushes the build with one click. This is the easiest path for beginners, though the CLI is better for teams and automation.

Step 4: Configure App Settings and Connection Strings

Never hardcode secrets in appsettings.json. Azure App Service injects configuration as environment variables, which ASP.NET Core's configuration system reads automatically. Set them via the CLI:

// Set an app setting (becomes an environment variable in the app)
//   az webapp config appsettings set \
//     --resource-group rg-azuredemo \
//     --name azuredemo-app-2026 \
//     --settings "ApiKey=super-secret-value" "Features__EnableCache=true"

// In your C# code, read it normally — no Azure-specific code required:
public class WeatherService
{
    private readonly string _apiKey;

    public WeatherService(IConfiguration config)
    {
        // Reads from Azure App Settings in the cloud,
        // or appsettings.json / user secrets locally.
        _apiKey = config["ApiKey"]
            ?? throw new InvalidOperationException("ApiKey is not configured.");
    }
}

Notice the double underscore (Features__EnableCache). Azure maps __ to the : hierarchy separator, so it becomes Features:EnableCache in your configuration. For production secrets, the gold standard is Azure Key Vault combined with a managed identity — your app authenticates to Key Vault without storing any credentials at all.

Step 5: Automate Deployment with GitHub Actions CI/CD

Manual deploys are fine for learning, but real teams want every push to main to deploy automatically. Here's a minimal GitHub Actions workflow that builds and deploys your ASP.NET Core app to Azure App Service on every commit:

// .github/workflows/deploy.yml
//
// name: Deploy to Azure App Service
// on:
//   push:
//     branches: [ main ]
//
// jobs:
//   build-and-deploy:
//     runs-on: ubuntu-latest
//     steps:
//       - uses: actions/checkout@v4
//
//       - name: Setup .NET
//         uses: actions/setup-dotnet@v4
//         with:
//           dotnet-version: '8.0.x'
//
//       - name: Publish
//         run: dotnet publish -c Release -o ./publish
//
//       - name: Deploy to Azure
//         uses: azure/webapps-deploy@v3
//         with:
//           app-name: azuredemo-app-2026
//           publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE }}
//           package: ./publish

To get the publish profile, run az webapp deployment list-publishing-profiles --name azuredemo-app-2026 --resource-group rg-azuredemo --xml and store the output as a GitHub secret named AZURE_PUBLISH_PROFILE. Now every merge to main triggers an automated build-and-deploy — true continuous deployment with zero manual steps.

Best Practices for Azure App Service Deployment

  • Use deployment slots. Deploy to a staging slot, smoke-test it, then "swap" it into production. The swap is instant and gives you instant rollback if something breaks.
  • Enable Application Insights. It gives you live metrics, distributed tracing, and exception logging with almost no code changes.
  • Always set ASPNETCORE_ENVIRONMENT. App Service defaults to Production, which disables the developer exception page — exactly what you want in the cloud.
  • Use Linux plans for cost and speed. Linux App Service plans are typically cheaper and start faster than Windows for ASP.NET Core workloads.
  • Turn on "Always On" for non-free tiers so your app doesn't cold-start after idle periods.
  • Store secrets in Key Vault, never in source control or plain app settings.

Common Pitfalls (and How to Avoid Them)

  • HTTP 500.30 startup errors. Almost always a runtime version mismatch or a missing config value. Check the Log Stream in the Azure Portal with az webapp log tail to see the real exception.
  • Forgetting to publish in Release mode. Deploying a Debug build ships slower, larger binaries. Always use -c Release.
  • Connection strings not found. Remember the __ separator and confirm settings actually saved with az webapp config appsettings list.
  • Cold starts on free/shared tiers. F1 and D1 tiers unload your app when idle. Upgrade to B1+ and enable "Always On" for production APIs.
  • Wrong runtime stack. If you target .NET 9 but created the app with DOTNETCORE:8.0, it won't start. Match the runtime to your project's target framework.

How to Clean Up Resources

To avoid surprise charges after testing, delete everything in one command — this is why we put it all in one resource group:

// Deletes the resource group and every resource inside it
//   az group delete --name rg-azuredemo --yes --no-wait

Conclusion: Key Takeaways

You've now seen end-to-end how to deploy ASP.NET Core to Azure App Service — from creating resources with the Azure CLI, to publishing your app, configuring secrets, and wiring up automated CI/CD with GitHub Actions. Azure App Service removes the heavy lifting of server management so you can focus on shipping features.

Here's what to remember:

  • Azure App Service is a managed PaaS — perfect for ASP.NET Core web apps and APIs.
  • The fastest deployment path is dotnet publish + az webapp deploy, which works in under 10 minutes.
  • Use environment variables and Key Vault for configuration — never hardcode secrets.
  • Adopt deployment slots, Application Insights, and "Always On" for production-grade reliability.
  • Automate with GitHub Actions so every push deploys safely and repeatably.

With these fundamentals, you're ready to confidently deploy your ASP.NET Core app to Azure App Service and scale it as your traffic grows. Bookmark this tutorial, fire up the Azure CLI, and ship your first cloud deployment today.

About csharp-coder.com
Your go-to resource for C#, .NET, and modern software development. Follow along for daily tutorials, tips, and real-world examples.

Comments

Popular posts from this blog

Angular 14 CRUD Operation with Web API .Net 6.0

How to Perform CRUD Operation Using Angular 14 In this article, we will learn the angular crud (create, read, update, delete) tutorial with ASP.NET Core 6 web API. We will use the SQL Server database and responsive user interface for our Web app, we will use the Bootstrap 5. Let's start step by step. Step 1 - Create Database and Web API First we need to create Employee database in SQL Server and web API to communicate with database. so you can use my previous article CRUD operations in web API using net 6.0 to create web API step by step. As you can see, after creating all the required API and database, our API creation part is completed. Now we have to do the angular part like installing angular CLI, creating angular 14 project, command for building and running angular application...etc. Step 2 - Install Angular CLI Now we have to install angular CLI into our system. If you have already installed angular CLI into your system then skip this step.  To install angular CLI ope...

Angular 14 : 404 error during refresh page after deployment

In this article, We will learn how to solve 404 file or directory not found angular error in production.  Refresh browser angular 404 file or directory not found error You have built an Angular app and created a production build with ng build --prod You deploy it to a production server. Everything works fine until you refresh the page. The app throws The requested URL was not found on this server message (Status code 404 not found). It appears that angular routing not working on the production server when you refresh the page. The error appears on the following scenarios When you type the URL directly in the address bar. When you refresh the page The error appears on all the pages except the root page.   Reason for the requested URL was not found on this server error In a Multi-page web application, every time the application needs to display a page it has to send a request to the web server. You can do that by either typing the URL in the address bar, clicking on the Me...

Send an Email via SMTP with MailKit Using .NET 6

How to Send an Email in .NET Core This tutorial show you how to send an email in .NET 6.0 using the MailKit email client library. Install MailKit via NuGet Visual Studio Package Manager Console: Install-Package MailKit How to Send an HTML Email in .NET 6.0 This code sends a simple HTML email using the Gmail SMTP service. There are instructions further below on how to use a few other popular SMTP providers - Gmail, Hotmail, Office 365. // create email message var email = new MimeMessage(); email.From.Add(MailboxAddress.Parse("from_address@example.com")); email.To.Add(MailboxAddress.Parse("to_address@example.com")); email.Subject = "Email Subject"; email.Body = new TextPart(TextFormat.Html) { Text = "<h1>Test HTML Message Body</h1>" }; // send email using var smtp = new SmtpClient(); smtp.Connect("smtp.gmail.com", 587, SecureSocketOptions.StartTls); smtp.Authenticate("[Username]", "[Password]"); smtp.Se...