Aspirerelease/13.6
Watch Aspire live streamsDocsTry Aspire
Watch Aspire live streamsDocsTry

WithReference

Definition

Term type
API method

Supplies a consuming resource with connection strings or service endpoint configuration from another resource.

Also known as
withReference, resource reference

WithReference in C# and withReference in TypeScript connect the configuration of resources. The information supplied depends on the referenced resource: a database can provide a connection string, while a service can provide named endpoints for service discovery.

A database reference typically becomes ConnectionStrings__<name> in the consuming process’s environment. Service endpoint references supply service discovery configuration instead; a single reference does not necessarily provide both forms.

A reference does not guarantee startup order or readiness. Use an explicit wait when required, and configure the consuming application’s client or service discovery support to read the supplied configuration.

Practical example

Give an API a reference to a named PostgreSQL database to supply its connection string. Add WaitFor separately if startup must wait for readiness.