Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing Service Fabric stateless service config values outside the service project

Is there a way to access Service Fabric Stateless Service's custom config values from a different class library project? I can access the configurations currently like this from the StatelessService itself.

var configurationPackage =     Context.CodePackageActivationContext.GetConfigurationPackageObject("Config");
var connectionStringParameter = configurationPackage.Settings.Sections["QueueConfigSection"].Parameters["QueueName"];

How can I access this Context.CodePackageActivationContext from a different project? Or how can I expose the Stateless Service Context to a different project?

like image 288
Prasadi Avatar asked Oct 10 '16 14:10

Prasadi


1 Answers

Try this:

var activationContext = FabricRuntime.GetActivationContext();
var configurationPackage = activationContext.GetConfigurationPackageObject("Config");
var connectionStringParameter = configurationPackage.Settings.Sections["QueueConfigSection"].Parameters["QueueName"];

Note that this will only work from within the cluster.

like image 119
LoekD Avatar answered Sep 25 '22 00:09

LoekD