1
votes

Azure Service Fabric applications have an ApplicationParameters folder with XML config files targeting different deployment locations. The settings in these files seem to deal with the number of instances/partitions of the contained actors and services; I have not seen examples of these settings affecting actor or service logic.

Additionally, reliable services and reliable actors can specify a configuration package in the ServiceManifest.xml file, which points to a folder containing a Settings.xml file. You are able to create custom configuration sections in Settings.xml and gain access to them via the service's/actor's ConfigurationPackage through ServiceInitializationParameters.CodePackageActivationContext.GetConfigurationPackageObject(). Unlike the configuration at the application level, these configuration files do not seem to easily target specific deployment locations.

What is the proper way to tailor actor/service logic via configuration files that target deployment locations? For example, if your service is dependent on an external API with different URLs for development vs. production environments, how can these be established easily with config files? If the ApplicationParameters files are the answer, how do you programmatically access this information from the actor or service? If custom sections within the Settings.xml file is the answer, how does the actor/service know which environment it is in?

1

1 Answers

4
votes

Take a look at the "Per-environment service configuration settings" section here: Managing application parameters for multiple environments.

In short, you can create a ConfigOverride when importing the service manifest to the application manifest. Suppose that you have the following setting in the Settings.xml for the Stateful1 service:

<Section Name="MyConfigSection">
  <Parameter Name="MaxQueueSize" Value="25" />
</Section>

In the application manifest, you would specify the following:

<ServiceManifestImport>
    <ServiceManifestRef ServiceManifestName="Stateful1Pkg" ServiceManifestVersion="1.0.0" />
    <ConfigOverrides>
       <ConfigOverride Name="Config">
           <Settings>
              <Section Name="MyConfigSection">
                  <Parameter Name="MaxQueueSize" Value="[Stateful1_MaxQueueSize]" />
              </Section>
           </Settings>
       </ConfigOverride>
    </ConfigOverrides>
</ServiceManifestImport>

You can then specify the application/environment-specific value for MaxQueueSize using application parameters.