-1

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

5
  • What does "fails when deployed to ACR" mean? Please include the actual steps you're trying to perform, what error message you're getting etc. Remember, we're not at your computer, so it's up to you to be pro-active and include the basic information so that we have the full picture of what's happening. Commented Jul 11, 2024 at 14:02
  • Provide you github repo if possible ? Commented Jul 11, 2024 at 14:40
  • Provide the screenshot of error message you're encountering. Commented Jul 11, 2024 at 14:41
  • @SirraSneha the error message is 504.0 GatewayTimeout. The web app log stream shows "Connected! 504.0 GatewayTimeout" Commented Jul 12, 2024 at 7:56
  • @Nataly Verner, it would be easier to solve if you provide the code you've tried. Commented Jul 12, 2024 at 8:15

2 Answers 2

0

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

Sign up to request clarification or add additional context in comments.

1 Comment

@Nataly Verner Is your issue resolved?
0

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.