Skip to content
Docs Try Aspire

aspire resource command

aspire resource - Execute a command on a resource.

Aspire CLI
aspire resource <resource> <command> [options]

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.

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

  1. Scans for all running AppHost processes.
  2. If multiple AppHosts are running within the current directory scope, prompts you to select which one to target.
  3. If only one AppHost is running in scope, connects to it directly.
  4. If no in-scope AppHosts are found but out-of-scope AppHosts exist, displays all running AppHosts for selection.
  • <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.

The following options are available:

  • --apphost <apphost>

    The path to the Aspire AppHost project file.

  • -?, -h, --help

    Prints help and usage documentation for the available commands and options.

  • -l, --log-level <Critical|Debug|Error|Information|None|Trace|Warning>

    Set the minimum log level for console output. Use this option to increase diagnostics while troubleshooting or reduce output in scripted runs.

  • --non-interactive

    Run the command in non-interactive mode, disabling all interactive prompts and spinners.

  • --nologo

    Suppress the startup banner and telemetry notice.

  • --banner

    Display the animated Aspire CLI welcome banner.

  • --wait-for-debugger

    Wait for a debugger to attach before running a command.

  • Restart a resource in the current AppHost:

    Aspire CLI
    aspire resource cache restart
  • Stop a specific resource:

    Aspire CLI
    aspire resource worker stop
  • Target a specific AppHost project:

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