Search code examples
azuredockerdockerfileazure-web-app-servicecontainers

Facing issue after deploying net 8 docker image to azure web app(Linux) container


I've build an API using .Net 8 and created container image using below Dockerfile

#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Presentation/POMaster.API/POMaster.API.csproj", "Presentation/POMaster.API/"]
COPY ["Libraries/POMaster.Framework/POMaster.Framework.csproj", "Libraries/POMaster.Framework/"]
COPY ["Libraries/POMaster.Services/POMaster.Services.csproj", "Libraries/POMaster.Services/"]
COPY ["Libraries/POMaster.Data/POMaster.Data.csproj", "Libraries/POMaster.Data/"]
COPY ["Libraries/POMaster.Domain/POMaster.Domain.csproj", "Libraries/POMaster.Domain/"]
COPY ["Libraries/POMaster.Utils/POMaster.Utils.csproj", "Libraries/POMaster.Utils/"]
RUN dotnet restore "./Presentation/POMaster.API/POMaster.API.csproj"
COPY . .
WORKDIR "/src/Presentation/POMaster.API"
RUN dotnet build "./POMaster.API.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./POMaster.API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "POMaster.API.dll"]

I've pushed this image onto ACR. I'm using Azure web app(Linux) container to run the container out of image. Everything works fine(i.e. based on logs), but i can't visit site via public URL and it shows 404

Below is the log from log stream

enter image description here

What am I missing or doing something wrong here? Can somebody please help to resolve? Your help would be greatly appreciated.

I've also added WEBSITES_PORT setting with value 8080 under azure web app application settings, but didn't worked.


Solution

  • Posting My Comment as an Answer.

    I created a simple ASP. NET Core 8 Web APP, containerized it with Docker, pushed it to Azure Container Registry, and deployed it to Azure Web App (Linux). It was successful.

    I also faced the same issue, so I placed this

    dotnet <YourLocalWebAppName>.dll
    

    Startup command in Azure App Service, as shown below.

    enter image description here

    The Startup command for Linux is necessary it tells platform how to start the Application.

    Azure App Service Output:

    enter image description here