Environment variable interpolation
The ${VAR} and ${VAR:-default} syntax Rayfin supports inside rayfin.yml — usage, .env file location, resolution priority, type coercion, and error handling.
rayfin.yml supports environment variable interpolation using ${VAR} /
${VAR:-default} shell-style syntax, so you can keep environment-specific values
(connection strings, API keys, URLs) out of the committed config file.
Syntax
${VAR}— simple substitution. Fails if the variable is unset or empty.${VAR:-default}— substitution with a default if the variable is unset or empty.
By convention, :- treats both an undefined variable and an empty string the same way —
both fall through to the default.
# .env
DEFINED=value
EMPTY=
# UNDEFINED is not set# rayfin.yml — results:
config1: ${DEFINED} # → "value" (uses the variable)
config2: ${EMPTY:-fallback} # → "fallback" (empty, uses default)
config3: ${UNDEFINED:-fallback} # → "fallback" (unset, uses default)
config4: ${DEFINED:-fallback} # → "value" (defined, ignores default)
config5: ${EMPTY} # → Error! (empty without default)
config6: ${UNDEFINED} # → Error! (unset without default)Usage
Basic substitution
services:
data:
dialect: ${DB_DIALECT}DB_DIALECT=mssqlDefault values
services:
data:
dialect: ${DB_DIALECT:-mssql}Partial interpolation
Combine static text with a variable:
services:
auth:
allowedRedirectUris:
- https://${APP_HOSTNAME}/callback.env file location
By default, Rayfin loads variables from rayfin/.env. Override this three ways, highest
priority first:
-
CLI flag:
npx rayfin up --env-file /production.env -
Environment variable:
export RAYFIN_ENV_FILE='/staging.env' npx rayfin up -
Default:
rayfin/.env.
Resolution priority
- Shell environment variables (if non-empty).
- Variables from the resolved
.envfile (if non-empty). - Default values, when specified with
:-syntax and the variable is unset or empty. - Error, if the variable is unset or empty and no default is given.
This is the same priority order used everywhere else Rayfin resolves environment values —
see Environment variables
for the canonical reference, including how it composes with --env-file.
Type coercion
Interpolated values are coerced to the matching YAML type only when the entire value is a single variable reference:
services:
auth:
expiryInMinutes: ${TOKEN_EXPIRY} # becomes the number 60, not the string "60"
data:
enabled: ${DATA_ENABLED} # becomes the boolean true, not the string "true"TOKEN_EXPIRY=60
DATA_ENABLED=truePartial interpolation always produces a string, even when the referenced variable looks numeric:
folder: build-${BUILD_NUMBER} # → the string "build-42"Security best practices
- Never commit
.envfiles — they hold secrets and environment-specific values.rayfin/.envis gitignored by default. - Provide
rayfin/.env.example— document required variables for other developers with placeholder values. - Use shell environment variables in CI/CD — override
.envwith build and deployment secrets rather than checking a CI-specific.envfile into the repo. - Omit default values for required configuration — a variable with no
:-default fails fast instead of silently deploying with a wrong value.
Error handling
A missing required variable fails with a specific, actionable message rather than a silent fallback:
❌ Environment variable 'DB_HOST' referenced in rayfin.yml (services.data.host) is not defined.
Set it in .env file or shell environment.Update my rayfin/rayfin.yml so services.data.dialect reads from a DB_DIALECT variable with
mssql as the default, add DB_DIALECT to rayfin/.env.example with a comment explaining it,
and confirm the actual value in rayfin/.env still resolves correctly with
`npx rayfin up --dry-run`.Environment variables
The canonical, exhaustive reference for every environment variable the Rayfin CLI and runtime read or write — frontend, tooling, feature flags, and file locations.
SDK
Which @microsoft/rayfin-* package to install for each capability, how they depend on each other, and version notes for the whole family.