AWS SDK Version 3 for .NET
API Reference

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.

Registers the specified targets with the specified target group.

By default, the load balancer routes requests to registered targets using the protocol and port number for the target group. Alternatively, you can override the port for a target when you register it.

The target must be in the virtual private cloud (VPC) that you specified for the target group. If the target is an EC2 instance, it must be in the running state when you register it.

Network Load Balancers do not support the following instance types as targets: C1, CC1, CC2, CG1, CG2, CR1, CS1, G1, G2, HI1, HS1, M1, M2, M3, and T1.

To remove a target from a target group, use DeregisterTargets.

Note:

For PCL this operation is only available in asynchronous form. Please refer to RegisterTargetsAsync.

Namespace: Amazon.ElasticLoadBalancingV2
Assembly: AWSSDK.ElasticLoadBalancingV2.dll
Version: 3.x.y.z

Syntax

C#
public virtual RegisterTargetsResponse RegisterTargets(
         RegisterTargetsRequest request
)
Parameters
request
Type: Amazon.ElasticLoadBalancingV2.Model.RegisterTargetsRequest

Container for the necessary parameters to execute the RegisterTargets service method.

Return Value
The response from the RegisterTargets service method, as returned by ElasticLoadBalancingV2.

Exceptions

ExceptionCondition
InvalidTargetException The specified target does not exist or is not in the same VPC as the target group.
TargetGroupNotFoundException The specified target group does not exist.
TooManyRegistrationsForTargetIdException You've reached the limit on the number of times a target can be registered with a load balancer.
TooManyTargetsException You've reached the limit on the number of targets.

Examples

This example registers the specified instances with the specified target group.

To register targets with a target group


var response = client.RegisterTargets(new RegisterTargetsRequest 
{
    TargetGroupArn = "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067",
    Targets = new List {
        new TargetDescription { Id = "i-80c8dd94" },
        new TargetDescription { Id = "i-ceddcd4d" }
    }
});


            

This example registers the specified instance with the specified target group using multiple ports. This enables you to register ECS containers on the same instance as targets in the target group.

To register targets with a target group using port overrides


var response = client.RegisterTargets(new RegisterTargetsRequest 
{
    TargetGroupArn = "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-targets/3bb63f11dfb0faf9",
    Targets = new List {
        new TargetDescription {
            Id = "i-80c8dd94",
            Port = 80
        },
        new TargetDescription {
            Id = "i-80c8dd94",
            Port = 766
        }
    }
});


            

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5

Portable Class Library:
Supported in: Windows Store Apps
Supported in: Windows Phone 8.1
Supported in: Xamarin Android
Supported in: Xamarin iOS (Unified)
Supported in: Xamarin.Forms

See Also