2016-03-31 2 views
4

J'essaie de créer un modèle de projet Visual Studio qui inclut un projet Azure Service Fabric avec un StatelessService.FabricConnectionDeniedException - Où puis-je configurer les connexions Azure Service Fabric?

Dans la plaque de la chaudière Program code EntryPoint, je reçois un FabricConnectionDeniedException. Où puis-je configurer les informations de connexion ou corriger cette exception? Je cours contre le gestionnaire de cluster local. J'ai regardé à travers les différents fichiers de configuration .xml mais ne vois rien. Ai-je besoin de mettre en liste blanche mon application dans le gestionnaire de cluster?

est ici le code de plaque de la chaudière je copiais du service Azure 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; 
     } 
    } 

Répondre

4

C'est parce que vous utilisez votre service EXE en dehors de l'environnement d'exécution Fabric service. Lorsque vous compilez votre service dans un fichier EXE, vous ne pouvez pas l'exécuter seul; vous devez "déployer" le cluster Service Fabric où il sera exécuté pour vous par l'environnement d'exécution de Fabric Service.

Si vous déployez dans Visual Studio, assurez-vous que votre demande projet est défini comme projet de démarrage, pas le projet de service (le projet de démarrage apparaît en gras dans la solution Explorer). En outre, pas lié à l'erreur que vous voyez mais juste un heads up: Lorsque vous avez mis à jour vers le dernier SDK 2.0.135, vous devrez mettre à jour votre code d'enregistrement de service pour utiliser le nouveau 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; 
}