skip to Main Content

I’m working on a .NET 8 web api and using Docker to containerize it. The app works on my local machine, but fails when deployed to ACR. Before that I was running the app on .NET 7, and there were no issues with deploying it to ACR.

Dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["MyProject.API/MyProject.API.csproj", "MyProject.API/"]
COPY ["MyProject.Core/MyProject.Core.csproj", "MyProject.Core/"]
COPY ["MyProject.Models/MyProject.Models.csproj", "MyProject.Models/"]
RUN dotnet restore "MyProject.API/MyProject.API.csproj"
COPY . .
WORKDIR "/src/MyProject.API"
RUN dotnet build "MyProject.API.csproj" -c Release -o /app/build

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

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

Any help will be appreciated, thanks in advance!

UPD: The web app that uses this container image shows "Connected! 504.0 GatewayTimeout" in logs

2

Answers


  1. I created a sample ASP .NET 8 Web API and successfully deployed it to azure app service via Azure Container Registry.

    The error message you’re encountering might be related to Environment configuration issues.

    I successfully pushed the image to container registry.

    • Right click on your project in solution explorer=>publish=>Azure => Azure container registry =>select your registry => Finish.

    enter image description here

    enter image description here

    enter image description here

    enter image description here

    • While creating azure web app make sure you choose publish option as Container.

    • Configure the App Service to use the correct container image from your Azure Container Registry (ACR).
      enter image description here

    • After creating the azure app service.

    • Open settings => Configuration => startup command

    • Add dotnet containertestapp18.dll as Startup command.

    enter image description here

    While creating the app itself, the environment variables are automatically configured. However, ensure that the following environment variables are set in your app.
    enter image description here

    Local output :
    enter image description here

    Output after deployment:

    enter image description here

    Login or Signup to reply.
  2. Updating my .NET from 8.0.400 to 8.0.401 fixed my issue of pushing the image to ACR when deploying on Azure container Apps (ACA)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search