0
votes
  1. Using 5.1.163 version of service fabric run time.
  2. Created a service fabric application with one stateless web api (i.e. using owin communication listener).
  3. Modified the generated code so that listening endpoint to contain partition id/instance id/new_guid (just as is the case for stateful services). This should allow me to create another app instance so that I can have multi-tenancy at application level.
  4. By default, Local.xml file is set to 1 instance for this service.
  5. Deployed it to local machine by F5. Verified that it is deployed to only one instance.
  6. Verified that service is working fine.
  7. Navigated to local service fabric explorer and clicked on the Cluster/Application/AppType node. Clicked on 'Create app instance'.
  8. It successfully created 2nd app instance.
  9. However in this new instance, the service is deployed to all 5 nodes.

I was expecting it deploy the service instance only one node. Is this a bug? But only in this version of service fabric?

1

1 Answers

1
votes

When you deploy a Service Fabric application using Visual Studio (or from PowerShell) you use the Deploy-FabricApplication.ps1 that is generated for your application and found in /scripts under your SF project. This script does two things (mainly):

  1. Create/update the application type
  2. Create a new/upgrade existing instance of the application type

The second part there is similar to what you do in the SF Explorer, except this one also considers the publisher profile file you supply. The PS-script actually reads your publisher profile xml files and extracts any parameters in there to a hashset (a dictionary) and passes that as an argument in step 2.

You can create an instance of an SF application type using the PS cmdlets (alternatively you can use FabricClient). The following command does this: New-ServiceFabricApplication. Here you have the chance to supply your own application parameters, including instance count for services in your new application instance (if you have a dynamic parameter for that in your application manifest).

So, when you use the SF explorer to create a new application instance you cannot control how that instance is created, it is always using the default parameter values as specified directly in ApplicationManifest.xml, not values you have specified in your publisher profiles (local1, local5, cloud, etc.).

To controll the creation, run New-ServiceFabricApplication with yor parameters as a hashset.