Azure App Service Window Container Fail to start (.Net Core Sdk not found)

ronkit 36 Reputation points
2022-05-24T16:57:40.683+00:00

Created ASP .net Core Web Api project using Visual Studio 2022 with docker support for Windows.
Below was my docker file. It was auto generated when I enable docker support for Windows

FROM mcr.microsoft.com/dotnet/aspnet:3.1-nanoserver-1809 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["TestDocker/TestDocker.csproj", "TestDocker/"]
RUN dotnet restore "TestDocker/TestDocker.csproj"
COPY . .
WORKDIR "/src/TestDocker"
RUN dotnet build "TestDocker.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "TestDocker.csproj" -c Release -o /app/publish

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

After deployed to Azure App Service Window container, it keep showing me unable to start the container.
After checking from App Service Kudu, found these error message in console logs:

24/05/2022 16:39:32.107 STDERR - Site: simpleDocker123 - [c67b2a5f07c12c44b98311303842a244ec416eea0432e0f0fcbe9218dc1be242] -       https://aka.ms/dotnet-download
24/05/2022 16:40:05.113 STDERR - Site: simpleDocker123 - [aa0bab045680844de048b1f7c158f88d53585d531484bb3f1030800731b56ecb] -   It was not possible to find any installed .NET Core SDKs
24/05/2022 16:40:05.113 STDERR - Site: simpleDocker123 - [aa0bab045680844de048b1f7c158f88d53585d531484bb3f1030800731b56ecb] -   Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
24/05/2022 16:40:05.113 STDERR - Site: simpleDocker123 - [aa0bab045680844de048b1f7c158f88d53585d531484bb3f1030800731b56ecb] -       https://aka.ms/dotnet-download
24/05/2022 16:42:51.232 STDERR - Site: simpleDocker123 - [29a2d2d08e27bb6852608a4b2ac116a55bf011c19bdfc4278e069aa368d76c66] -   It was not possible to find any installed .NET Core SDKs
24/05/2022 16:42:51.232 STDERR - Site: simpleDocker123 - [29a2d2d08e27bb6852608a4b2ac116a55bf011c19bdfc4278e069aa368d76c66] -   Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
24/05/2022 16:42:51.232 STDERR - Site: simpleDocker123 - [29a2d2d08e27bb6852608a4b2ac116a55bf011c19bdfc4278e069aa368d76c66] -       https://aka.ms/dotnet-download

On platform logs was something as below:

24/05/2022 16:51:39.528 INFO - Site: simpleDocker123 - [e30858fffca0b25a8280722958eb413a87299c1422cf713f786e8ae839a5091a] - Start container succeeded.
24/05/2022 16:51:45.822 INFO - Site: simpleDocker123 - [e30858fffca0b25a8280722958eb413a87299c1422cf713f786e8ae839a5091a] - Container has started.
24/05/2022 16:51:45.822 INFO - Site: simpleDocker123 - [e30858fffca0b25a8280722958eb413a87299c1422cf713f786e8ae839a5091a] - Customizing the container
24/05/2022 16:51:47.053 INFO - Site: simpleDocker123 - [e30858fffca0b25a8280722958eb413a87299c1422cf713f786e8ae839a5091a] - Container customization has completed successfully
24/05/2022 16:51:47.067 INFO - Site: simpleDocker123 - [e30858fffca0b25a8280722958eb413a87299c1422cf713f786e8ae839a5091a] - Container has started.
24/05/2022 16:51:47.836 INFO - Site: simpleDocker123 - [e30858fffca0b25a8280722958eb413a87299c1422cf713f786e8ae839a5091a] - Container entrypoint has started
24/05/2022 16:52:08.890 ERROR - Site: simpleDocker123 - [e30858fffca0b25a8280722958eb413a87299c1422cf713f786e8ae839a5091a] - Container entrypoint is no longer running.
24/05/2022 16:52:08.890 ERROR - Site: simpleDocker123 - [e30858fffca0b25a8280722958eb413a87299c1422cf713f786e8ae839a5091a] - Container was not ready because it has been cancelled or exited
24/05/2022 16:52:08.890 INFO - Site: simpleDocker123 - [e30858fffca0b25a8280722958eb413a87299c1422cf713f786e8ae839a5091a] - Attempting to stop container: e30858fffca0b25a8280722958eb413a87299c1422cf713f786e8ae839a5091a. Site simpleDocker123
24/05/2022 16:52:08.947 INFO - Site: simpleDocker123 - [e30858fffca0b25a8280722958eb413a87299c1422cf713f786e8ae839a5091a] - Shutdown container: e30858fffca0b25a8280722958eb413a87299c1422cf713f786e8ae839a5091a

Any idea on this issue? Already followed the guide from microsoft exactly but still hitting these error
Any help will be appreciate

Thanks

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,368 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,157 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,235 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JasonPan - MSFT 4,201 Reputation points Microsoft Vendor
    2022-05-25T02:27:25.367+00:00

    Hi @ronkit

    Change your docker file like below, keeping your runtime and sdk version consistent should solve this problem.

     FROM mcr.microsoft.com/dotnet/aspnet:3.1-nanoserver-1809 AS base  
     WORKDIR /app  
     EXPOSE 80  
     EXPOSE 443  
          
     FROM mcr.microsoft.com/dotnet/sdk:3.1-nanoserver-1809 AS build  
     WORKDIR /src  
     COPY ["TestDocker/TestDocker.csproj", "TestDocker/"]  
     RUN dotnet restore "TestDocker/TestDocker.csproj"  
     COPY . .  
     WORKDIR "/src/TestDocker"  
     RUN dotnet build "TestDocker.csproj" -c Release -o /app/build  
          
     FROM build AS publish  
     RUN dotnet publish "TestDocker.csproj" -c Release -o /app/publish  
          
     FROM base AS final  
     WORKDIR /app  
     COPY --from=publish /app/publish .  
     ENTRYPOINT ["dotnet", "TestDocker.dll"]  
    

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,
    Jason