Hello everyone,
I am facing one issue so, trying to explain the whole scenario.
Final Result :
I am having a TCPClient (a console application) which will send data to TCPListener (a web app hosted on azure).
Implementation :
- Created one simple web application which will act as a TCP Listener. Add logs to see the received message from TCP Client.
- Add Dockerfile
- In dockerfile expose the port 8080 for TCP communication.
- Publish the application on azure container repository
- Create one console application for sending data to listener.
- The TCPClient will connect to host my-app.azurewebsites.net and port 8080
Problem :
TCP Client (local console application) is not able to connect to the TCP listener. By default web app allows only 80 and 443 port. So, to open other ports tried below solutions,
- Create virtual network
- Create Network Security Group and add the virtual network as subnet
- Add Inbound Security Rules in NSG.
- Create a azure web app and assign the virtual network.
- Also try to set the WEBSITES_PORT in web app configuration
None of the above solution works. Also tried to check port via telnet and connection failed which means port is not open. I am stuck here don't know which part is missing.
Any help is appreciated.
Thanks.

Saravanan GanesanPosted Aug 4, 2023, 8:14 PM
It seems like you are trying to establish a TCP connection between a local TCP client (console application) and a TCP listener (web app hosted on Azure). There are a few points to consider when setting up this communication:
Azure Web App Limitations: Azure Web Apps have limitations when it comes to running as a TCP listener on custom ports. As you mentioned, by default, they only support ports 80 and 443 for HTTP and HTTPS traffic. Unfortunately, you cannot directly open port 8080 for TCP communication.
Using Azure Container Instances (ACI): If you want to run a custom TCP listener on Azure, you might consider using Azure Container Instances (ACI) instead of Azure Web Apps. ACI allows you to run containers with custom ports, including TCP ports. This way, you can expose port 8080 for your TCP listener.
Azure Functions with Custom Bindings: Another option to handle incoming TCP traffic is by using Azure Functions with custom bindings. Azure Functions can be triggered by different types of events, including TCP messages.
Azure Virtual Machine (VM): If running a custom TCP listener is a critical requirement, you can consider deploying a Virtual Machine (VM) on Azure. VMs give you complete control over the network and firewall settings, allowing you to open and use any required ports.
Azure IoT Hub: If your goal is to enable communication between devices and a central hub, you might explore using Azure IoT Hub, which provides a secure, bidirectional communication channel for IoT devices.
In conclusion, if running a custom TCP listener on a non-standard port is essential, consider using Azure Container Instances or deploying a Virtual Machine. Azure Web Apps are better suited for HTTP and HTTPS communication on standard ports. Evaluate your requirements, and choose the appropriate Azure service that best aligns with your use case.
Tuhin PaulPosted Feb 28, 2023, 8:49 AM
Hi Hiten,
I think you have already taken some steps to open the port for the TCP Listener but you are still unable to connect the TCP Client to the Listener. Try the following for troubleshooting:
If you are still unable to connect the TCP Client to the TCP Listener after trying these suggestions, please provide more information or error messages to help diagnose the issue further.