All Products
Search
Document Center

Server Load Balancer:CreateLoadBalancer

Last Updated:Oct 18, 2026

Creates a Network Load Balancing (NLB) instance.

Operation description

  • When you create a Network Load Balancing (NLB) instance, the system automatically creates the AliyunServiceRoleForNlb service-linked role for you.

  • The CreateLoadBalancer operation is asynchronous. The system returns an instance ID, but the Network Load Balancing (NLB) instance is not yet created and the creation task is still running in the background. You can invoke the GetLoadBalancerAttribute operation to query the creation status of the Network Load Balancing (NLB) instance:
    • If the Network Load Balancing (NLB) instance is in the Provisioning state, the Network Load Balancing (NLB) instance is being created.

    • If the Network Load Balancing (NLB) instance is in the Active state, the Network Load Balancing (NLB) instance is created.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

nlb:CreateLoadBalancer

create

*LoadBalancer

acs:nlb:{#regionId}:{#accountId}:loadbalancer/*

*VSwitch

acs:vpc:{#regionId}:{#accountId}:vswitch/{#VSwitchId}

EipAddress

acs:vpc:{#regionId}:{#accountId}:eip/{#AllocationId}

*VPC

acs:vpc:{#regionId}:{#accountId}:vpc/{#VpcId}

  • nlb:AddressType
None

Request parameters

Parameter

Type

Required

Description

Example

LoadBalancerType

string

No

The type of load balancing. Valid value: network, which indicates Network Load Balancing (NLB).

network

LoadBalancerName

string

No

The name of the Network Load Balancing (NLB) instance.

The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). It must start with a letter.

NLB1

AddressType

string

Yes

The IPv4 address type of the Network Load Balancing (NLB) instance. Valid values:

  • Internet: The load balancing instance has a public IP address. The DNS domain name is resolved to the public IP address, so it can be accessed over the Internet.

  • Intranet: The load balancing instance has only a private IP address. The DNS domain name is resolved to the private IP address, so it can be accessed only over the internal network of the VPC where the load balancing instance is deployed.

Note

To enable IPv6 access over the Internet for a dual-stack Network Load Balancing (NLB) instance, invoke the EnableLoadBalancerIpv6Internet operation.

Internet

AddressIpVersion

string

No

The IP version. Valid values:

  • ipv4 (default): IPv4.

  • DualStack: dual-stack.

ipv4

VpcId

string

Yes

The ID of the virtual private cloud (VPC) where the Network Load Balancing (NLB) instance is deployed.

vpc-bp1b49rqrybk45nio****

ZoneMappings

array<object>

Yes

The zone and vSwitch mappings. You can add up to 10 zones. If the current region supports two or more zones, you must add at least two zones.

object

No

The zone and vSwitch mappings. You can add up to 10 zones. If the current region supports two or more zones, you must add at least two zones.

VSwitchId

string

Yes

The vSwitch that corresponds to the zone. You can use only one vSwitch and one subnet in each zone. You can add up to 10 zones. If the current region supports two or more zones, you must add at least two zones.

vsw-sersdf****

ZoneId

string

Yes

The ID of the zone where the Network Load Balancing (NLB) instance is deployed. You can add up to 10 zones. If the current region supports two or more zones, you must add at least two zones.

You can invoke the DescribeZones operation to query zone IDs.

cn-hangzhou-a

PrivateIPv4Address

string

No

The private IPv4 virtual IP address (VIP). This is the private IPv4 address used by the NLB to provide services.

192.168.10.1

AllocationId

string

No

The EIP instance ID associated with the Internet-facing instance. Each zone corresponds to one EIP instance ID. You can add up to 10 zones. If the current region supports two or more zones, you must add at least two zones.

eip-bp1aedxso6u80u0qf****

Ipv6Address

string

No

The IPv6 VIP. This is the IPv6 address used by the NLB to provide services.

2408:400a:d5:3080:b409:840a:ca:e8e5

Ipv4LocalAddresses

array

No

The list of IPv4 local addresses. These are the addresses used by the NLB to interact with backend services. The number of addresses must be an even number, with a minimum of 2 and a maximum of 8.

string

No

The IPv4 local address.

192.168.10.2

Ipv6LocalAddresses

array

No

The list of IPv6 local addresses. These are the addresses used by the NLB to interact with backend services. The number of addresses must be an even number, with a minimum of 2 and a maximum of 8.

string

No

The IPv6 local address.

2408:400a:d5:3080:b409:840a:ca:e8e6

BandwidthPackageId

string

No

The ID of the Internet Shared Bandwidth instance that is associated with the Internet-facing instance.

cbwp-bp1vevu8h3ieh****

LoadBalancerBillingConfig

object

No

The billing configuration of the Network Load Balancing (NLB) instance.

PayType

string

No

The billing method of the Network Load Balancing (NLB) instance.

Valid value: PostPay, which indicates the pay-as-you-go billing method.

PostPay

ResourceGroupId

string

No

The ID of the resource group.

rg-atstuj3rtop****

DryRun

boolean

No

Specifies whether to only precheck the request. Valid values:

  • true: prechecks the request without creating the instance. The system checks whether required parameters are specified, the request format is valid, and service limits are met. If the request fails the precheck, the corresponding error is returned. If the request passes the precheck, the DryRunOperation error code is returned.

  • false (default): sends the request. If the request passes the precheck, an HTTP 2xx status code is returned and the operation is performed.

false

ClientToken

string

No

The client token that is used to ensure the idempotence of the request.

You can use the client to generate the value, but you must ensure that it is unique among different requests. The client token can contain only ASCII characters.

Note

If you do not specify this parameter, the system automatically uses the RequestId of the API request as the ClientToken. The RequestId of each API request is unique.

123e4567-e89b-12d3-a456-426655440000

RegionId

string

No

The region ID of the Network Load Balancing (NLB) instance.

You can invoke the DescribeRegions operation to query region IDs.

cn-hangzhou

DeletionProtectionConfig

object

No

The deletion protection configuration.

Enabled

boolean

No

The deletion protection status. Valid values:

  • true: enabled.

  • false (default): disabled.

false

Reason

string

No

The reason for changing the deletion protection status. The reason must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). It must start with a letter.

Instance is running

ModificationProtectionConfig

object

No

The modification protection configuration.

Status

string

No

The modification protection status of the Network Load Balancing (NLB). Valid values:

  • NonProtection: modification protection is disabled. You cannot specify the Reason parameter. If you specify the Reason parameter, the configuration is cleared.

  • ConsoleProtection: console modification protection is enabled. You can specify the Reason parameter.

Note

If you set the value to ConsoleProtection, modification protection is enabled. You cannot modify the instance configurations in the load balancing console, but you can invoke API operations to modify the instance configurations.

ConsoleProtection

Reason

string

No

The reason for enabling modification protection. The reason must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). It must start with a letter.

Note

This parameter is valid and takes effect only when Status is set to ConsoleProtection.

Business protection period

Tag

array<object>

No

The list of tags.

object

No

The tag.

Key

string

No

The tag key. The key can be up to 64 characters in length, and cannot start with aliyun or acs:. It cannot contain http:// or https://. The key can contain letters, digits, underscores (_), periods (.), colons (:), forward slashes (/), equal signs (=), plus signs (+), hyphens (-), and at signs (@).

You can add up to 20 tags in a single call.

env

Value

string

No

The tag value. The value can be up to 128 characters in length, and cannot start with aliyun or acs:. It cannot contain http:// or https://. The value can contain letters, digits, underscores (_), periods (.), colons (:), forward slashes (/), equal signs (=), plus signs (+), hyphens (-), and at signs (@).

You can add up to 20 tags in a single call.

product

Response elements

Element

Type

Description

Example

object

response

RequestId

string

The request ID.

CEF72CEB-54B6-4AE8-B225-F876FF7BA984

LoadbalancerId

string

The instance ID.

nlb-83ckzc8d4xlp8o****

OrderId

integer

The order ID of the Network Load Balancing (NLB) instance.

20230000

Examples

Success response

JSON format

{
  "RequestId": "CEF72CEB-54B6-4AE8-B225-F876FF7BA984",
  "LoadbalancerId": "nlb-83ckzc8d4xlp8o****",
  "OrderId": 20230000
}

Error codes

HTTP status code

Error code

Error message

Description

400 OperationDenied.OnlyPayByTrafficSupported The operation is not allowed because of OnlyPayByTrafficSupported. The operation is not allowed because only pay-by-data-transfer billing is supported.
400 OperationFailed.%s The operation failed because of %s. Failed to call the API operation due to %.
400 Mismatch.ZoneIdAndVswitchId The ZoneIdAndVswitchId is mismatched for %s and %s. The ZoneId and VswitchId are missing. Check the input parameters.
400 QuotaExceeded.%s The quota of %s is exceeded, usage %s/%s. The quota for %s has been exceeded. Used: %s/%s.
400 DryRunOperation Request validation has been passed with DryRun flag set. Request validation has been passed with DryRun flag set.
400 OperationDenied.OnlyPostPaidSupported The operation is not allowed because of OnlyPostPaidSupported. The operation is not allowed because only pay-as-you-go billing is supported.
400 OperationFailed.DuplicateZones. The operation failed because of Can not Specify duplicate zones. The operation failed because duplicate zones were specified. Modify the parameters.
400 ResourceNotEnough.VSwitchIp The specified resource of VSwitchIp is not enough. The specified virtual switch (vSwitch) IP resources are insufficient.
400 DuplicatedParam.AllocationId The param of AllocationId is duplicated. The AllocationId parameter is duplicated. Check the parameter.
400 ResourceInConfiguring.VswitchId The specified resource of VswitchId is being configured, please try again later. The specified resource of VswitchId is being configured, please try again later.
400 IllegalParam The param of %s is illegal. The input parameters contain invalid values. Check the input.
400 OperationFailed.UnpaidBill The operation failed because of UnpaidBill. You have overdue bills and are not eligible to make a purchase. Settle the outstanding bills before making a purchase.
400 OperationDenied.ServiceLinkedRoleNotExist The operation is not allowed because of ServiceLinkedRoleNotExist. The operation is not allowed because of ServiceLinkedRoleNotExist.Please check if the necessary permissions are granted in RAM for the NLB.
400 ResourceAlreadyAssociated.AllocationId The specified resource of %s is already associated. The specified resource AllocationId is already associated.
400 OperationFailed.vSwitchNotSupportIpv6 The operation failed because of vSwitchNotSupportIpv6. The specified vSwitch does not support IPv6. Check the input parameters.
400 InvalidZones The current zone list is illegal. The Availability Zone used in Zone maping is illegal.
400 QuotaExceeded.QuotaInsufficient The quota of %s is exceeded, usage %s/%s. The quota is insufficient, currently used %s/%s. Please modify the quota size in the quota center.
400 ResourceInUse.IP The specified resource of IP is in use. The specified IP address cannot be an ENI address of the NLB instance. Check the parameters.
400 OperationFailed.CreateOrderError Operation failed because CreateOrderError. The operation failed because the order creation failed.
400 OperationFailed.NotExist.ResourceGroup Operation failed because ResourceGroup not exist. The specified resource group does not exist.
400 IllegalParam.loadBalancerName Param loadBalancerName is illegal. The instance name is invalid. Check the parameters.
400 SystemBusy System is busy, please try again later. The system is busy. Try again later.
400 MissingParam.%s The parameter of %s is missing. The parameter %s is missing. Check the input parameters.
400 IllegalParam.DeletionProtectionConfig DeletionProtectionConfig reason is illegal. The reason parameter for changing the delete protection status is invalid.
400 IllegalParam.ModificationProtectionConfig ModificationProtectionConfig reason is illegal. ModificationProtectionConfig reason is illegal.
400 Throttling.User Request was denied due to api flow control. Request was denied due to api flow control.
403 UnauthorizedZone The specified zone of %s is not authorized. The specified zone %s is not authorized for use.
403 Forbidden.NoPermission Authentication is failed for NoPermission. Authentication is failed for NoPermission.
403 UnauthorizedRegion The specified region of %s is not authorized. The current region has not been authorized.
404 ResourceNotFound.VSwitch The specified resource of vSwitch is not found. The specified vSwitch resource was not found. Please check the input parameters.
404 ResourceNotFound.Vpc The specified resource of Vpc is not found. The specified VPC resource was not found. Please check the input parameters.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.