AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Starts a new task from the specified task definition on the specified container instance
or instances.
On March 21, 2024, a change was made to resolve the task definition revision before
authorization. When a task definition revision is not specified, authorization will
occur using the latest revision of a task definition.
Amazon Elastic Inference (EI) is no longer available to customers.
Alternatively, you can useRunTask
to place tasks for you. For more information,
see Scheduling
Tasks in the Amazon Elastic Container Service Developer Guide.
You can attach Amazon EBS volumes to Amazon ECS tasks by configuring the volume when creating or updating a service. For more information, see Amazon EBS volumes in the Amazon Elastic Container Service Developer Guide.
For .NET Core this operation is only available in asynchronous form. Please refer to StartTaskAsync.
Namespace: Amazon.ECS
Assembly: AWSSDK.ECS.dll
Version: 3.x.y.z
public virtual StartTaskResponse StartTask( StartTaskRequest request )
Container for the necessary parameters to execute the StartTask service method.
Exception | Condition |
---|---|
ClientException | These errors are usually caused by a client action. This client action might be using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Or, it might be specifying an identifier that isn't valid. |
ClusterNotFoundException | The specified cluster wasn't found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region specific. |
InvalidParameterException | The specified parameter isn't valid. Review the available parameters for the API request. For more information about service event errors, see Amazon ECS service event messages. |
ServerException | These errors are usually caused by a server issue. |
UnsupportedFeatureException | The specified task isn't supported in this Region. |
This example starts a new task in the cluster "MyCluster" on the specified container instance using the latest revision of the "hello-world" task definition.
var client = new AmazonECSClient(); var response = client.StartTask(new StartTaskRequest { Cluster = "MyCluster", ContainerInstances = new List<string> { "4c543eed-f83f-47da-b1d8-3d23f1da4c64" }, TaskDefinition = "hello-world" }); List<Failure> failures = response.Failures; List<Task> tasks = response.Tasks;
.NET Framework:
Supported in: 4.5 and newer, 3.5