【发布时间】:2016-10-27 06:16:11
【问题描述】:
我部署了一个 azure worker 角色,它运行一些计划任务作为集成系统的一部分。我正在尝试公开一个 http 端点,该端点将提供一些管理功能,以便我可以远程控制工作者角色的各个方面。
我有工作角色并且正在运行,唯一的问题是我无法从 Internet 访问 http 端点。
我已经确认 nancy 服务器正在运行,因为当我远程访问虚拟机时,我可以使用本地 IP 地址进行连接。
角色配置如下:
<ServiceDefinition name="Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
<WorkerRole name="Host.Azure" vmsize="Small">
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
</ConfigurationSettings>
<Startup>
<Task commandLine="mount.cmd" executionContext="limited" taskType="background">
</Task>
</Startup>
<Endpoints>
<InputEndpoint name="http" protocol="http" port="80" localPort="80" />
</Endpoints>
<LocalResources>
</LocalResources>
<Imports>
<Import moduleName="RemoteAccess" />
<Import moduleName="RemoteForwarder" />
</Imports>
</WorkerRole>
</ServiceDefinition>
我正在按如下方式创建 nancy url:
var endpointName = "http";
var instance = RoleEnvironment.CurrentRoleInstance;
var internalEndpoint = instance.InstanceEndpoints[endpointName];
var uri = new Uri($"{internalEndpoint.Protocol}://{internalEndpoint.IPEndpoint}");
return new NancyUri {Value = uri};
还有什么我需要做的才能让它工作吗?
【问题讨论】:
-
你的 Uri 构造看起来很可疑,因为你正在抓取
.Protocol。.IPEndpoint下有你可能想要使用的属性(我现在不记得细节了)。