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
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.
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).
After creating the azure app service.
Open settings => Configuration => startup command
Add
dotnet containertestapp18.dll
as Startup command.While creating the app itself, the environment variables are automatically configured. However, ensure that the following environment variables are set in your app.
Local output :
Output after deployment:
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)