Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I host a TCP Listener in Azure?

Tags:

I am looking to build an application in Azure which will act as TCP listener, receive TCP message streams on a specified port, and then add the information to a database. The incoming TCP communication will be secured with a certificate.

I'm considering the following options:

Cloud Service Worker Role

This definitely looks like it will work. However that means I have to use a Cloud Service, and I miss out on the features and simplicity offered by the App Service. The Cloud Service documentation also specifically describes how to open the required TCP ports.

App Service

In a Logic App (preferred), however this doesn't seem to natively support a TCP listener, so I would look to build a custom API App. Alternatively I could create a Web Job.

However I'm not sure this approach will work, and I have the following questions:

  • Can I expose arbitrary TCP ports on the App Service?
    • Whilst the Cloud Service documentation specifically describes how to do this, I can't find anything similar for the App Service. So, either the configuration is not required or TCP communication is just not possible within the App Service.
  • Can I build a TCP listener inside an Logic App, API App, or Web Job, e.g. does the architecture of Azure support the behaviour required for a TCP listener?

Can I host a TCP Listener in an Azure App Service?

like image 595
James Wood Avatar asked Jul 12 '16 15:07

James Wood


2 Answers

Cloud Service Worker Role

This definitely looks like it will work. However that means I have to use a Cloud Service, and I miss out on the features and simplicity offered by the App Service. The Cloud Service documentation also specifically describes how to open the required TCP ports.

Definitely works.

https://msdn.microsoft.com/en-us/library/azure/gg557553.aspx

In ServiceDefinition.csdef:

<Endpoints>   <InputEndpoint name="RawTCP" protocol="tcp" port="54321" localPort="54321" /> </Endpoints>  

App Service

In a Logic App (preferred), however this doesn't seem to natively support a TCP >listener, so I would look to build a custom API App. Alternatively I could create a Web Job. ...

Can I expose arbitrary TCP ports on the App Service? ...

Can I host a TCP Listener in an Azure App Service?

No and No. Only 80/TCP and 443/TCP are exposed publicly and the only protocol that works is HTTP. You can't do custom listeners with App Service.

See the sandbox limitations listed here: https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#network-endpoint-listening

Feel free to make a pull request in the Azure documentation if this limitation is not mentioned on the App Service page.

Service Fabric would be a cool 3rd (or 1st?) option: https://azure.microsoft.com/en-us/services/service-fabric/

like image 100
evilSnobu Avatar answered Nov 13 '22 09:11

evilSnobu


I raised a support ticket and confirmed this with Microsoft.

[In the App Service] Azure doesn’t support customized port and only support http protocol. These 2 reasons deny the use of TCP listener.

Also further collaborating information this question; Can I open ports on Azure Websites?

like image 38
James Wood Avatar answered Nov 13 '22 09:11

James Wood