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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With