# IResource

- Module: [Aspire.Hosting](/reference/api/typescript/aspire.hosting.md)
- Version: `13.2.0`
- Kind: `interface`
- Source: [GitHub](https://github.com/microsoft/aspire)

## Definition

```typescript
interface IResource {
  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;
  withIconName(
      iconName: string,
      iconVariant?: IconVariant): IResource;
  withParentRelationship(parent: IResource): IResource;
  withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise<void>): IResource;
  withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise<void>): IResource;
  withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise<void>, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): IResource;
  withRequiredCommand(
      command: string,
      helpLink?: string): IResource;
  withUrl(
      url: string,
      displayText?: string): IResource;
  withUrlExpression(
      url: ReferenceExpression,
      displayText?: string): IResource;
  withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise<void>): IResource;
  withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise<void>): IResource;
  withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise<void>): IResource;
}
```

## Methods

- [excludeFromManifest](/reference/api/typescript/aspire.hosting/iresource/excludefrommanifest.md) -- `method` -- Excludes the resource from the deployment manifest
    ```typescript
  excludeFromManifest(): IResource
  ```
- [excludeFromMcp](/reference/api/typescript/aspire.hosting/iresource/excludefrommcp.md) -- `method` -- Excludes the resource from MCP server exposure
    ```typescript
  excludeFromMcp(): IResource
  ```
- [getResourceName](/reference/api/typescript/aspire.hosting/iresource/getresourcename.md) -- `method` -- Gets the resource name
    ```typescript
  getResourceName(): string
  ```
- [onBeforeResourceStarted](/reference/api/typescript/aspire.hosting/iresource/onbeforeresourcestarted.md) -- `method` -- Subscribes to the BeforeResourceStarted event
    ```typescript
  onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise<void>): IResource
  ```
- [onInitializeResource](/reference/api/typescript/aspire.hosting/iresource/oninitializeresource.md) -- `method` -- Subscribes to the InitializeResource event
    ```typescript
  onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise<void>): IResource
  ```
- [onResourceReady](/reference/api/typescript/aspire.hosting/iresource/onresourceready.md) -- `method` -- Subscribes to the ResourceReady event
    ```typescript
  onResourceReady(callback: (arg: ResourceReadyEvent) => Promise<void>): IResource
  ```
- [onResourceStopped](/reference/api/typescript/aspire.hosting/iresource/onresourcestopped.md) -- `method` -- Subscribes to the ResourceStopped event
    ```typescript
  onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise<void>): IResource
  ```
- [withChildRelationship](/reference/api/typescript/aspire.hosting/iresource/withchildrelationship.md) -- `method` -- Sets a child relationship
    ```typescript
  withChildRelationship(child: IResource): IResource
  ```
- [withCommand](/reference/api/typescript/aspire.hosting/iresource/withcommand.md) -- `method` -- Adds a resource command
    ```typescript
  withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise<ExecuteCommandResult>, commandOptions?: CommandOptions): IResource
  ```
- [withContainerRegistry](/reference/api/typescript/aspire.hosting/iresource/withcontainerregistry.md) -- `method` -- Configures a resource to use a container registry
    ```typescript
  withContainerRegistry(registry: IResource): IResource
  ```
- [withDockerfileBaseImage](/reference/api/typescript/aspire.hosting/iresource/withdockerfilebaseimage.md) -- `method` -- Sets the base image for a Dockerfile build
    ```typescript
  withDockerfileBaseImage(buildImage?: string, runtimeImage?: string): IResource
  ```
- [withExplicitStart](/reference/api/typescript/aspire.hosting/iresource/withexplicitstart.md) -- `method` -- Prevents resource from starting automatically
    ```typescript
  withExplicitStart(): IResource
  ```
- [withHealthCheck](/reference/api/typescript/aspire.hosting/iresource/withhealthcheck.md) -- `method` -- Adds a health check by key
    ```typescript
  withHealthCheck(key: string): IResource
  ```
- [withIconName](/reference/api/typescript/aspire.hosting/iresource/withiconname.md) -- `method` -- Sets the icon for the resource
    ```typescript
  withIconName(iconName: string, iconVariant?: IconVariant): IResource
  ```
- [withParentRelationship](/reference/api/typescript/aspire.hosting/iresource/withparentrelationship.md) -- `method` -- Sets the parent relationship
    ```typescript
  withParentRelationship(parent: IResource): IResource
  ```
- [withPipelineConfiguration](/reference/api/typescript/aspire.hosting/iresource/withpipelineconfiguration.md) -- `method` -- Configures pipeline step dependencies via a callback
    ```typescript
  withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise<void>): IResource
  ```
- [withPipelineConfigurationAsync](/reference/api/typescript/aspire.hosting/iresource/withpipelineconfigurationasync.md) -- `method` -- Configures pipeline step dependencies via an async callback
    ```typescript
  withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise<void>): IResource
  ```
- [withPipelineStepFactory](/reference/api/typescript/aspire.hosting/iresource/withpipelinestepfactory.md) -- `method` -- Adds a pipeline step to the resource
    ```typescript
  withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise<void>, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): IResource
  ```
- [withRequiredCommand](/reference/api/typescript/aspire.hosting/iresource/withrequiredcommand.md) -- `method` -- Adds a required command dependency
    ```typescript
  withRequiredCommand(command: string, helpLink?: string): IResource
  ```
- [withUrl](/reference/api/typescript/aspire.hosting/iresource/withurl.md) -- `method` -- Adds or modifies displayed URLs
    ```typescript
  withUrl(url: string, displayText?: string): IResource
  ```
- [withUrlExpression](/reference/api/typescript/aspire.hosting/iresource/withurlexpression.md) -- `method` -- Adds a URL using a reference expression
    ```typescript
  withUrlExpression(url: ReferenceExpression, displayText?: string): IResource
  ```
- [withUrlForEndpoint](/reference/api/typescript/aspire.hosting/iresource/withurlforendpoint.md) -- `method` -- Customizes the URL for a specific endpoint via callback
    ```typescript
  withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise<void>): IResource
  ```
- [withUrlsCallback](/reference/api/typescript/aspire.hosting/iresource/withurlscallback.md) -- `method` -- Customizes displayed URLs via callback
    ```typescript
  withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise<void>): IResource
  ```
- [withUrlsCallbackAsync](/reference/api/typescript/aspire.hosting/iresource/withurlscallbackasync.md) -- `method` -- Customizes displayed URLs via async callback
    ```typescript
  withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise<void>): IResource
  ```
