title: How can I host a TCP Listener in Azure?
body: <p>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.</p>
  
  <p>I'm considering the following options:</p>
  
  <p><strong>Cloud Service Worker Role</strong> </p>
  
  <p>This definitely looks like it will <a href="http://blog.maartenballiauw.be/post/2010/01/17/Creating-an-external-facing-Azure-Worker-Role-endpoint.aspx" rel="noreferrer">work</a>. 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 <a href="https://azure.microsoft.com/en-gb/documentation/articles/cloud-services-enable-communication-role-instances/" rel="noreferrer">documentation</a> also specifically describes how to open the required TCP ports.</p>
  
  <p><strong>App Service</strong></p>
  
  <p>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. </p>
  
  <p>However I'm not sure this approach will work, and I have the following questions:</p>
  
  <ul>
  <li>Can I expose arbitrary TCP ports on the App Service? 
  
  <ul>
  <li>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.</li>
  </ul></li>
  <li>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?</li>
  </ul>
  
  <p>Can I host a TCP Listener in an Azure App Service?</p>