Skip to content
DocsTry Aspire
DocsTry

ResourceCommandService Methods

ClassMethods4 members
A service to execute resource commands.
Execute a command for the specified resource.
public class ResourceCommandService
{
public Task<ExecuteCommandResult> ExecuteCommandAsync(
string resourceId,
string commandName,
CancellationToken cancellationToken = default(CancellationToken))
{
// ...
}
}
resourceIdstringThe resource id. This id can either exactly match the unique id of the resource or the displayed resource name if the resource name doesn't have duplicates (i.e. replicas).
commandNamestringThe command name.
cancellationTokenCancellationTokenoptionalThe cancellation token.
Task<ExecuteCommandResult>The ExecuteCommandResult indicates command success or failure.

A resource id can be either the unique id of the resource or the displayed resource name.

Projects, executables and containers typically have a unique id that combines the display name and a unique suffix. For example, a resource named cache could have a resource id of cache-abcdwxyz. This id is used to uniquely identify the resource in the app host.

The resource name can be also be used to retrieve the resource state, but it must be unique. If there are multiple resources with the same name, then this method will not return a match. For example, if a resource named cache has multiple replicas, then specifing cache won't return a match.

ExecuteCommandAsync(string, string, InteractionInputCollection, CancellationToken)Section titled ExecuteCommandAsync(string, string, InteractionInputCollection, CancellationToken)Task<ExecuteCommandResult>
Execute a command for the specified resource.
public class ResourceCommandService
{
public Task<ExecuteCommandResult> ExecuteCommandAsync(
string resourceId,
string commandName,
InteractionInputCollection arguments,
CancellationToken cancellationToken = default(CancellationToken))
{
// ...
}
}
resourceIdstringThe resource id. This id can either exactly match the unique id of the resource or the displayed resource name if the resource name doesn't have duplicates (i.e. replicas).
commandNamestringThe command name.
argumentsInteractionInputCollectionThe invocation arguments supplied to the command callback.
cancellationTokenCancellationTokenoptionalThe cancellation token.
Task<ExecuteCommandResult>The ExecuteCommandResult indicates command success or failure.

A resource id can be either the unique id of the resource or the displayed resource name.

Projects, executables and containers typically have a unique id that combines the display name and a unique suffix. For example, a resource named cache could have a resource id of cache-abcdwxyz. This id is used to uniquely identify the resource in the app host.

The resource name can be also be used to retrieve the resource state, but it must be unique. If there are multiple resources with the same name, then this method will not return a match. For example, if a resource named cache has multiple replicas, then specifing cache won't return a match.

Execute a command for the specified resource.
public class ResourceCommandService
{
public Task<ExecuteCommandResult> ExecuteCommandAsync(
IResource resource,
string commandName,
CancellationToken cancellationToken = default(CancellationToken))
{
// ...
}
}
resourceIResourceThe resource. If the resource has multiple instances, such as replicas, then the command will be executed for each instance.
commandNamestringThe command name.
cancellationTokenCancellationTokenoptionalThe cancellation token.
Task<ExecuteCommandResult>The ExecuteCommandResult indicates command success or failure.
ExecuteCommandAsync(IResource, string, InteractionInputCollection, CancellationToken)Section titled ExecuteCommandAsync(IResource, string, InteractionInputCollection, CancellationToken)Task<ExecuteCommandResult>
Execute a command for the specified resource.
public class ResourceCommandService
{
public Task<ExecuteCommandResult> ExecuteCommandAsync(
IResource resource,
string commandName,
InteractionInputCollection arguments,
CancellationToken cancellationToken = default(CancellationToken))
{
// ...
}
}
resourceIResourceThe resource. If the resource has multiple instances, such as replicas, then the command will be executed for each instance.
commandNamestringThe command name.
argumentsInteractionInputCollectionThe invocation arguments supplied to the command callback.
cancellationTokenCancellationTokenoptionalThe cancellation token.
Task<ExecuteCommandResult>The ExecuteCommandResult indicates command success or failure.