I have a service in Service Fabric containing an Environment Variable defined in the service manifest that I want to alter dynamically after deployment. What is the best way to do so?
As far as I've been able to tell this necessarily involves updating the application and creating a new version for the service.
<CodePackage Name="MyCode" Version="CodeVersion1">
<EnvironmentVariables>
<EnvironmentVariable Name="MyEnvVariable" Value="DefaultValue"/>
<EnvironmentVariable Name="HttpGatewayPort" Value="19080"/>
</EnvironmentVariables>
</CodePackage>
<ServiceManifestImport>
<ServiceManifestVersion="1.0.0" />
<EnvironmentOverrides CodePackageRef="MyCode">
<EnvironmentVariable Name="MyEnvVariable" Value="OverrideValue"/>
</EnvironmentOverrides>
</ServiceManifestImport>
<ServiceManifestImport>
<ServiceManifestVersion="1.0.0" />
<EnvironmentOverrides CodePackageRef="MyCode">
<EnvironmentVariable Name="MyEnvVariable" Value="[MyEnvVariableOverride]"/>
</EnvironmentOverrides>
</ServiceManifestImport>
and
<Parameters>
<Parameter Name="MyEnvVariableOverride" DefaultValue="DefaultOverrideValue" />
</Parameters>
ApplicationParameters hashtable (in PS - mapping of parameter name to parameter value). For example you would set "MyEnvVariableOverride" to "FinalValue". This will flow down and cause the environment variable value that the service sees to change. Note that changing environment variables requires that the process restart.Relevant docs: 1, 2, 3, 4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With