I wanted to see if I could get Azure Web App on Containers working on a custom port. It turns out you can but you can't expose the container on anything other than port 80 or 443.
I tried this out locally first with ASP.NET Core. Taking the sample, mcr.microsoft.com/dotnet/core/samples:aspnetapp and changing the port of the web server inside the image to be 8000....
docker run --rm -it -p 8000:8000 -e ASPNETCORE_URLS="http://*:8000" mcr.microsoft.com/dotnet/core/samples:aspnetapp
The environment variable, ASPNETCORE_URLS, needs to be passed in matching any ip in the container to port 8000. I'm mapping port 8000 on my host to that of the container's process.
The documentation for Web App on Containers states you need to add environment variables to the Application Settings under Configuration but it also advises that to run on a custom port WEBSITES_PORT setting is required. Slightly confusing is that when you set this and view the Container Settings blade you don't see the environment variable on the docker run statement....
docker run -d -p 53967:8000 --name mccontainer_0_a97e8f2d -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITES_PORT=8000 -e WEBSITE_SITE_NAME=mccontainer -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=mccontainer.azurewebsites.net -e WEBSITE_INSTANCE_ID=57008eb873c7365c6ef907311d1d26e719d2d304effbc14458cd2f45247bca14 mcr.microsoft.com/dotnet/core/samples:aspnetapp
But you do need both settings and it does work (I had to wait for several minutes for my container to pick up a change in the settings). When I navigate to https://mccontainer.azurewebsites.net/ my containerised website is loaded.