Skip to content

Environment variable naming convention for resources not documented #477

Closed

Description

Bug Description

Aspire transforms resource names into environment variable prefixes using a specific convention, but this convention is not clearly documented. When a resource is named with hyphens (e.g., foundry-demo-proj), the resulting environment variable prefix is FOUNDRY_DEMO_PROJ (uppercased, hyphens replaced with underscores). Properties are appended as suffixes (e.g., _URI, _MODELNAME).

Current Behavior

There is no clear documentation explaining the resource name → environment variable transformation rules. Users must discover the naming convention by trial and error or by inspecting the Aspire dashboard.

Expected Behavior

The docs should include a section explaining:

  1. Resource names are uppercased
  2. Hyphens (-) are replaced with underscores (_)
  3. Properties are appended as _{PROPERTY} (e.g., _URI, _MODELNAME, _CONNECTIONSTRING)
  4. Connection strings use the format ConnectionStrings__{resource-name}
  5. Examples showing the mapping, e.g.: resource "my-db" → env vars MY_DB_HOST, MY_DB_PORT, ConnectionStrings__my-db

Page URL

Could be added to the app model fundamentals or a dedicated "environment variables" reference page.

Additional Context

We spent significant debugging time because our Python app referenced PROJ_URI when the actual variable was FOUNDRY_DEMO_PROJ_URI (resource was named foundry-demo-proj). This is especially impactful for non-.NET service projects (Python, Node.js) where developers must manually read environment variables rather than using typed Aspire client integrations.

Activity

  1. IEvangelist commented on Jun 2, 2026

    @IEvangelist
    Member

    Triage → @Copilot

    Scope — add a documented reference for Aspire's resource-name → environment-variable transformation rules, with worked examples covering hyphenated names and connection strings.

    Where to add

    • Primary: src/frontend/src/content/docs/app-host/ — add a new short reference page (suggested filename environment-variables.mdx) and link it from the App Host fundamentals nav so it's discoverable.
    • Cross-link from any existing page that documents WithEnvironment/WithReference/connection-string consumption so a reader looking up env-var usage finds it.

    Content (use the spec from the issue body verbatim, expanded into prose + an examples table):

    1. Resource names are uppercased.
    2. Hyphens (-) are replaced with underscores (_).
    3. Property values are appended as _{PROPERTY} (e.g. _URI, _MODELNAME, _CONNECTIONSTRING).
    4. Connection strings use the format ConnectionStrings__{resource-name} (note: the resource-name retains its original casing/hyphens for the connection-string key).
    5. End with the worked example from the issue: resource "foundry-demo-proj" → env vars FOUNDRY_DEMO_PROJ_URI, FOUNDRY_DEMO_PROJ_MODELNAME, ConnectionStrings__foundry-demo-proj. Call out that this is especially important for non-.NET service projects (Python, Node.js, etc.) that read env vars directly rather than going through a typed client integration.

    Acceptance

    • New page renders, is reachable from the App Host nav, and uses Aspire docs MDX conventions (frontmatter, code blocks with language tags, etc.).
    • Example table covers at least: single-word resource, hyphenated resource, connection-string variant.
    • npm run build in src/frontend/ passes.
    • JA mirror under src/frontend/src/content/docs/ja/app-host/ either gets a translated copy or a clearly-marked TODO(translate) placeholder linking back to the EN page.
    • No unrelated changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions