# Resource

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

Represents a resource that can be hosted by an application.

## Definition

```go
type Resource interface{}
```

## Methods

A marker interface declares no methods of its own in Go. Its functions are declared on the concrete types they apply to.

- [CreateExecutionConfiguration](/reference/api/go/aspire.hosting/resource/createexecutionconfiguration.md) -- `method` -- Creates an execution configuration builder for the specified resource.
  ```go
  CreateExecutionConfiguration() ExecutionConfigurationBuilder
  ```
- [ExcludeFromManifest](/reference/api/go/aspire.hosting/resource/excludefrommanifest.md) -- `method` -- Excludes a resource from being published to the manifest.
  ```go
  ExcludeFromManifest() Resource
  ```
- [ExcludeFromMcp](/reference/api/go/aspire.hosting/resource/excludefrommcp.md) -- `method` -- Exclude the resource from MCP operations using the Aspire MCP server. The resource is excluded from results that return resources, console logs and telemetry.
  ```go
  ExcludeFromMcp() Resource
  ```
- [GetResourceName](/reference/api/go/aspire.hosting/resource/getresourcename.md) -- `method` -- Gets the name of the resource from a builder.
  ```go
  GetResourceName() (string, error)
  ```
- [GetSerializedAnnotation](/reference/api/go/aspire.hosting/resource/getserializedannotation.md) -- `method` -- Gets a serialized ATS annotation payload from a resource.
  ```go
  GetSerializedAnnotation(annotationId string) (string, error)
  ```
- [HasSerializedAnnotation](/reference/api/go/aspire.hosting/resource/hasserializedannotation.md) -- `method` -- Determines whether a resource has a serialized ATS annotation with the specified ID.
  ```go
  HasSerializedAnnotation(annotationId string) (bool, error)
  ```
- [OnBeforeResourceStarted](/reference/api/go/aspire.hosting/resource/onbeforeresourcestarted.md) -- `method` -- Subscribes to the BeforeResourceStarted event.
  ```go
  OnBeforeResourceStarted(callback func(arg BeforeResourceStartedEvent)) Resource
  ```
- [OnInitializeResource](/reference/api/go/aspire.hosting/resource/oninitializeresource.md) -- `method` -- Subscribes to the InitializeResource event.
  ```go
  OnInitializeResource(callback func(arg InitializeResourceEvent)) Resource
  ```
- [OnResourceReady](/reference/api/go/aspire.hosting/resource/onresourceready.md) -- `method` -- Subscribes to the ResourceReady event.
  ```go
  OnResourceReady(callback func(arg ResourceReadyEvent)) Resource
  ```
- [OnResourceStopped](/reference/api/go/aspire.hosting/resource/onresourcestopped.md) -- `method` -- Subscribes to the ResourceStopped event.
  ```go
  OnResourceStopped(callback func(arg ResourceStoppedEvent)) Resource
  ```
- [SubscribeHttpsEndpointsUpdate](/reference/api/go/aspire.hosting/resource/subscribehttpsendpointsupdate.md) -- `method` -- 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.
  ```go
  SubscribeHttpsEndpointsUpdate(callback func(obj HttpsEndpointUpdateCallbackContext)) Resource
  ```
- [WithChildRelationship](/reference/api/go/aspire.hosting/resource/withchildrelationship.md) -- `method` -- Sets a child relationship
  ```go
  WithChildRelationship(child Resource) Resource
  ```
- [WithCommand](/reference/api/go/aspire.hosting/resource/withcommand.md) -- `method` -- Adds a resource command
  ```go
  WithCommand(name string, displayName string, executeCommand func(arg ExecuteCommandContext) *ExecuteCommandResult, options ...*WithCommandOptions) Resource
  ```
- [WithContainerBuildOptions](/reference/api/go/aspire.hosting/resource/withcontainerbuildoptions.md) -- `method` -- Configures container build options for a compute resource using an async callback.
  ```go
  WithContainerBuildOptions(callback func(arg ContainerBuildOptionsCallbackContext)) Resource
  ```
- [WithContainerRegistry](/reference/api/go/aspire.hosting/resource/withcontainerregistry.md) -- `method` -- Configures the resource to use the specified container registry for container image operations.
  ```go
  WithContainerRegistry(registry Resource) Resource
  ```
- [WithDisplayOrder](/reference/api/go/aspire.hosting/resource/withdisplayorder.md) -- `method` -- 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.
  ```go
  WithDisplayOrder(order float64) Resource
  ```
- [WithDockerfileBaseImage](/reference/api/go/aspire.hosting/resource/withdockerfilebaseimage.md) -- `method` -- Configures custom base images for generated Dockerfiles.
  ```go
  WithDockerfileBaseImage(options ...*WithDockerfileBaseImageOptions) Resource
  ```
- [WithExplicitStart](/reference/api/go/aspire.hosting/resource/withexplicitstart.md) -- `method` -- Prevents resource from starting automatically
  ```go
  WithExplicitStart() Resource
  ```
- [WithHealthCheck](/reference/api/go/aspire.hosting/resource/withhealthcheck.md) -- `method` -- Adds a health check by key
  ```go
  WithHealthCheck(key string) Resource
  ```
- [WithHidden](/reference/api/go/aspire.hosting/resource/withhidden.md) -- `method` -- Hides the resource from default resource lists
  ```go
  WithHidden() Resource
  ```
- [WithHiddenOnCompletion](/reference/api/go/aspire.hosting/resource/withhiddenoncompletion.md) -- `method` -- Hides the resource from default resource lists after successful completion
  ```go
  WithHiddenOnCompletion(options ...*WithHiddenOnCompletionOptions) Resource
  ```
- [WithIconName](/reference/api/go/aspire.hosting/resource/withiconname.md) -- `method` -- Specifies the icon to use when displaying the resource in the dashboard.
  ```go
  WithIconName(iconName string, options ...*WithIconNameOptions) Resource
  ```
- [WithLifetimeOf](/reference/api/go/aspire.hosting/resource/withlifetimeof.md) -- `method` -- Configures a resource to match the lifetime of another resource.
  ```go
  WithLifetimeOf(sourceBuilder Resource) Resource
  ```
- [WithParentProcessLifetime](/reference/api/go/aspire.hosting/resource/withparentprocesslifetime.md) -- `method` -- Configures a resource to use a persistent lifetime that ends when a parent process exits.
  ```go
  WithParentProcessLifetime(parentProcessId float64) Resource
  ```
- [WithParentRelationship](/reference/api/go/aspire.hosting/resource/withparentrelationship.md) -- `method` -- Sets the parent relationship
  ```go
  WithParentRelationship(parent Resource) Resource
  ```
- [WithPersistentLifetime](/reference/api/go/aspire.hosting/resource/withpersistentlifetime.md) -- `method` -- Configures a resource to use a persistent lifetime.
  ```go
  WithPersistentLifetime() Resource
  ```
- [WithPipelineConfiguration](/reference/api/go/aspire.hosting/resource/withpipelineconfiguration.md) -- `method` -- Registers a callback to be executed during the pipeline configuration phase, allowing modification of step dependencies and relationships.
  ```go
  WithPipelineConfiguration(callback func(obj PipelineConfigurationContext)) Resource
  ```
- [WithPipelineStepFactory](/reference/api/go/aspire.hosting/resource/withpipelinestepfactory.md) -- `method` -- Adds a pipeline step to the resource that will be executed during deployment.
  ```go
  WithPipelineStepFactory(stepName string, callback func(arg PipelineStepContext), options ...*WithPipelineStepFactoryOptions) Resource
  ```
- [WithProcessCommand](/reference/api/go/aspire.hosting/resource/withprocesscommand.md) -- `method` -- Adds a command to the resource that starts a local process when invoked.
  ```go
  WithProcessCommand(commandName string, displayName string, options *ProcessCommandExportOptions) Resource
  ```
- [WithProcessCommandFactory](/reference/api/go/aspire.hosting/resource/withprocesscommandfactory.md) -- `method` -- Adds a command to the resource that starts a local process created by a callback when invoked.
  ```go
  WithProcessCommandFactory(commandName string, displayName string, createProcessSpec func(arg ExecuteCommandContext) *ProcessCommandSpecExportData, options ...*ProcessCommandResultExportOptions) Resource
  ```
- [WithRelationship](/reference/api/go/aspire.hosting/resource/withrelationship.md) -- `method` -- Adds a relationship to another resource using its builder.
  ```go
  WithRelationship(resourceBuilder Resource, type_ string) Resource
  ```
- [WithRequiredCommand](/reference/api/go/aspire.hosting/resource/withrequiredcommand.md) -- `method` -- Declares that a resource requires a specific command/executable to be available on the local machine PATH before it can start.
  ```go
  WithRequiredCommand(command string, options ...*WithRequiredCommandOptions) Resource
  ```
- [WithRequiredCommandValidation](/reference/api/go/aspire.hosting/resource/withrequiredcommandvalidation.md) -- `method` -- 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.
  ```go
  WithRequiredCommandValidation(command string, validationCallback func(arg RequiredCommandValidationContext) RequiredCommandValidationResult, options ...*WithRequiredCommandValidationOptions) Resource
  ```
- [WithResourceTypeDisplayName](/reference/api/go/aspire.hosting/resource/withresourcetypedisplayname.md) -- `method` -- Overrides the human-readable resource type label.
  ```go
  WithResourceTypeDisplayName(resourceTypeDisplayName string) Resource
  ```
- [WithSerializedAnnotation](/reference/api/go/aspire.hosting/resource/withserializedannotation.md) -- `method` -- Stores a serialized ATS annotation payload on a resource, replacing any existing annotation with the same ID.
  ```go
  WithSerializedAnnotation(annotationId string, json string) Resource
  ```
- [WithSessionLifetime](/reference/api/go/aspire.hosting/resource/withsessionlifetime.md) -- `method` -- Configures a resource to use a session lifetime.
  ```go
  WithSessionLifetime() Resource
  ```
- [WithTags](/reference/api/go/aspire.hosting/resource/withtags.md) -- `method` -- Adds AppHost-defined dashboard tags that users cannot remove. Repeated calls add tags.
  ```go
  WithTags(tags []string) Resource
  ```
- [WithTerminal](/reference/api/go/aspire.hosting/resource/withterminal.md) -- `method` -- Adds an interactive terminal session to a resource with an optional callback to configure its initial dimensions.
  ```go
  WithTerminal(options ...*WithTerminalOptions) Resource
  ```
- [WithTrait](/reference/api/go/aspire.hosting/resource/withtrait.md) -- `method` -- Adds immutable, non-sensitive metadata to a resource. Repeated names add multiple values.
  ```go
  WithTrait(name string, value string) Resource
  ```
- [WithUrl](/reference/api/go/aspire.hosting/resource/withurl.md) -- `method` -- Adds or modifies displayed URLs
  ```go
  WithUrl(url any, options ...*WithUrlOptions) Resource
  ```
- [WithUrlForEndpoint](/reference/api/go/aspire.hosting/resource/withurlforendpoint.md) -- `method` -- Registers a callback to update the URL displayed for the endpoint with the specified name.
  ```go
  WithUrlForEndpoint(endpointName string, callback func(obj *ResourceUrlAnnotation)) Resource
  ```
- [WithUrls](/reference/api/go/aspire.hosting/resource/withurls.md) -- `method` -- Registers a callback to customize the URLs displayed for the resource.
  ```go
  WithUrls(callback func(obj ResourceUrlsCallbackContext)) Resource
  ```

## Applies to

- [`ContainerRegistryResource`](/reference/api/go/aspire.hosting/containerregistryresource.md)
- [`ContainerResource`](/reference/api/go/aspire.hosting/containerresource.md)
- [`CSharpAppResource`](/reference/api/go/aspire.hosting/csharpappresource.md)
- [`DotnetToolResource`](/reference/api/go/aspire.hosting/dotnettoolresource.md)
- [`ExecutableResource`](/reference/api/go/aspire.hosting/executableresource.md)
- [`ExternalServiceResource`](/reference/api/go/aspire.hosting/externalserviceresource.md)
- [`ParameterResource`](/reference/api/go/aspire.hosting/parameterresource.md)
- [`ProjectResource`](/reference/api/go/aspire.hosting/projectresource.md)
