Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FabricConnectionDeniedException - Where do I setup Azure Service Fabric connections?

I'm trying to create a Visual Studio Project Template that includes an Azure Service Fabric Project with a StatelessService.

In the boiler plate Program EntryPoint code, I'm getting a FabricConnectionDeniedException. Where do I setup the Connection Information or otherwise fix this exception? I'm running against the Local Cluster Manager. I've looked through the various .xml config files but aren't seeing anything. Do I need to whitelist my application in the Cluster Manager?

Here's the boiler plate code I copied from the Azure Service Fabric:

    private static void Main()
    {
        try
        {
            // Creating a FabricRuntime connects this host process to the Service Fabric runtime.
            using (var fabricRuntime = System.Fabric.FabricRuntime.Create())
            {
                // The ServiceManifest.XML file defines one or more service type names.
                // RegisterServiceType maps a service type name to a .NET class.
                // When Service Fabric creates an instance of this service type,
                // an instance of the class is created in this host process.
                fabricRuntime.RegisterServiceType(
                    "RunSetManagerServiceType", 
                    typeof(RunSetManagerService));

                ServiceEventSource.Current.ServiceTypeRegistered(
                    Process.GetCurrentProcess().Id, 
                    typeof(RunSetManagerService).Name);

                // Prevents this host process from terminating to keep the service host process running.
                Thread.Sleep(Timeout.Infinite);  
            }
        }
        catch (Exception e)
        { 
           // !!!!!! GETTING FabricConnectionDeniedException HERE !!!!!
            ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());
            throw;
        }
    }
like image 879
Philip Pittle Avatar asked Mar 31 '16 23:03

Philip Pittle


People also ask

What is the default port for getting connected to the service Fabric Explorer?

To connect to a Service Fabric cluster, you need the clusters management endpoint (FQDN/IP) and the HTTP management endpoint port (19080 by default).

How do I install Microsoft service Fabric?

Download & install the Service Fabric standalone package. Create the Service Fabric cluster. Connect to the Service Fabric cluster.

How does Azure service Fabric work?

Azure Service Fabric is a distributed systems platform that makes it easy to package, deploy, and manage scalable and reliable microservices and containers. Service Fabric also addresses the significant challenges in developing and managing cloud native applications.


1 Answers

This is because you're running your service EXE outside of the Service Fabric runtime environment. When you compile your service into an EXE, you can't just execute it on its own; you have to "deploy" it the Service Fabric cluster where it will be executed for you by the Service Fabric runtime environment.

If you're deploying through Visual Studio, make sure your application project is set as the startup project, not the service project (the startup project will appear in bold in the Solution Explorer).

Also, not related to the error you're seeing but just a heads up: When you upgraded to the latest 2.0.135 SDK, you'll need to update your service registration code to use the new ServiceRuntime:

try
{
    ServiceRuntime.RegisterServiceAsync("RunSetManagerServiceType",
        context => new RunSetManagerService(context)).GetAwaiter().GetResult();

    ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(Stateless1).Name);

    // Prevents this host process from terminating so services keep running.
    Thread.Sleep(Timeout.Infinite);
}
catch (Exception e)
{
    ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());
    throw;
}
like image 55
Vaclav Turecek Avatar answered Sep 24 '22 12:09

Vaclav Turecek