Skip to content

Environment variable naming convention for resources not documented #477

@maddymontaquila

Description

@maddymontaquila

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.

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