Skip to content
DocsTry Aspire
DocsTry

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
methodexcludeFromManifestbuilder
Excludes a resource from being published to the manifest.
excludeFromManifest(): IResource
IResource
methodexcludeFromMcpbuilder
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
Subscribes to the InitializeResource event.
onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise<void>): IResource
callback(arg: InitializeResourceEvent) => Promise<void>
IResource
methodonResourceReadybuilder
Subscribes to the ResourceReady event.
onResourceReady(callback: (arg: ResourceReadyEvent) => Promise<void>): IResource
callback(arg: ResourceReadyEvent) => Promise<void>
IResource
methodonResourceStoppedbuilder
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
childIResource
IResource
methodwithCommandbuilder
Adds a resource command
withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise<ExecuteCommandResult>, commandOptions?: CommandOptions): IResource
namestring
displayNamestring
executeCommand(arg: ExecuteCommandContext) => Promise<ExecuteCommandResult>
commandOptionsCommandOptionsoptional
IResource
Configures the resource to use the specified container registry for container image operations.
withContainerRegistry(registry: IResource): IResource
registryIResource
IResource
Configures custom base images for generated Dockerfiles.
withDockerfileBaseImage(
buildImage?: string,
runtimeImage?: string): IResource
buildImagestringoptional
runtimeImagestringoptional
IResource
methodwithExplicitStartbuilder
Prevents resource from starting automatically
withExplicitStart(): IResource
IResource
methodwithHealthCheckbuilder
Adds a health check by key
withHealthCheck(key: string): IResource
keystring
IResource
methodwithHiddenbuilder
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
exitCodenumberoptional
exitCodesnumber[]optional
IResource
methodwithIconNamebuilder
Specifies the icon to use when displaying the resource in the dashboard.
withIconName(
iconName: string,
iconVariant?: IconVariant): IResource
iconNamestring
iconVariantIconVariantoptional= Filled
IResource
methodwithLifetimeOfbuilder
Configures a resource to match the lifetime of another resource.
withLifetimeOf(sourceBuilder: IResource): IResource
sourceBuilderIResource
IResource
Configures a resource to use a persistent lifetime that ends when a parent process exits.
withParentProcessLifetime(parentProcessId: number): IResource
parentProcessIdnumber
IResource
Sets the parent relationship
withParentRelationship(parent: IResource): IResource
parentIResource
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
stepNamestring
callback(arg: PipelineStepContext) => Promise<void>
dependsOnstring[]optional
requiredBystring[]optional
tagsstring[]optional
descriptionstringoptional
IResource
methodwithProcessCommandbuilder
Adds a command to the resource that starts a local process when invoked.
withProcessCommand(
commandName: string,
displayName: string,
options: ProcessCommandExportOptions): IResource
commandNamestring
displayNamestring
optionsProcessCommandExportOptions
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
commandNamestring
displayNamestring
createProcessSpec(arg: ExecuteCommandContext) => Promise<ProcessCommandSpecExportData>
optionsProcessCommandResultExportOptionsoptional
IResource
methodwithRelationshipbuilder
Adds a relationship to another resource using its builder.
withRelationship(
resourceBuilder: IResource,
type: string): IResource
resourceBuilderIResource
typestring
IResource
methodwithRequiredCommandbuilder
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
commandstring
helpLinkstringoptional
IResource
methodwithSessionLifetimebuilder
Configures a resource to use a session lifetime.
withSessionLifetime(): IResource
IResource
methodwithUrlbuilder
Adds or modifies displayed URLs
withUrl(
url: ReferenceExpression,
displayText?: string): IResource
urlReferenceExpression
displayTextstringoptional
IResource
methodwithUrlForEndpointbuilder
Registers a callback to update the URL displayed for the endpoint with the specified name.
withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise<void>): IResource
endpointNamestring
callback(obj: ResourceUrlAnnotation) => Promise<void>
IResource
methodwithUrlsbuilder
Registers a callback to customize the URLs displayed for the resource.
withUrls(callback: (obj: ResourceUrlsCallbackContext) => Promise<void>): IResource
callback(obj: ResourceUrlsCallbackContext) => Promise<void>
IResource