Call Azure Service Fabric from outside


I'm playing with Azure Service Fabric and a console app. I simply want my console app to connect to the cluster and do some stuff.

The console app try to resolve the service address with the following:

    static void Main(string[] args)
        ServicePartitionResolver resolver = null;

            resolver = new ServicePartitionResolver(
                new string[] {

            Uri serviceUri = new Uri("fabric:/StatefullServiceTEST/MyStatefulService");
            ResolvedServicePartition partition = resolver.ResolveAsync(serviceUri, new ServicePartitionKey(), CancellationToken.None).GetAwaiter().GetResult();
        catch (Exception ex)
            Console.WriteLine($"Exception: {ex.Message}");
        Console.Write("Press any key to exit...");

My problem is that resolver.ResolveAsync throws an exception that doesn't seem to have any connection with Service Fabric:

Unable to cast COM object of type 'System.__ComObject' to interface type 'IFabricApplicationManagementClient10'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{67001225-D106-41AE-8BD4-5A0A119C5C01}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

Any ideas on this?


I was not so clear explaining my problem and what I want to achive.

I'm playing with Azure Service Fabric (both stateless and stateful services): my question is: what's the best way to call a micro service hosted in Azure Service Fabric?

Regards, Attilio

asked on Stack Overflow Feb 19, 2018 by Attilio Gelosa • edited Aug 21, 2019 by Bhargav Rao

3 Answers


You can't use ServicePartitionResolver, it is a reliable service feature and must be called from within a service running in your cluster.

I couldn't understand clearly what you want.

If you want to manage the service and get details about it, like query running instances or replicas, add or remove instances, and so on, Use the Fabric Client, below is a quick snippet, check details here and here:


using System.Fabric;
using System.Security.Cryptography.X509Certificates;

string clientCertThumb = "71DE04467C9ED0544D021098BCD44C71E183414E";
string serverCertThumb = "A8136758F4AB8962AF2BF3F27921BE1DF67F4326";
string CommonName = "";
string connection = "";

var xc = GetCredentials(clientCertThumb, serverCertThumb, CommonName);
var fc = new FabricClient(xc, connection);`


If you want to communicate to a running service, like an API, you should use a Reverse Proxy to resolve your services via URL, like the below snippet, more details here:

answered on Stack Overflow Feb 19, 2018 by Diego Mendes • edited Feb 21, 2018 by Diego Mendes

You have to create a public facing service (such as Core Web Api) which will expose the functionality of your service inside service fabric to outside world (outside the service fabric cluster). FabricClient approach is to be utilzied for calling services from within the service fabric cluster and not outside.

From your Core service you will use the FabricClient to access the service hosted, so in general your core app act as reverse proxy to expose the functionality of actual service.

answered on Stack Overflow Feb 20, 2018 by Satya Tanwar • edited Feb 20, 2018 by Satya Tanwar

You cannot access service in an ASF cluster from the outside using the ServicePartitionResolver.

You have to have a public facing endpoint on your cluster, like a stateless service acting as a web api for example.

From the docs:

Services connecting to each other inside a cluster generally can directly access the endpoints of other services because the nodes in a cluster are on the same local network. In some environments, however, a cluster may be behind a load balancer that routes external ingress traffic through a limited set of ports. In these cases, services can still communicate with each other and resolve addresses using the Naming Service, but extra steps must be taken to allow external clients to connect to services.

A Service Fabric cluster in Azure is placed behind an Azure Load Balancer. All external traffic to the cluster must pass through the load balancer. The load balancer will automatically forward traffic inbound on a given port to a random node that has the same port open. The Azure Load Balancer only knows about ports open on the nodes, it does not know about ports open by individual services.

So, unless your console app is hosted in the cluster as a guest executable, you have some more work to do.

answered on Stack Overflow Feb 19, 2018 by Peter Bons

User contributions licensed under CC BY-SA 3.0