projectkudu / kudu

Kudu is the engine behind git/hg deployments, WebJobs, and various other features in Azure Web Sites. It can also run outside of Azure.
Apache License 2.0
3.13k stars 652 forks source link

Creating an HttpListener in an Azure Sandbox? #3471

Closed Envisij closed 1 year ago

Envisij commented 1 year ago

https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox says:

Network endpoint listening

The only way an application can be accessed via the internet is through the already-exposed HTTP (80) and HTTPS (443) TCP ports; applications may not listen on other ports for packets arriving from the internet. However, applications may create a socket which can listen for connections from within the sandbox. For example, two processes within the same app may communicate with one another via TCP sockets; connection attempts incoming from outside the sandbox, albeit they be on the same machine, will fail. See the next topic for additional detail. Local Address Requests

Connection attempts to local addresses (e.g. localhost, 127.0.0.1) and the machine's own IP will fail, except if another process in the same sandbox has created a listening socket on the destination port. The listening port must be > 1024 and not currently in used. Otherwise, you may get below exception.

Has anyone any tips on how one creates a listening port in an azure sandbox? When I try, using a webjob console app, I receive "Access denied" when trying to bind a listening address to http://localhost:9696

jvano commented 1 year ago

Please read more about the Azure App Service propietary sandbox here: https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox

This is not possible by design if you use Windows Web App, but you can try to enable this type of scenarios inside a Windows Container or a Linux Container on App Service. For more info: https://learn.microsoft.com/en-us/azure/app-service/quickstart-custom-container