All Products
Search
Document Center

Auto Scaling:DetachLoadBalancers

Last Updated:Jul 09, 2024

Detaches Classic Load Balancer (CLB, formerly known as Server Load Balancer or SLB) instances from a scaling group. If the current CLB instance no longer meets your business requirements, you can call the DetachLoadBalancers operation to detach it from your scaling group. When you call this operation, you can use ScalingGroupId, LoadBalancer.N, and ForceDetach to specify one or more CLB instances to detach. You can also determine whether to call this operation asynchronously and whether to remove the Elastic Compute Service (ECS) instances acting as backend servers from the backend server groups of the CLB instance. You can call this operation to detach only CLB instances from a scaling group.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter

Type

Required

Example

Description

Action

String

Yes

DetachLoadBalancers

The operation that you want to perform. Set the value to DetachLoadBalancers.

ScalingGroupId

String

Yes

asg-bp1ffogfdauy0jw0****

The ID of the scaling group.

ForceDetach

Boolean

No

false

Specifies whether to remove the ECS instances acting as backend servers from the backend server groups of the CLB instance. Valid values:

  • true

  • false

Default value: false.

ClientToken

String

No

123e4567-e89b-12d3-a456-42665544****

The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests.

The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see Ensure idempotence.

Async

Boolean

No

false

Specifies whether to detach CLB instance N from the scaling group in an asynchronous manner. If you detach CLB instance N from the scaling group in an asynchronous manner, the call is successful only after all operations are complete. If a specific operation fails, the call fails. We recommend that you set this parameter to true.

Valid values:

  • true: detaches CLB instance N from the scaling group in an asynchronous manner. In this case, the ID of the scaling activity will be returned.

  • false: does not detach CLB instance N from the scaling group in an asynchronous manner.

Default value: false.

LoadBalancer.N

String

No

lb-2zeur05gfs****

The ID of CLB instance N that you want to detach from the scaling group. Valid values of N: 1 to 5.

RegionId

String

No

cn-qingdao

The region ID of the scaling group.

Response parameters

Parameter

Type

Example

Description

ScalingActivityId

String

asa-bp140qd7mak8k63f****

The ID of the scaling activity.

The value of this parameter is returned only if you set Async to true. You can call the DescribeScalingActivities operation to query the returned IDs of scaling activities and view the execution status of the scaling activities.

RequestId

String

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

The request ID.

Examples

Sample requests

http(s)://ess.aliyuncs.com/?Action=DetachLoadBalancers
&ScalingGroupId=asg-bp1ffogfdauy0jw0****
&ForceDetach=false
&ClientToken=123e4567-e89b-12d3-a456-42665544****
&Async=false
&LoadBalancer=["lb-2zeur05gfs****"]
&RegionId=cn-qingdao
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<DetachLoadBalancersResponse>
    <ScalingActivityId>asa-bp140qd7mak8k63f****</ScalingActivityId>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
</DetachLoadBalancersResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "ScalingActivityId" : "asa-bp140qd7mak8k63f****",
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}

Error codes

For a list of error codes, see Service error codes.

HTTP status code

Error code

Error message

Description

403

Forbidden.Unauthorized

A required authorization for the specified action is not supplied.

Auto Scaling is not authorized to call the operation.

404

InvalidScalingGroupId.NotFound

The specified scaling group does not exist.

The specified scaling group does not exist within the Alibaba Cloud account.

404

InvalidLoadBalancerId.NotFound

The Load Balancer "%s" does not exist.

The specified CLB instance is not attached to the scaling group.