I have set up a Service Fabric cluster on Azure, and have an application with 2 services running. now I want to be able to connect to the services in my browser, like I can when I run it on localhost. The application uses Owin and Swagger. Here is how it looks like running on localhost: running on localhost. When I try to connect to it from Azure, I get a timeout error. I'm using port 20002 and 20001 in the application, and I have opened the ports when I set up the cluster (port 19000, 19080, 20001 and 20002 are open in my cluster). Here is my service in the Explorer: Service in the explorer. The cluster is setup with certificate security, and I have the certificate added to my browser (I'm using it to connect to the explorer). My code for 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)));
}
and my code for 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);
}
and my ServiceEndpoint:
<Endpoints>
<Endpoint Name="ServiceEndpoint" Port="20002" />
</Endpoints>
to sum up my question: how can I acces my Service Fabric applications services in my browser, using swagger and all?