Reputation: 1552
I have set up Azure App Service with Linux server and deployed a dotnet core app on it. When navigating to app URL (.azurewebsites.net) I am receiving the following error:
:( Application Error
The console output is:
Failed to load resource: the server responded with a status of 503 (Service Unavailable)
When opening the monitoring Log stream, this is what I get (I have replaced names and IDs, I don't know what the sensitive data is):
2023-05-08T21:11:07.396Z ERROR - Container 0 for site has exited, failing site start 2023-05-08T21:11:07.408Z ERROR - Container 0 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging. 2023-05-08T21:11:07.415Z INFO - Stopping site because it failed during startup. 2023-05-08T21:19:11.674Z INFO - Starting container for site 2023-05-08T21:19:11.683Z INFO - docker run -d --expose=8080 --name 0 -e PORT=8080 -e WEBSITE_SITE_NAME= -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=.azurewebsites.net -e WEBSITE_INSTANCE_ID= -e HTTP_LOGGING_ENABLED=1 -e ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=Microsoft.ApplicationInsights.StartupBootstrapper -e DOTNET_STARTUP_HOOKS=/agents/core/StartupHook/Microsoft.ApplicationInsights.StartupHook.dll -e WEBSITE_USE_DIAGNOSTIC_SERVER=True appsvc/dotnetcore:6.0_20230323.1.tuxprod
I have tried adding WEBSITES_PORT and just PORT settings with value "8080" to App Service > Configuration > Application settings, but nothing changed.
Any ideas where to go from here, this is all new to me?
Upvotes: 4
Views: 8806
Reputation: 1
Try adding this: ASPNETCORE_URLS=http://+:8080 in the docker file itself or in Azure; settings —-> environment variables.
Upvotes: 0
Reputation: 1
If you are following along with the Deploy an ASP.NET Core and Azure SQL Database app to Azure App Service Tutorial, you can find the Dockerfile inside a .devcontainer directory in the sample repository provided towards the beginning of the tutorial. There you can Expose the port to 8080.
Upvotes: 0
Reputation: 8579
This error occurs when the site fails to respond to HTTP pings on port 8080. This could be because of incorrect configuration settings or issues with the container image.
Check if the below steps help to fix the issue:
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 8080
.....
Check the container logs to figure out the errors or issues which is causing the container to fail in App Service -> Deployment Center -> Logs tab.
Check if the container image is configured properly, and also compatible with the version of .NET Core you are using.
Check the configuration settings of your App Service. Restart your App Service after configuring the WEBSITES_PORT or PORT setting to the same port that your application is listening to, it helps to resolve issues with the container.
Enable application logging (Linux/Container) in the App service. App service-> App Service Logs->Select Application logging in File System.
I have created a dotnet core web application. Dockerized and deployed the application to Azure App service. Dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["WebApplication12.csproj", "."]
RUN dotnet restore "./WebApplication12.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "WebApplication12.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "WebApplication12.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WebApplication12.dll"]
Building Docker Image:
Pushing the Image to repository:
Portal:
Response:
Upvotes: 3