IResourceWithEndpoints

Interface
📦 Aspire.Hosting v17.0.0
interface IResourceWithEndpoints {
asHttp2Service(): IResourceWithEndpoints;
getEndpoint(name: string): EndpointReference;
onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise<void>): IResourceWithEndpoints;
withEndpoint(
port?: number,
targetPort?: number,
scheme?: string,
name?: string,
env?: string,
isProxied?: boolean,
isExternal?: boolean,
protocol?: ProtocolType): IResourceWithEndpoints;
withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise<void>, createIfNotExists?: boolean): IResourceWithEndpoints;
withEndpointProxySupport(proxyEnabled: boolean): IResourceWithEndpoints;
withExternalHttpEndpoints(): IResourceWithEndpoints;
withHttpCommand(
path: string,
displayName: string,
options?: HttpCommandExportOptions): IResourceWithEndpoints;
withHttpEndpoint(
port?: number,
targetPort?: number,
name?: string,
env?: string,
isProxied?: boolean): IResourceWithEndpoints;
withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise<void>, name?: string, createIfNotExists?: boolean): IResourceWithEndpoints;
withHttpHealthCheck(
path?: string,
statusCode?: number,
endpointName?: string): IResourceWithEndpoints;
withHttpProbe(
probeType: ProbeType,
path?: string,
initialDelaySeconds?: number,
periodSeconds?: number,
timeoutSeconds?: number,
failureThreshold?: number,
successThreshold?: number,
endpointName?: string): IResourceWithEndpoints;
withHttpsEndpoint(
port?: number,
targetPort?: number,
name?: string,
env?: string,
isProxied?: boolean): IResourceWithEndpoints;
withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise<void>, name?: string, createIfNotExists?: boolean): IResourceWithEndpoints;
withMcpServer(
path?: string,
endpointName?: string): IResourceWithEndpoints;
}

Methods

methodasHttp2Servicebuilder
Configures a resource to mark all endpoints' transport as HTTP/2. This is useful for HTTP/2 services that need prior knowledge.
asHttp2Service(): IResourceWithEndpoints
IResourceWithEndpoints
Gets an endpoint reference
getEndpoint(name: string): EndpointReference
namestringThe name of the endpoint.
EndpointReference
Subscribes to the ResourceEndpointsAllocated event.
onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise<void>): IResourceWithEndpoints
callback(arg: ResourceEndpointsAllocatedEvent) => Promise<void>The callback to invoke when the event fires.
IResourceWithEndpoints
methodwithEndpointbuilder
Adds a network endpoint
withEndpoint(
port?: number,
targetPort?: number,
scheme?: string,
name?: string,
env?: string,
isProxied?: boolean,
isExternal?: boolean,
protocol?: ProtocolType): IResourceWithEndpoints
portnumberoptionalAn optional port. This is the port that will be given to other resource to communicate with this resource.
targetPortnumberoptionalThis is the port the resource is listening on. If the endpoint is used for the container, it is the container port.
schemestringoptionalAn optional scheme e.g. (http/https). Defaults to the `protocol` argument if it is defined or "tcp" otherwise.
namestringoptionalAn optional name of the endpoint. Defaults to the scheme name if not specified.
envstringoptionalAn optional name of the environment variable that will be used to inject the `targetPort`. If the target port is null one will be dynamically generated and assigned to the environment variable.
isProxiedbooleanoptionalSpecifies if the endpoint will be proxied by DCP. Defaults to `null`.
isExternalbooleanoptionalIndicates that this endpoint should be exposed externally at publish time.
protocolProtocolTypeoptionalNetwork protocol: TCP or UDP are supported today, others possibly in future.
IResourceWithEndpoints
Updates a named endpoint via callback
withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise<void>, createIfNotExists?: boolean): IResourceWithEndpoints
endpointNamestring
callback(obj: EndpointUpdateContext) => Promise<void>
createIfNotExistsbooleanoptional= True
IResourceWithEndpoints
Set whether a resource can use proxied endpoints or whether they should be disabled for all endpoints belonging to the resource. If set to `false`, endpoints belonging to the resource will ignore the configured proxy settings and run proxy-less.
withEndpointProxySupport(proxyEnabled: boolean): IResourceWithEndpoints
proxyEnabledbooleanShould endpoints for the resource support using a proxy?
IResourceWithEndpoints
Marks existing http or https endpoints on a resource as external.
withExternalHttpEndpoints(): IResourceWithEndpoints
IResourceWithEndpoints
methodwithHttpCommandbuilder
Adds an HTTP resource command
withHttpCommand(
path: string,
displayName: string,
options?: HttpCommandExportOptions): IResourceWithEndpoints
pathstring
displayNamestring
optionsHttpCommandExportOptionsoptional
IResourceWithEndpoints
methodwithHttpEndpointbuilder
Adds an HTTP endpoint
withHttpEndpoint(
port?: number,
targetPort?: number,
name?: string,
env?: string,
isProxied?: boolean): IResourceWithEndpoints
portnumberoptionalAn optional port. This is the port that will be given to other resource to communicate with this resource.
targetPortnumberoptionalThis is the port the resource is listening on. If the endpoint is used for the container, it is the container port.
namestringoptionalAn optional name of the endpoint. Defaults to "http" if not specified.
envstringoptionalAn optional name of the environment variable to inject.
isProxiedbooleanoptionalSpecifies if the endpoint will be proxied by DCP. Defaults to `null`.
IResourceWithEndpoints
Updates an HTTP endpoint via callback
withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise<void>, name?: string, createIfNotExists?: boolean): IResourceWithEndpoints
callback(obj: EndpointUpdateContext) => Promise<void>
namestringoptional
createIfNotExistsbooleanoptional= True
IResourceWithEndpoints
methodwithHttpHealthCheckbuilder
Adds a health check to the resource which is mapped to a specific endpoint.
withHttpHealthCheck(
path?: string,
statusCode?: number,
endpointName?: string): IResourceWithEndpoints
pathstringoptionalThe relative path to test.
statusCodenumberoptionalThe result code to interpret as healthy.
endpointNamestringoptionalThe name of the endpoint to derive the base address from.
IResourceWithEndpoints
methodwithHttpProbebuilder
Adds an HTTP health probe to the resource
withHttpProbe(
probeType: ProbeType,
path?: string,
initialDelaySeconds?: number,
periodSeconds?: number,
timeoutSeconds?: number,
failureThreshold?: number,
successThreshold?: number,
endpointName?: string): IResourceWithEndpoints
probeTypeProbeType
pathstringoptional
initialDelaySecondsnumberoptional
periodSecondsnumberoptional
timeoutSecondsnumberoptional
failureThresholdnumberoptional
successThresholdnumberoptional
endpointNamestringoptional
IResourceWithEndpoints
methodwithHttpsEndpointbuilder
Adds an HTTPS endpoint
withHttpsEndpoint(
port?: number,
targetPort?: number,
name?: string,
env?: string,
isProxied?: boolean): IResourceWithEndpoints
portnumberoptionalAn optional host port.
targetPortnumberoptionalThis is the port the resource is listening on. If the endpoint is used for the container, it is the container port.
namestringoptionalAn optional name of the endpoint. Defaults to "https" if not specified.
envstringoptionalAn optional name of the environment variable to inject.
isProxiedbooleanoptionalSpecifies if the endpoint will be proxied by DCP. Defaults to `null`.
IResourceWithEndpoints
Updates an HTTPS endpoint via callback
withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise<void>, name?: string, createIfNotExists?: boolean): IResourceWithEndpoints
callback(obj: EndpointUpdateContext) => Promise<void>
namestringoptional
createIfNotExistsbooleanoptional= True
IResourceWithEndpoints
methodwithMcpServerbuilder
Marks the resource as hosting a Model Context Protocol (MCP) server on the specified endpoint.
withMcpServer(
path?: string,
endpointName?: string): IResourceWithEndpoints
pathstringoptional= /mcpAn optional path to append to the endpoint URL when forming the MCP server address. Defaults to `"/mcp"`. A leading slash is added if missing. A null or empty value uses the endpoint URL without an additional path.
endpointNamestringoptionalAn optional name of the endpoint that hosts the MCP server. If not specified, selects the endpoint named `https`, falling back to the endpoint named `http`. Names are matched case-insensitively; endpoints with other names must be selected explicitly, regardless of their URI scheme.
IResourceWithEndpoints