我已经在Azure上设置了服务结构集群,并且运行了2个服务的应用程序。现在我希望能够连接到浏览器中的服务,就像我在本地主机上运行它时一样。 该应用程序使用Owin和Swagger。以下是它在本地主机上的运行方式:running on localhost。当我尝试从Azure连接到它时,出现超时错误。我在应用程序中使用了端口20002和20001,并且在设置群集时(端口19000,19080,20001和20002在我的群集中打开),我打开了端口。这是我在资源管理器中的服务:Service in the explorer。群集设置为证书安全性,并且我已将证书添加到浏览器(我正在使用它连接到资源管理器)。我对CreateServiceInstanceListeners代码:连接到服务结构应用程序端点
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return Context.CodePackageActivationContext.GetEndpoints()
.Where(endpoint => endpoint.Protocol.Equals(EndpointProtocol.Http) || endpoint.Protocol.Equals(EndpointProtocol.Https))
.Select(endpoint => new ServiceInstanceListener(serviceContext => new OwinCommunicationListener("", new Startup(), serviceContext)));
}
和我的代码为OpenAsync:
public OwinCommunicationListener(string appRoot, IOwinAppBuilder startup, StatelessServiceContext serviceInitializationParameters)
{
_startup = startup;
_appRoot = appRoot;
_parameters = serviceInitializationParameters;
}
public Task<string> OpenAsync(CancellationToken cancellationToken)
{
var serviceEndpoint =
_parameters
.CodePackageActivationContext
.GetEndpoint("ServiceEndpoint");
var port = serviceEndpoint.Port;
var root =
String.IsNullOrWhiteSpace(_appRoot)
? String.Empty
: _appRoot.TrimEnd('/') + '/';
//TODO: Make localhost configable
_listeningAddress = String.Format(
CultureInfo.InvariantCulture,
"http://+:{0}/{1}",
port,
root
);
_serverHandle = WebApp.Start(
_listeningAddress,
appBuilder => _startup.Configuration(appBuilder)
);
var publishAddress = _listeningAddress.Replace(
"+",
FabricRuntime.GetNodeContext().IPAddressOrFQDN
);
ServiceEventSource.Current.Message("Listening on {0}", publishAddress);
return Task.FromResult(publishAddress);
}
和我serviceEndpoint:一个
<Endpoints>
<Endpoint Name="ServiceEndpoint" Port="20002" />
</Endpoints>
来总结我的问题:我如何才能存取权限我的服务织物的应用服务在我的浏览器中,使用大举和所有?
转发(任意)外部端口的内部端口20002在您的负载平衡器上 – Mardoxx