如何在 Azure 中托管 TCP 侦听器? [英] How can I host a TCP Listener in Azure?

查看:27
本文介绍了如何在 Azure 中托管 TCP 侦听器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在 Azure 中构建一个应用程序,它将充当 TCP 侦听器,在指定端口上接收 TCP 消息流,然后将信息添加到数据库中.传入的 TCP 通信将使用证书进行保护.

我正在考虑以下选项:

云服务工作者角色

这看起来肯定会工作.然而,这意味着我必须使用云服务,而我错过了应用服务提供的功能和简单性.云服务文档还具体介绍了如何打开需要的TCP端口.

应用服务

在逻辑应用程序(首选)中,但是这似乎本身并不支持 TCP 侦听器,因此我希望构建自定义 API 应用程序.或者,我可以创建一个 Web 作业.

但是我不确定这种方法是否有效,我有以下问题:

  • 我可以在应用服务上公开任意 TCP 端口吗?
    • 虽然云服务文档专门描述了如何执行此操作,但我找不到应用服务的类似内容.因此,要么不需要配置,要么在应用服务中无法进行 TCP 通信.
  • 我可以在逻辑应用程序、API 应用程序或 Web 作业中构建 TCP 侦听器吗,例如Azure 的体系结构是否支持 TCP 侦听器所需的行为?

我可以在 Azure 应用服务中托管 TCP 侦听器吗?

解决方案

云服务工作者角色

这看起来肯定会奏效.然而,这意味着我必须使用云服务,而我错过了应用服务提供的功能和简单性.Cloud Service 文档中还专门介绍了如何打开所需的 TCP 端口.

绝对有效.

https://msdn.microsoft.com/en-us/图书馆/天蓝色/gg557553.aspx

ServiceDefinition.csdef中:

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

<块引用>

应用服务

在逻辑应用程序(首选)中,但是这似乎本身并不支持 TCP >侦听器,因此我希望构建自定义 API 应用程序.或者,我可以创建一个 Web 作业....

我可以在应用服务上公开任意 TCP 端口吗?...

我可以在 Azure 应用服务中托管 TCP 侦听器吗?

否和否.只有 80/TCP 和 443/TCP 公开,并且唯一有效的协议是 HTTP.您无法使用应用服务进行自定义侦听器.

查看此处列出的沙箱限制:https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#network-endpoint-listening

如果应用服务页面上未提及此限制,请随时在 Azure 文档中提出拉取请求.

Service Fabric 将是一个很酷的第三(或第一?)选项:https://azure.microsoft.com/en-us/services/service-面料/

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?

解决方案

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/

这篇关于如何在 Azure 中托管 TCP 侦听器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆