Search code examples
azure-service-fabric

How to add an external (packaged) Service Fabric Service to Application Manifest


We want to ingest bunch of external Service Fabric Services, which are packaged into Universal Packages.

To download these services, I had to use vsts cli - once they are downloaded I can see the ServiceManifest.xml and the Code / Config folders in the location that I've downloaded. I now want to add them as some kind of external services to my manifest.

How should I modify the ApplicationManifest.xml so these services are added?


Solution

  • Inside the <ServiceManifestImport> node in ApplicationManifest.xml you should add references to each of the service you would like to have in your application.

    <ServiceManifestImport>
      <ServiceManifestRef ServiceManifestName="ServicePkg" ServiceManifestVersion="1.0.0" />
      <ConfigOverrides />
    </ServiceManifestImport>
    

    Here is two important things to understand:

    1. While in general one ServiceManifest.xml contains definition of single service from the design standpoint ServiceManifest.xml describes a so-called service package. This service package is the thing referenced inside ApplicationManifest.xml.

    2. The value of ServiceManifestName attribute is the name of ServiceManifest.xml. ServiceManifest.xml name is defined inside it using ServiceManifest/@Nameattribute. At the same time ServiceManifestName attribute defines name of directory relative to location of ApplicationManifest.xml where ServiceManifest.xml, Code, Config and other folders are located.

    Here is a quick example

    Imagine you assemble a package in C:\MyPackage directory and you want to use external service which has Service1 name in ServiceManifest.xml.

    1. The first thing you do is adding this service to ApplicationManifest.xml
      <ServiceManifestImport>
        <ServiceManifestRef ServiceManifestName="Service1" ServiceManifestVersion="1.0.0" /> 
        <ConfigOverrides />
      </ServiceManifestImport>
      
    2. Now you copy ApplicationManifest.xml to C:\MyPackage directory.
    3. Then you create a C:\MyPackage\Service1 directory and copy ServiceManifest.xml, Code and etc. to C:\MyPackage\Service1.
    4. In order to make sure everything is alright you execute a PowerShell cmdlet Test-ServiceFabricApplicationPackage C:\MyPackage

    Hope this helps.