Migration to Azure App Configuration-(Fluxx)
This document outlines the steps and code changes required to migrate our application’s configuration management to Azure App Configuration. The goal is to centralize runtime configuration values, improve maintainability, and support environment-specific settings with better security and consistency.
The migration involves:
-
Organizing configuration keys into logical groups
-
Introducing a consistent prefix for all runtime keys
-
Moving secret or optional environment variables to dedicated groups
-
Updating how configuration values are accessed in the codebase
-
Synchronizing configuration values in Helm deployment files and Azure App Configuration service
Following this guide will ensure a smooth transition with minimal impact on existing functionality.
Related Pull Requests
1. App Configuration Setup Files
Copy the following files into your service repository:
-
src/internal/createAppConfigOptions.ts -
src/middlware/app.config.middleware.ts -
src/config/app.config.ts
2. Update index.ts to Use the New App Configuration Setup
Add the following during application startup:
3. Update Your Configuration Keys in configurations.ts
Configuration Keys Are Now Grouped
Previously, all environment keys were defined in a single object:
Now the keys are separated into three categories:
These are then merged into ENV_KEYS.
This keeps configuration organized and clarifies where each value comes from.
App Configuration Keys Now Use a Prefix
All runtime configuration keys now include the prefix:
Example changes:
This prevents key collisions across services.
Example:
SQL Credentials Moved to Optional Environment Keys
SQL_USERNAME and SQL_PASSWORD were removed from the main configuration and moved to:
These are only needed when:
-
running locally
-
not using managed identity
Added System Environment Variables
Startup-related environment variables are now grouped under SYSTEM_ENVS.
These variables are required before the application loads runtime configuration.
No Changes Required in Code Usage
Developers should continue using:
Example:
Since ENV_KEYS now merges all key groups, existing usage remains compatible.
4. Move Environment Variable Values to appdevcommon-lz-config
Move the environment variable values to the appdevcommon-lz-config repository for each environment.
Update the following files accordingly:
-
app_config/<env>-eus2-adc-app-appcs-001.yaml -
app_config/<env>-eus2-adc-app-appcs-001.json -
app_config/<env>-eus2-saas-adc-app-appcs-001.json
1. Get the Configuration Values
Locate the configuration values in the service Helm files:
-
values.yml -
<env>-values.yml
Example:
2. Map the Key to the New Config Key
Convert the existing key to the new prefixed format.
Example mapping:
3. Add the Merged Values to the Environment-Specific Config
Add the converted keys to the environment-specific YAML/JSON files in the appdevcommon-lz-config repository.
Example mapping:
Note
Do not add the following values to appdevcommon-lz-config:
-
NODE_ENV -
AZURE_APP_CONFIG_ENDPOINT -
SQL_USERNAME -
SQL_PASSWORD
Also exclude any variables defined in:
-
OPTIONAL_ENV_KEYS -
SYSTEM_ENVS
4. Update Configuration Access in the Service
1. Replace app.lookup() Calls
Replace all app.lookup() calls in the service with the appropriate appConfig methods.
Use:
-
appConfig.get()for string values -
appConfig.getNumber()for numeric values -
appConfig.getBoolean()for boolean values
Example:
Before
After
2. Remove Deprecated Lookup Utilities
Delete references to the following functions:
-
lookUp() -
createLookup() -
prepareLookup()
These may appear in files such as:
-
app.ts -
prepareLookup.ts -
createLookup.ts
Remove the files and any related imports if they are no longer used.
5. Updating .env.local.example and .env.example with Prefixed Keys
As part of migrating to Azure App Configuration, you need to update your local environment example files to reflect the new prefixed configuration keys.
Example:
Steps:
-
Locate
.env.local.exampleand.env.examplefiles** in your repository root. -
Rename all existing keys by adding the prefix
FLUXX_FILE_INTAKE_.For example:
- Leave optional (
OPTIONAL_ENV_KEYS) and system environment (SYSTEM_ENVS) variables unchanged: