# ResourceCommandService.ExecuteCommandAsync

- Module: [Aspire.Hosting](/reference/api/go/aspire.hosting.md)
- Defined on: [ResourceCommandService](/reference/api/go/aspire.hosting/resourcecommandservice.md)
- Version: `17.0.0`
- Kind: `method`

Executes a command for the specified resource.

## Definition

```go
type ResourceCommandService interface {
    // ... omitted for brevity
    ExecuteCommandAsync(
        resource any,
        commandName string,
        options ...*ExecuteCommandAsyncOptions,
    ) (*ExecuteCommandResult, error)
}
```

## Signature

```go
ExecuteCommandAsync(
    resource any,
    commandName string,
    options ...*ExecuteCommandAsyncOptions,
) (*ExecuteCommandResult, error)
```

## Parameters

- `resource` (`any`) -- The resource id or resource handle. A resource id can either exactly match the unique id of the resource or the displayed resource name if the resource name doesn't have duplicates.
- `commandName` (`string`) -- The command name.
- `options` (`...*ExecuteCommandAsyncOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*ExecuteCommandAsyncOptions` argument.

- `Arguments` (`map[string]string`) -- The optional invocation arguments supplied to the command callback.
- `CancellationToken` (`*CancellationToken`) -- The cancellation token.

## Returns

`(*ExecuteCommandResult, error)` -- The command execution result.

Returns `(*ExecuteCommandResult, error)`.

## Defined on

- [ResourceCommandService](/reference/api/go/aspire.hosting/resourcecommandservice.md) -- `handle`
