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.

Container for the parameters to the RegisterTargets operation. Registers the specified targets with the specified target group.

If the target is an EC2 instance, it must be in the running state when you register it.

By default, the load balancer routes requests to registered targets using the protocol and port for the target group. Alternatively, you can override the port for a target when you register it. You can register each EC2 instance or IP address with the same target group multiple times using different ports.

With a Network Load Balancer, you cannot register instances by instance ID if they have the following instance types: C1, CC1, CC2, CG1, CG2, CR1, CS1, G1, G2, HI1, HS1, M1, M2, M3, and T1. You can register instances of these types by IP address.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceRequest
    Amazon.ElasticLoadBalancingV2.AmazonElasticLoadBalancingV2Request
      Amazon.ElasticLoadBalancingV2.Model.RegisterTargetsRequest

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

Syntax

C#
public class RegisterTargetsRequest : AmazonElasticLoadBalancingV2Request
         IAmazonWebServiceRequest

The RegisterTargetsRequest type exposes the following members

Constructors

NameDescription
Public Method RegisterTargetsRequest()

Properties

NameTypeDescription
Public Property TargetGroupArn System.String

Gets and sets the property TargetGroupArn.

The Amazon Resource Name (ARN) of the target group.

Public Property Targets System.Collections.Generic.List<Amazon.ElasticLoadBalancingV2.Model.TargetDescription>

Gets and sets the property Targets.

The targets.

Examples

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

To register targets with a target group


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


            

Version Information

.NET Core App:
Supported in: 3.1

.NET Standard:
Supported in: 2.0

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