问题
Can an Azure Web Job listen on a public TCP port (socket)
I am deploying a Web Application to Azure, and it has a long running Web Job that listens to a TCP port (a custom protocol is involved, so a raw socket is required)
The listener runs, but I want to send data from outside of Azure, from another on-prem machine.
The port is listening OK, it can open an incoming socket, but it is internal (10.0.X.X)
I suspect a public port like this is NOT possible, but I want to be 100% sure of that limitation, before I invest in an alternate solution.
FWIW, the protocol is for HL7
If it is not possible, would a point to point VPN into the Web Application be one option, to tunnel the connection from on-prem to the Web App?
Are there other approaches (maybe Azure Functions) that I should consider instead?
回答1:
Indeed, you will not be able to listen on a public socket. See wiki for more details about the App Service sandbox.
回答2:
I have tried it but doesn't work! See the limitations: https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#network-endpoint-listening
But I could create a client application that can listen a non-http port. Also, It is possible to host the TCPListener app in ServiceFabric. I could host my existing application (WCF Console host) as a GuestExecutable in ServiceFabric without any code changes. I would recommend to go for ServiceFabric..its scalable and very reliable service.
来源:https://stackoverflow.com/questions/47601783/is-it-possible-to-use-an-azure-web-job-to-listen-on-a-public-socket