Skip to content
Docs Try Aspire
Docs Try

IResource

Interface
📦 Aspire.Hosting v13.4.0
interface IResource {
createExecutionConfiguration(): IExecutionConfigurationBuilder;
excludeFromManifest(): IResource;
excludeFromMcp(): IResource;
getResourceName(): string;
onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise<void>): IResource;
onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise<void>): IResource;
onResourceReady(callback: (arg: ResourceReadyEvent) => Promise<void>): IResource;
onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise<void>): IResource;
withChildRelationship(child: IResource): IResource;
withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise<ExecuteCommandResult>, commandOptions?: CommandOptions): IResource;
withContainerRegistry(registry: IResource): IResource;
withDockerfileBaseImage(
buildImage?: string,
runtimeImage?: string): IResource;
withExplicitStart(): IResource;
withHealthCheck(key: string): IResource;
withHidden(): IResource;
withHiddenOnCompletion(
exitCode?: number,
exitCodes?: number[]): IResource;
withIconName(
iconName: string,
iconVariant?: IconVariant): IResource;
withLifetimeOf(sourceBuilder: IResource): IResource;
withParentProcessLifetime(parentProcessId: number): IResource;
withParentRelationship(parent: IResource): IResource;
withPersistentLifetime(): IResource;
withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise<void>): IResource;
withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise<void>, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): IResource;
withProcessCommand(
commandName: string,
displayName: string,
options: ProcessCommandExportOptions): IResource;
withProcessCommandFactory(commandName: string, displayName: string, createProcessSpec: (arg: ExecuteCommandContext) => Promise<ProcessCommandSpecExportData>, options?: ProcessCommandResultExportOptions): IResource;
withRelationship(
resourceBuilder: IResource,
type: string): IResource;
withRequiredCommand(
command: string,
helpLink?: string): IResource;
withSessionLifetime(): IResource;
withUrl(
url: ReferenceExpression,
displayText?: string): IResource;
withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise<void>): IResource;
withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise<void>): IResource;
}

Methods

Creates an execution configuration builder for the specified resource.
createExecutionConfiguration(): IExecutionConfigurationBuilder
IExecutionConfigurationBuilder
method excludeFromManifest builder
Excludes a resource from being published to the manifest.
excludeFromManifest(): IResource
IResource
method excludeFromMcp builder
Exclude the resource from MCP operations using the Aspire MCP server. The resource is excluded from results that return resources, console logs and telemetry.
excludeFromMcp(): IResource
IResource
Gets the name of the resource from a builder.
getResourceName(): string
string
Subscribes to the BeforeResourceStarted event.
onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise<void>): IResource
callback (arg: BeforeResourceStartedEvent) => Promise<void>
IResource
method onInitializeResource builder
Subscribes to the InitializeResource event.
onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise<void>): IResource
callback (arg: InitializeResourceEvent) => Promise<void>
IResource
method onResourceReady builder
Subscribes to the ResourceReady event.
onResourceReady(callback: (arg: ResourceReadyEvent) => Promise<void>): IResource
callback (arg: ResourceReadyEvent) => Promise<void>
IResource
method onResourceStopped builder
Subscribes to the ResourceStopped event.
onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise<void>): IResource
callback (arg: ResourceStoppedEvent) => Promise<void>
IResource
Sets a child relationship
withChildRelationship(child: IResource): IResource
child IResource
IResource
method withCommand builder
Adds a resource command
withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise<ExecuteCommandResult>, commandOptions?: CommandOptions): IResource
name string
displayName string
executeCommand (arg: ExecuteCommandContext) => Promise<ExecuteCommandResult>
commandOptions CommandOptions optional
IResource
Configures the resource to use the specified container registry for container image operations.
withContainerRegistry(registry: IResource): IResource
registry IResource
IResource
Configures custom base images for generated Dockerfiles.
withDockerfileBaseImage(
buildImage?: string,
runtimeImage?: string): IResource
buildImage string optional
runtimeImage string optional
IResource
method withExplicitStart builder
Prevents resource from starting automatically
withExplicitStart(): IResource
IResource
method withHealthCheck builder
Adds a health check by key
withHealthCheck(key: string): IResource
key string
IResource
method withHidden builder
Hides the resource from default resource lists
withHidden(): IResource
IResource
Hides the resource from default resource lists after successful completion
withHiddenOnCompletion(
exitCode?: number,
exitCodes?: number[]): IResource
exitCode number optional
exitCodes number[] optional
IResource
method withIconName builder
Specifies the icon to use when displaying the resource in the dashboard.
withIconName(
iconName: string,
iconVariant?: IconVariant): IResource
iconName string
iconVariant IconVariant optional = Filled
IResource
method withLifetimeOf builder
Configures a resource to match the lifetime of another resource.
withLifetimeOf(sourceBuilder: IResource): IResource
sourceBuilder IResource
IResource
Configures a resource to use a persistent lifetime that ends when a parent process exits.
withParentProcessLifetime(parentProcessId: number): IResource
parentProcessId number
IResource
Sets the parent relationship
withParentRelationship(parent: IResource): IResource
parent IResource
IResource
Configures a resource to use a persistent lifetime.
withPersistentLifetime(): IResource
IResource
Registers a callback to be executed during the pipeline configuration phase, allowing modification of step dependencies and relationships.
withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise<void>): IResource
callback (obj: PipelineConfigurationContext) => Promise<void>
IResource
Adds a pipeline step to the resource that will be executed during deployment.
withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise<void>, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): IResource
stepName string
callback (arg: PipelineStepContext) => Promise<void>
dependsOn string[] optional
requiredBy string[] optional
tags string[] optional
description string optional
IResource
method withProcessCommand builder
Adds a command to the resource that starts a local process when invoked.
withProcessCommand(
commandName: string,
displayName: string,
options: ProcessCommandExportOptions): IResource
commandName string
displayName string
options ProcessCommandExportOptions
IResource
Adds a command to the resource that starts a local process created by a callback when invoked.
withProcessCommandFactory(commandName: string, displayName: string, createProcessSpec: (arg: ExecuteCommandContext) => Promise<ProcessCommandSpecExportData>, options?: ProcessCommandResultExportOptions): IResource
commandName string
displayName string
createProcessSpec (arg: ExecuteCommandContext) => Promise<ProcessCommandSpecExportData>
options ProcessCommandResultExportOptions optional
IResource
method withRelationship builder
Adds a relationship to another resource using its builder.
withRelationship(
resourceBuilder: IResource,
type: string): IResource
resourceBuilder IResource
type string
IResource
method withRequiredCommand builder
Declares that a resource requires a specific command/executable to be available on the local machine PATH before it can start.
withRequiredCommand(
command: string,
helpLink?: string): IResource
command string
helpLink string optional
IResource
method withSessionLifetime builder
Configures a resource to use a session lifetime.
withSessionLifetime(): IResource
IResource
method withUrl builder
Adds or modifies displayed URLs
withUrl(
url: ReferenceExpression,
displayText?: string): IResource
url ReferenceExpression
displayText string optional
IResource
method withUrlForEndpoint builder
Registers a callback to update the URL displayed for the endpoint with the specified name.
withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise<void>): IResource
endpointName string
callback (obj: ResourceUrlAnnotation) => Promise<void>
IResource
method withUrls builder
Registers a callback to customize the URLs displayed for the resource.
withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise<void>): IResource
callback (obj: ResourceUrlsCallbackContext) => Promise<void>
IResource