aspire resource command

Name

aspire resource - Execute a command on a resource.

Synopsis

aspire resource   [options]

Description

The aspire resource command executes a command exposed by a resource in a running AppHost. Use it to trigger actions such as start, stop, or restart without opening the dashboard.

The available command names depend on the selected resource. If a resource doesn't expose the command you specify, Aspire returns an error.

Note

aspire resource doesn't expose a fixed set of CLI subcommands in --help. Instead, <command> is a positional argument whose valid values come from the selected resource at runtime. This is why the CLI reference documents aspire resource as a single command page instead of separate pages such as aspire resource start.

When executed without the --apphost option, the command:

  1. 1

    Scans for all running AppHost processes.

  2. 2

    If multiple AppHosts are running within the current directory scope, prompts you to select which one to target.

  3. 3

    If only one AppHost is running in scope, connects to it directly.

  4. 4

    If no in-scope AppHosts are found but out-of-scope AppHosts exist, displays all running AppHosts for selection.

Arguments

  • <resource>

    The name of the resource to execute the command on.

  • <command>

    The name of the resource command to execute, such as start, stop, or restart.

Options

The following options are available:

              • Examples

  • Restart a resource in the current AppHost:

    aspire resource cache restart
    
  • Stop a specific resource:

    aspire resource worker stop
    
  • Target a specific AppHost project:

    aspire resource api restart --apphost './src/MyApp.AppHost/MyApp.AppHost.csproj'
    

See also