2

Is it possible to access parameters defined in the ApplicationManifest.xml directly from your SF services?

I know you can define parameters on service level and provide overrides (as described here) but it is very cumbersome. If you have several services accessing same parameter (e.g. connection string) then it would be much easier to have it defined in a single place, like app manifest.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
filip
  • 1,444
  • 1
  • 20
  • 40
  • The whole idea of microservices is to be independent. So it is natural to have the same connection string in several places for each service. – cassandrad Aug 19 '16 at 08:17
  • Using same config params for commons things doesn't break their independence but would ease the maintenance. I'm configuring elastic search listeners to collect logs as advised in tutorials and I need to implement 4 overrides per each service - a lot of work for such a simple goal... – filip Aug 19 '16 at 11:25

1 Answers1

3

It's possible, but not easy.

  1. Get the manifest xml:
var fc = new FabricClient();         
var application = (await fc.QueryManager.GetApplicationListAsync(new Uri (Context.CodePackageActivationContext.ApplicationName))).Single();         
var applicationManifest = await fc.ApplicationManager.GetApplicationManifestAsync(application.ApplicationTypeName,
 application.ApplicationTypeVersion);
  1. Use that xml to deserialize an object based on the XSD schema. C:\Program Files\Microsoft SDKs\Service Fabric\schemas\ServiceFabricServiceModel.xsd (ApplicationManifestType)

(sorry about the formatting)

LoekD
  • 11,402
  • 17
  • 27