Search code examples
c#deploymentazure-service-fabric

How to get the path of a Data Package in Service Fabric?


I created a Data Package under the PackageRoot of my SF service (called WebSvc) which contains a License.xml file, like so:

ApplicationTypePackageRoot --> WebSvcPkg --> Data --> License.xml

Now in my C# code, I would like to get the full path to the License.xml file. How to do this?


Solution

  • Seems like you can find the path via the CodePackageActivationContext of the service:

     var dataPackage = this.serviceContext.CodePackageActivationContext.GetDataPackageObject("Data");
     var nsbLicensePath = Path.Combine(dataPackage.Path, "License.xml");