I am trying to deploy Azure function to Linux environment. Function needs to use hybrid connection to connect to on-prem API on port 80.
After deploy I receive the following error "Azure Functions Runtime is unreachable". Here is the output from docker logs:
2023-03-22T11:44:50.580612973Z Unhandled exception on 03/22/2023 11:44:50: System.AggregateException: One or more errors occurred. (Failed to bind to address http://[::]:80: address already in use.)
2023-03-22T11:44:50.580768273Z ---> System.IO.IOException: Failed to bind to address http://[::]:80: address already in use.
2023-03-22T11:44:50.580781573Z ---> Microsoft.AspNetCore.Connections.AddressInUseException: Address already in use
2023-03-22T11:44:50.580785873Z ---> System.Net.Sockets.SocketException (98): Address already in use
2023-03-22T11:44:50.580883973Z at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
2023-03-22T11:44:50.580895373Z at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
2023-03-22T11:44:50.580899573Z at System.Net.Sockets.Socket.Bind(EndPoint localEP)
Setting WEBSITES_PORT
to another port doesn't fix the issue.
I have stumbled upon this article which helped me resolve the issue.
After setting the PORT
to value 8080
, container boots normally.
PORT is for App Service on Linux “Blessed” Images.
tldr: On App Service Linux, using Blessed Images - PORT directly influences the container port of the docker run command. Just like what is explained in the WEBSITES_PORT section. However, most times, you most likely don’t need to alter it.
If for some reason you need to change the default container port (that your application would be listening on), you can use the PORT variable.
WEBSITES_PORT has no effect here. Adding this as an App Setting will not change the port - if you need to change the port from the default port being ran, then you must use the PORT App Setting.
The following are the default ports for Blessed Image stacks (possibly subject to change):
Node: 8080 Python: 8000 Java SE / Tomcat: 80 Go (experimental): 8080 .NET: 8080 Ruby: 8080 PHP: 8080