Reputation: 10055
I have an app service setup in azure and loaded using a container. The container runs locally on my dev pc without issues. This worked previously and not sure at what point it failed.
Below are the logs from the log stream.
2021-03-15T23:58:30.009Z INFO - docker run -d -p 4040:443 --name <hidden> -e WEBSITE_SITE_NAME=<hidden> -e WEBSITE_AUTH_ENABLED=False -e PORT=443 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=<hidden>.azurewebsites.net -e WEBSITE_INSTANCE_ID=7d541a8f0aa7702237eea8e36b3c0321166514fdfef681b7755b6e82339b42dd -e HTTP_LOGGING_ENABLED=1 <hidden>.azurecr.io/tests/api:20210310.4
2021-03-15T23:58:31.444Z INFO - Initiating warmup request to container <hidden> for site test-app-svc
2021-03-15T23:58:31.450Z INFO - Container <hidden> for site <hidden> initialized successfully and is ready to serve requests.
2021-03-15T23:58:31.452Z INFO - Initiating warmup request to container <hidden> for site <hidden>
2021-03-15T23:58:48.930Z INFO - Waiting for response to warmup request for container <hidden>. Elapsed time = 17.4856219 sec
2021-03-15T23:59:09.988Z INFO - Waiting for response to warmup request for container <hidden>. Elapsed time = 38.5439589 sec
2021-03-15T23:59:25.081Z INFO - Waiting for response to warmup request for container <hidden>. Elapsed time = 53.6371028 sec
2021-03-15T23:59:40.170Z INFO - Waiting for response to warmup request for container <hidden>. Elapsed time = 68.7254333 sec
2021-03-15T23:59:55.261Z INFO - Waiting for response to warmup request for container <hidden>. Elapsed time = 83.8165802 sec
/home/LogFiles/2021_03_15_pl0sdlwk00000D_msi_docker.log (https://<hidden>.scm.azurewebsites.net/api/vfs/LogFiles/2021_03_15_pl0sdlwk00000D_msi_docker.log)
/home/LogFiles/2021_03_16_pl0sdlwk00000D_default_docker.log (https://<hidden>.scm.azurewebsites.net/api/vfs/LogFiles/2021_03_16_pl0sdlwk00000D_default_docker.log)
2021-03-16T09:14:56.794224723Z [40m[32minfo[39m[22m[49m: Microsoft.Hosting.Lifetime[0]
2021-03-16T09:14:56.794289922Z Now listening on: http://[::]:80
2021-03-16T09:14:56.797213505Z [40m[32minfo[39m[22m[49m: Microsoft.Hosting.Lifetime[0]
2021-03-16T09:14:56.797234705Z Application started. Press Ctrl+C to shut down.
2021-03-16T09:14:56.797388904Z [40m[32minfo[39m[22m[49m: Microsoft.Hosting.Lifetime[0]
2021-03-16T09:14:56.797402504Z Hosting environment: Production
2021-03-16T09:14:56.797539103Z [40m[32minfo[39m[22m[49m: Microsoft.Hosting.Lifetime[0]
2021-03-16T09:14:56.797551903Z Content root path: /App
My docker file correctly exposes port 443
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim
COPY app/publish/<hidden>/ App/
WORKDIR /App
RUN ls -la
EXPOSE 443
ENTRYPOINT ["dotnet", "<hidden>.dll"]
Upvotes: 0
Views: 1947
Reputation: 10055
So the problem was my understanding of Azure and how it communicates with containers.
Azure REQUIRES you to Expose port 80 on the container and not 443. Azure will communicate with your container internally on port 80, not 443.
Azure will then accept connections on both 80 and 443 by default and forward them to port 80 internally.
So once i changed by dockerfile to be like this then it all worked fine on both 80 and 443.
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim
COPY app/publish/<hidden>/ App/
WORKDIR /App
RUN ls -la
EXPOSE 80
ENTRYPOINT ["dotnet", "<hidden>.dll"]
You can also expose port 443 in the docker file but azure wont use it. This will allow you to test the container locally on your machine on 443.
Upvotes: 1