Slicc
Slicc

Reputation: 3445

Change service fabric config in live environment

I have configured my service fabric services to use Azure Key Vault for configuration. If, after the app is deployed, I change the config in Key Vault, how do I then restart the affected service so it can pick up the new config value?

Or is there another way altogether?

Upvotes: 2

Views: 1297

Answers (2)

Diego Mendes
Diego Mendes

Reputation: 11361

The best way to handle configuration on SF is use your application parameters file for this, if you use a continuous deployment pipeline like VSTS, you could use release variables to set these values for you and deploy a new version of your configuration file and let SF do the rest.

But in case you still need to use Key vault:

if you are using asp.net core, Using Azure Key Vault to store secrets are like loading configuration files, the values are cached until you reload it.

You can use the IConfigurationRoot.Reload() to reload the secrets from your key vault new values. Check it Here

The trick now is to make it automatically you have to:

  • Enable Key Vault Logging to track the changes, this will emit logs once you update the key vault. check it here and here .

  • And then:

    • Create an endpoint in your API to be called and refresh the secrets. Make it secure to avoid abuse.
    • Create an Azure function to process these logs and trigger the endpoint
    • Or:
    • Create a message queue to receive the command and the system read the message to refresh the settings
  • Or:
    • Make a timer to refresh on specific periods(I would not recommended this approach because you might end up with outdated config, but it is easy and useful for quick test scenarios, not production)

Or if you prefer more custom designed solution, you could create your own ConfigurationProvider based on KeyVault and do the cache logic according to your app architecture and you don't have to bother with the rest. Please refer to the Asp.Net source here for this.

Upvotes: 4

LoekD
LoekD

Reputation: 11470

The documented way to provide configuration to your services is by using the 'configuration' part of your application package. As this is versioned, it can be upgraded, without requiring your services to be upgraded or even be restarted.

More info here and here.

Upvotes: 0

Related Questions