Ste*_*old 5 c# azure endpoint ftp-server azure-cloud-services
我想在Azure云服务工作者角色中托管嵌入式FTP服务器.
要提供对FTP服务器的被动访问,它使用端口范围20000-21000.ServiceDefinition.csdef我在里面定义了所有需要的端口(见截图).
主要问题是港口数量巨大.如果我尝试将服务上传到云端,则会出现以下错误.
验证错误:输入端点数无效 - 当前1002,最大值 25
如何通过云服务实现这项工作?
这是基于 Azure 支持答案的解决方案。
您需要在 .cscfg 文件中定义公共 IP 并将其上传到云服务。
<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="ILPIPSample" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2014-01.2.3">
<Role name="WebRole1">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
</ConfigurationSettings>
</Role>
<NetworkConfiguration>
<AddressAssignments>
<InstanceAddress roleName="WebRole1">
<PublicIPs>
<PublicIP name="MyPublicIP" domainNameLabel="WebPublicIP" />
</PublicIPs>
</InstanceAddress>
</AddressAssignments>
</NetworkConfiguration>
</ServiceConfiguration>
Run Code Online (Sandbox Code Playgroud)
之后,您可以使用 nslookup 获取分配给实例的公共 IP。如果有多个实例,则需要将 0 更改为 1、2、3 等。
nslookup WebPublicIP.0.<Cloud Service Name>.cloudapp.net
然后您可以在实例的Windows防火墙中打开本地端口,您将能够直接从互联网连接本地端口。
您可以创建启动任务,打开云服务防火墙的本地端口。以下是如何配置防火墙规则的示例。每次实例重新启动/重新映像时都会执行启动任务。
像下面这样:
netsh advfirewall firewall add rule name="TCP ports" protocol=TCP dir=in localport=1000-2000 action=allow
| 归档时间: |
|
| 查看次数: |
332 次 |
| 最近记录: |