Search code examples
azurelisteneractorazure-service-fabricendpoint

How to set up reliable services to work on Azure remote cluster


I made a reliable services app that works perfectly on local cluster.

It has 1 stateless service and 1 actor service and both uses service remoting. Endpoints aren't defined on these services (only endpoint name) and both services use default listeners (no CreateServicesListeners override) Client app is a console app that uses service remoting to comunicate with app (ActorProxy and ServiceProxy).

Now I want to deploy it on an Azure cluster.

What should I do to make client comunicate correctly with app on cluster?

I know that I have to:

  • Configure TCP endpoints on settings xml
  • Configure Azure Load Balancer

But should I so some of these things? And in that case how?

  • Override CreateServiceListeners
  • Use FabricClient on client
  • Use ServicePartitionClient on client

My main problem is how to create ActorProxy and ServiceProxy


Solution

  • You should not use the ActorProxy and ServiceProxy classes outside the cluster. Instead use a public facing service like a Web Api that uses https for example to act as a gateway to the services. Then open the https port on the Azure Load Balancer.

    Please read the docs as they list every step you need to take.

    This is an example (taken from the docs) of a service that uses https:

    class HttpCommunicationListener : ICommunicationListener
    {
        ...
    
        public Task<string> OpenAsync(CancellationToken cancellationToken)
        {
            EndpointResourceDescription endpoint =
                serviceContext.CodePackageActivationContext.GetEndpoint("WebEndpoint");
    
            string uriPrefix = $"{endpoint.Protocol}://+:{endpoint.Port}/myapp/";
    
            this.httpListener = new HttpListener();
            this.httpListener.Prefixes.Add(uriPrefix);
            this.httpListener.Start();
    
            string publishUri = uriPrefix.Replace("+", FabricRuntime.GetNodeContext().IPAddressOrFQDN);
            return Task.FromResult(publishUri);
        }
    
        ...
    }
    
    class WebService : StatelessService
    {
        ...
    
        protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
        {
            return new[] { new ServiceInstanceListener(context => new HttpCommunicationListener(context))};
        }
    
        ...
    }
    

    The public service like the one above should use the ActorProxy and ServiceProxy classes to delegate work to the underlying services and actors.

    So to summarize:

    But should I so some of these things? And in that case how?

    • Override CreateServiceListeners Yes

    • Use FabricClient on client No

    • Use ServicePartitionClient on client No

    My main problem is how to create ActorProxy and ServiceProxy This only applies for communication between services in the cluster