Deploy ASP.NET Core to Azure

Deploying an ASP.NET Core application to Azure App Service provides a reliable, scalable platform for hosting web apps. This tutorial walks you through the end‑to‑end process, from prerequisites to CI/CD with GitHub Actions.

Prerequisites

1️⃣ Create an Azure App Service

Open Azure Portal → Create a resourceWeb App. Use the following settings:

Resource group:  MyResourceGroup
Name:           my-aspnetcore-app
Publish:        Code
Runtime stack:  .NET 8
Region:         East US

Click Review + create and then Create. The deployment takes a few seconds.

2️⃣ Publish from Visual Studio

  1. Right‑click the project → Publish.
  2. Select AzureAzure App Service (Linux).
  3. Choose the App Service you just created.
  4. Click Finish then Publish.

Visual Studio builds and pushes the app. Browse to https://my-aspnetcore-app.azurewebsites.net to verify.

3️⃣ Deploy Using Azure CLI

Open a terminal and run:

az login
az webapp up --name my-aspnetcore-cli --resource-group MyResourceGroup --runtime "DOTNET|8.0"

The command creates the App Service and deploys the current folder contents.

4️⃣ CI/CD with GitHub Actions

Add a workflow file .github/workflows/azure-deploy.yml:

name: Azure Deploy
on:
  push:
    branches: [ main ]
jobs:
  build-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: Restore
      run: dotnet restore
    - name: Build
      run: dotnet publish -c Release -o ./publish
    - name: Deploy to Azure Web App
      uses: azure/webapps-deploy@v2
      with:
        app-name: my-aspnetcore-app
        slot-name: production
        publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
        package: ./publish

Store your publish profile in the repository secret AZURE_WEBAPP_PUBLISH_PROFILE. Every push to main triggers a deployment.

🔧 Troubleshooting