How to parameterize configuration files in Service Fabric

This article shows you how to parameterize a configuration file in Service Fabric. If you're not already familiar with the core concepts of managing applications for multiple environments, read Manage applications for multiple environments.

Procedure for parameterizing configuration files

In this example, you override a configuration value using parameters in your application deployment.

  1. Open the <MyService>\PackageRoot\Config\Settings.xml file in your service project.

  2. Set a configuration parameter name and value, for example cache size equal to 25, by adding the following XML:

     <Section Name="MyConfigSection">
       <Parameter Name="CacheSize" Value="25" />
  3. Save and close the file.

  4. Open the <MyApplication>\ApplicationPackageRoot\ApplicationManifest.xml file.

  5. In the ApplicationManifest.xml file, declare a parameter and default value in the Parameters element. It's recommended that the parameter name contains the name of the service (for example, "MyService").

       <Parameter Name="MyService_CacheSize" DefaultValue="80" />
  6. In the ServiceManifestImport section of the ApplicationManifest.xml file, add a ConfigOverrides and ConfigOverride element, referencing the configuration package, the section, and the parameter.

       <ConfigOverride Name="Config">
             <Section Name="MyConfigSection">
                 <Parameter Name="CacheSize" Value="[MyService_CacheSize]" />


In the case where you add a ConfigOverride, Service Fabric always chooses the application parameters or the default value specified in the application manifest.

Next steps

For information about other app management capabilities that are available in Visual Studio, see Manage your Service Fabric applications in Visual Studio.