Search code examples
c#asp.net-coreazure-service-fabric

Read service versions from ApplicationManifest.xml from within a service fabric application


Packages for the service fabric can contain multiple services. Their version numbers are documented in ApplicationPackageRoot/ApplicationManifest.xml of the package:

...
<ServiceManifestImport>
 <ServiceManifestRef ServiceManifestName="VotingDataPkg" ServiceManifestVersion="1.0.29" />
</ServiceManifestImport>
<ServiceManifestImport>
  <ServiceManifestRef ServiceManifestName="VotingWebPkg" ServiceManifestVersion="1.0.29" />
</ServiceManifestImport>
...

Question: Is it possible to read this version information from one of the .NET services in the package?

I want the web service in the package to read the version information from ApplicationManifest.xml and present it on his web page.


Solution

  • You can use the servicecontext which is supplied to you in "runasync" method and call context.CodePackageActivationContext and drill down to the package versions.