How do I fix an issue where deployed .NET 8 API to Azure App Service is just showing placeholder page and is not working?

Jordan 20 Reputation points
2024-07-21T04:35:36.3066667+00:00

I am trying to deploy a simple .NET 8 API to Azure App Service using the Github CICD which I setup from the App Service deployment center. After the initial setup, the Github Action ran successfully and in the overview I can see that the deployment was successful, however, when I go to the app url, I just see the generic placeholder page "Your web app is running and waiting for your content" and I cannot reach the swagger documentation and I cant hit any of my endpoints -- I just get 404 errors.

The VS sln where the Github Action is running has multiple projects in it -- DealSiren.Api (which is the startup project when I run locally) and DealSiren.Data. Im not sure if thats part of my problem or not.

Below is the yml file that was created for me by the deployment center. Any help would be greatly appreciated, as I am definitely still learning.

# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy ASP.Net Core app to Azure Web App - dealsirenapi

on:
  push:
    branches:
      - master
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Set up .NET Core
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '8.x'

      - name: Build with dotnet
        run: dotnet build --configuration Release

      - name: dotnet publish
        run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v4
        with:
          name: .net-app
          path: ${{env.DOTNET_ROOT}}/myapp

  deploy:
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
    permissions:
      id-token: write #This is required for requesting the JWT

    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v4
        with:
          name: .net-app
      
      - name: Login to Azure
        uses: azure/login@v2
        with:
          client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_AA86B360F580433FB1855BCA67768AF3 }}
          tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_B93C0976BD0941DBB06D069F106A3F84 }}
          subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_006899419B1341F38B0B4442D8FEFA5C }}

      - name: Deploy to Azure Web App
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v3
        with:
          app-name: 'dealsirenapi'
          slot-name: 'Production'
          package: .
          

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,919 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,908 questions
{count} votes

Accepted answer
  1. Lex Li (Microsoft) 5,657 Reputation points Microsoft Employee
    2024-07-22T02:59:39.08+00:00

    Please delete

    // Add services to the container.
    builder.WebHost.ConfigureKestrel(options =>
    {
        options.ListenLocalhost(5000);
        options.ListenLocalhost(5001, listenOptions =>
        {
            listenOptions.UseHttps();
        });
    });
    

    as that prevents Azure from taking control of the bindings and forwarding traffic to your web app.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.