IResource

Interface
📦 Aspire.Hosting v17.0.0
interface IResource {
createExecutionConfiguration(): IExecutionConfigurationBuilder;
excludeFromManifest(): IResource;
excludeFromMcp(): IResource;
getResourceName(): string;
getSerializedAnnotation(annotationId: string): string;
hasSerializedAnnotation(annotationId: string): boolean;
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;
subscribeHttpsEndpointsUpdate(callback: (obj: HttpsEndpointUpdateCallbackContext) => Promise<void>): IResource;
withChildRelationship(child: IResource): IResource;
withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise<ExecuteCommandResult>, commandOptions?: CommandOptions): IResource;
withContainerBuildOptions(callback: (arg: ContainerBuildOptionsCallbackContext) => Promise<void>): IResource;
withContainerRegistry(registry: IResource): IResource;
withDisplayOrder(order: number): 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;
withRequiredCommandValidation(command: string, validationCallback: (arg: RequiredCommandValidationContext) => Promise<RequiredCommandValidationResult>, helpLink?: string): IResource;
withResourceTypeDisplayName(resourceTypeDisplayName: string): IResource;
withSerializedAnnotation(
annotationId: string,
json: string): IResource;
withSessionLifetime(): IResource;
withTags(tags: string[]): IResource;
withTerminal(configure?: (obj: TerminalOptions) => Promise<void>): IResource;
withTrait(
name: string,
value: string): IResource;
withUrl(
url: string | 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
Gets a serialized ATS annotation payload from a resource.
getSerializedAnnotation(annotationId: string): string
annotationIdstringThe stable annotation identifier.
string
Determines whether a resource has a serialized ATS annotation with the specified ID.
hasSerializedAnnotation(annotationId: string): boolean
annotationIdstringThe stable annotation identifier.
boolean
Subscribes to the BeforeResourceStarted event.
onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise<void>): IResource
callback(arg: BeforeResourceStartedEvent) => Promise<void>The callback to invoke when the event fires.
IResource
Subscribes to the InitializeResource event.
onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise<void>): IResource
callback(arg: InitializeResourceEvent) => Promise<void>The callback to invoke when the event fires.
IResource
methodonResourceReadybuilder
Subscribes to the ResourceReady event.
onResourceReady(callback: (arg: ResourceReadyEvent) => Promise<void>): IResource
callback(arg: ResourceReadyEvent) => Promise<void>The callback to invoke when the event fires.
IResource
methodonResourceStoppedbuilder
Subscribes to the ResourceStopped event.
onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise<void>): IResource
callback(arg: ResourceStoppedEvent) => Promise<void>The callback to invoke when the event fires.
IResource
Subscribes to the `BeforeStartEvent` and invokes the specified callback when an HTTPS certificate is determined to be available for the resource. This is used to conditionally update endpoint URI schemes or perform other HTTPS-related configuration at startup.
subscribeHttpsEndpointsUpdate(callback: (obj: HttpsEndpointUpdateCallbackContext) => Promise<void>): IResource
callback(obj: HttpsEndpointUpdateCallbackContext) => Promise<void>The callback to invoke when HTTPS is enabled. Receives an `HttpsEndpointUpdateCallbackContext` providing access to the service provider, resource, and application model.
IResource
Sets a child relationship
withChildRelationship(child: IResource): IResource
childIResourceThe child of `builder`.
IResource
methodwithCommandbuilder
Adds a resource command
withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise<ExecuteCommandResult>, commandOptions?: CommandOptions): IResource
namestringThe name of the command. The name uniquely identifies the command.
displayNamestringThe display name visible in UI.
executeCommand(arg: ExecuteCommandContext) => Promise<ExecuteCommandResult>A callback that is executed when the command is executed. The callback is run inside the Aspire host. The callback result is used to indicate success or failure in the UI.
commandOptionsCommandOptionsoptionalOptional configuration for the command.
IResource
Configures container build options for a compute resource using an async callback.
withContainerBuildOptions(callback: (arg: ContainerBuildOptionsCallbackContext) => Promise<void>): IResource
callback(arg: ContainerBuildOptionsCallbackContext) => Promise<void>An async callback to configure container build options.
IResource
Configures the resource to use the specified container registry for container image operations.
withContainerRegistry(registry: IResource): IResource
registryIResourceThe container registry resource builder.
IResource
methodwithDisplayOrderbuilder
Sets the default display order of the resource in lists of resources, such as the dashboard's. A saved ordering takes precedence. Repeated calls replace the order.
withDisplayOrder(order: number): IResource
ordernumberA relative sort key. Higher values appear first, consistent with `DisplayOrder`. Resources without a display order are treated as having an order of 0, so a negative value moves a resource after them.
IResource
Configures custom base images for generated Dockerfiles.
withDockerfileBaseImage(
buildImage?: string,
runtimeImage?: string): IResource
buildImagestringoptionalThe base image to use for the build stage. If null, uses the default build image.
runtimeImagestringoptionalThe base image to use for the runtime stage. If null, uses the default runtime image.
IResource
methodwithExplicitStartbuilder
Prevents resource from starting automatically
withExplicitStart(): IResource
IResource
methodwithHealthCheckbuilder
Adds a health check by key
withHealthCheck(key: string): IResource
keystringThe key for the health check.
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
exitCodenumberoptionalThe completion exit code to treat as successful. Defaults to `0`.
exitCodesnumber[]optionalCompletion exit codes to treat as successful. If no values are provided, `0` is used.
IResource
methodwithIconNamebuilder
Specifies the icon to use when displaying the resource in the dashboard.
withIconName(
iconName: string,
iconVariant?: IconVariant): IResource
iconNamestringThe name of the FluentUI icon to use. See https://aka.ms/fluentui-system-icons for available icons.
iconVariantIconVariantoptional= FilledThe variant of the icon (Regular or Filled). Defaults to Filled.
IResource
methodwithLifetimeOfbuilder
Configures a resource to match the lifetime of another resource.
withLifetimeOf(sourceBuilder: IResource): IResource
sourceBuilderIResourceThe resource builder whose lifetime should be used.
IResource
Configures a resource to use a persistent lifetime that ends when a parent process exits.
withParentProcessLifetime(parentProcessId: number): IResource
parentProcessIdnumberThe ID of the parent process to monitor.
IResource
Sets the parent relationship
withParentRelationship(parent: IResource): IResource
parentIResourceThe parent of `builder`.
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>The callback function to execute during the configuration phase.
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
stepNamestringThe unique name of the pipeline step.
callback(arg: PipelineStepContext) => Promise<void>The callback to execute when the step runs.
dependsOnstring[]optionalOptional step names that this step depends on.
requiredBystring[]optionalOptional step names that require this step.
tagsstring[]optionalOptional tags that categorize this step.
descriptionstringoptionalAn optional human-readable description of the step.
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
resourceBuilderIResourceThe resource builder that the relationship is to.
typestringThe relationship type.
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
commandstringThe command string (file name or path) that should be validated.
helpLinkstringoptionalAn optional help link URL to guide users when the command is missing.
IResource
Declares that a resource requires a specific command/executable to be available on the local machine PATH before it can start, with custom validation logic.
withRequiredCommandValidation(command: string, validationCallback: (arg: RequiredCommandValidationContext) => Promise<RequiredCommandValidationResult>, helpLink?: string): IResource
commandstringThe command string (file name or path) that should be validated.
validationCallback(arg: RequiredCommandValidationContext) => Promise<RequiredCommandValidationResult>A callback that validates the resolved command path. Receives a `RequiredCommandValidationContext` and returns a `RequiredCommandValidationResult`.
helpLinkstringoptionalAn optional help link URL to guide users when the command is missing or fails validation.
IResource
Overrides the human-readable resource type label.
withResourceTypeDisplayName(resourceTypeDisplayName: string): IResource
resourceTypeDisplayNamestringThe type label, such as Redis or PostgreSQL Server.
IResource
Stores a serialized ATS annotation payload on a resource, replacing any existing annotation with the same ID.
withSerializedAnnotation(
annotationId: string,
json: string): IResource
annotationIdstringThe stable annotation identifier.
jsonstringThe serialized JSON payload.
IResource
methodwithSessionLifetimebuilder
Configures a resource to use a session lifetime.
withSessionLifetime(): IResource
IResource
methodwithTagsbuilder
Adds AppHost-defined dashboard tags that users cannot remove. Repeated calls add tags.
withTags(tags: string[]): IResource
tagsstring[]The tags, each up to 50 characters with single spaces between words.
IResource
methodwithTerminalbuilder
Adds an interactive terminal session to a resource with an optional callback to configure its initial dimensions.
withTerminal(configure?: (obj: TerminalOptions) => Promise<void>): IResource
configure(obj: TerminalOptions) => Promise<void>optionalAn optional callback to configure the terminal options.
IResource
methodwithTraitbuilder
Adds immutable, non-sensitive metadata to a resource. Repeated names add multiple values.
withTrait(
name: string,
value: string): IResource
namestringThe case-sensitive trait name.
valuestringThe trait value. Do not include secrets.
IResource
methodwithUrlbuilder
Adds or modifies displayed URLs
withUrl(
url: string | ReferenceExpression,
displayText?: string): IResource
urlstring | ReferenceExpression
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
endpointNamestringThe name of the endpoint to customize the URL for.
callback(obj: ResourceUrlAnnotation) => Promise<void>The callback that will customize the URL.
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>The callback that will customize URLs for the resource.
IResource