Azure Service Fabric Manifests

In general, a new Service Fabric solution (from the Azure Service Fabric SDK project templates) will create an Application Project and a Service Project.

The Application Project contains the ApplicationManifest file in the ApplicationPackageRoot folder, and is named ApplicationManifest.xml.

Outline from Solution Explorer for a Service Fabric Application project

The model of a Service Fabric Application is that the Application may contain one or more Services.

The Service Project (or Projects) contain the ServiceManifest files in their PackageRoot folder. These files are named ServiceManifest.xml.

Outline from Solution Explorer for a Service Fabric Service project

ApplicationManifest

The basic template has a fairly simple structure:

<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     ApplicationTypeName="⟬application-name⟭Type"
                     ApplicationTypeVersion="1.0.0"
                     xmlns="http://schemas.microsoft.com/2011/01/fabric">
  <Parameters>
    <Parameter Name="⟬service-name⟭_InstanceCount"
               DefaultValue="-1" />
  </Parameters>
  <!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion
should match the Name and Version attributes of the ServiceManifest element defined in the
ServiceManifest.xml file. --> <ServiceManifestImport> <ServiceManifestRef ServiceManifestName="⟬service-name⟭Pkg" ServiceManifestVersion="1.0.0" /> <ConfigOverrides /> </ServiceManifestImport> <DefaultServices> <!-- The section below creates instances of service types, when an instance of this application type is created. You can also create one or more instances of service type using the ServiceFabric PowerShell module. The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. --> <Service Name="⟬service-name⟭"> <StatelessService ServiceTypeName="⟬service-name⟭Type" InstanceCount="[⟬service-name⟭_InstanceCount]"> <SingletonPartition /> </StatelessService> </Service> </DefaultServices> </ApplicationManifest>

Parameters:

  • application-name⟭ ::= the name you gave the New Project wizard for the name of the application
  • service-name⟭ ::= the name you gave the New Project wizard for the name of the Service (when you select the type of service)

So far, the only configuration setting I have changed in this file is at

/ApplicationManifest
    /DefaultServices
        /Service[name="⟬service-name⟭"]
            /StatelessService
                @InstanceCount

I’ve changed the value of that attribute to −1 in order to deploy the service to all the available nodes.

As I collect more services in an application, I’ll add entries to the ServiceManifestImport element and probably to the DefaultServices element.

ServiceManifest

The basic template for the ServiceManifest, like the ApplicationManifest, has a simple structure.

<?xml version="1.0"
      encoding="utf-8"?>
<ServiceManifest Name="⟬service-name⟭Pkg"
                 Version="1.0.0"
                 xmlns="http://schemas.microsoft.com/2011/01/fabric"
                 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ServiceTypes>
    <!-- This is the name of your ServiceType. 
         This name must match the string used in RegisterServiceType call in Program.cs. -->
    <StatelessServiceType ServiceTypeName="⟬service-name⟭Type" />
  </ServiceTypes>
  <!-- Code package is your service executable. -->
  <CodePackage Name="Code"
               Version="1.0.0">
    <EntryPoint>
      <ExeHost>
        <Program>⟬service-name⟭.exe</Program>
      </ExeHost>
    </EntryPoint>
  </CodePackage>
  <!-- Config package is the contents of the Config directoy under PackageRoot that contains an 
       independently-updateable and versioned set of custom configuration settings for your service. -->
  <ConfigPackage Name="Config"
                 Version="1.0.0" />
  <Resources>
    <Endpoints>
      <!-- This endpoint is used by the communication listener to obtain the port on which to 
           listen. Please note that if your service is partitioned, this port is shared with 
           replicas of different partitions that are placed in your code. -->
      <Endpoint Name="ServiceEndpoint" />
    </Endpoints>
  </Resources>
</ServiceManifest>

Parameters:

  • service-name⟭ ::= the name you gave the New Project wizard for the name of the Service (when you select the type of service)

So far, I have not made any changes to this file.

The comments in both files are helpful.

Author

Alan McBee

comments powered by Disqus