1
votes

I'm trying to host an existing application as a guest executable in Service Fabric. This work very well, but now I'm facing a problem I don't have a solution for so far.

The application we have is a Windows service build using .NET. It does include an app.config file containing some environment specific configuration. On our current platform we create packages and deploy them using MSDeploy. MSDeploy supports the usage of parameters which can transform the web.config file. This way we can change the configuration based on the environment we deploy on.

How can we achieve this using a guest executable in Service Fabric? The guest executable and app.config are added to the code-package of the sfproj. Is there a way we can transform the app.config when we instantiate a new instance of the Service Fabric application? I know of the config package and ApplicationParameter files but they can't transform app.config files, can they? Is there another way we can do this?

2

2 Answers

3
votes

One way you could possibly achieve this is by adding a SetupEntryPoint to the Service Manifest to run a custom script. In the script (e.g. PowerShell), load the settings from the Settings.xml (Configuration Package) and use these values to replace the placeholders in your app.config file.

Then you can use standard Service Fabric parameter files (https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-how-to-parameterize-configuration-files) to set the values for the different environments.

0
votes

You absolutely can transform the app.config. There is a NuGet package https://github.com/acottais/msbuild.xdt You will have to add the transforms via the command line but they work just like the web.config transforms.
It also works for custom configurations.