Search code examples
azure-service-fabric

Service Fabric: Change settings during continuous deployment


I have a SFC that getting deployed to different staging environments. The services have some settings parameters on the settings files. The values of these settings change depending on the staging variables.

I've read this article Manage application parameters for multiple environments but there is not clear what with is meant with Environment. Is it number and type of nodes or the staging env.

How I can change those values from a Release/Build definition? Is there ApplicationParameters transformation just like in Web.config?

Thanks


Solution

  • In service fabric, your Application will have one ApplicationParameter file per environment, and also, one PublishProfile. Your publish profile will define some deployment configurations, one of these configurations is the ApplicationParameter file.

    I'll assume you are using VSTS to deploy your cluster. You will add a service fabric deployment step, it will require a few settings, one of these is the publish profile path.

    To make it dynamic, I'd recommend you to name your PublishProfile the same way you name your environments, and use the environment name to get the publish profile.

    Summary:

    • VSTS Release will run the Service Fabric Deployment Step.
    • SF Dep. Step will use the environment name to find the publish profile(Example: Environment=Prod -> PublishProfile=Prod.xml)
    • PublishProfile will point to an application parameter file
    • The application parameter file will have the settings applicable to that environment(I recommend to use the same naming pattern here Prod.xml, to ease maintenance)

    With this configuration, you can use the same release definition to deploy the application into multiple environments, if a new environment is created, the only thing you have to define is the PublishProfile and ApplicationParamenter files.