Creates a Network Load Balancer (NLB) instance.

Usage notes

  • When you create an NLB instance, the service-linked role AliyunServiceRoleForNlb is automatically created and assigned to you.
  • CreateLoadBalancer is an asynchronous operation. After you send a request, the system returns an instance ID and runs the task in the background. You can call GetLoadBalancerAttribute to query the status of an NLB instance.
    • If an NLB instance is in the Provisioning state, the NLB instance is being created.
    • If an NLB instance is in the Active state, the NLB instance is created.

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

ParameterTypeRequiredExampleDescription
ActionStringYesCreateLoadBalancer

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

LoadBalancerTypeStringNonetwork

The type of the instance. Set the value to network, which specifies an NLB instance.

LoadBalancerNameStringNoNLB1

The name of the NLB instance.

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

AddressTypeStringYesInternet

The type of IPv4 address used by the NLB instance. Valid values:

  • Internet: The NLB instance uses a public IP address. The domain name of the NLB instance is resolved to the public IP address. Therefore, the NLB instance can be accessed over the Internet.
  • Intranet: The NLB instance uses a private IP address. The domain name of the NLB instance is resolved to the private IP address. Therefore, the NLB instance can be accessed over the virtual private cloud (VPC) where the NLB instance is deployed.
Note To enable public IPv6 for a dual-stack NLB instance, call the EnableLoadBalancerIpv6Internet operation.
AddressIpVersionStringNoipv4

The protocol version. Valid values:

  • ipv4: IPv4. This is the default value.
  • DualStack: dual stack
VpcIdStringYesvpc-bp1b49rqrybk45nio****

The ID of the VPC where the NLB instance is deployed.

ZoneMappings.N.VSwitchIdStringYesvsw-sersdf****

The vSwitch in the zone. You can specify only one vSwitch (subnet) in each zone of an NLB instance. You must add at least two zones. You can add a maximum of 10 zones.

ZoneMappings.N.ZoneIdStringYescn-hangzhou-a

The ID of the zone of the NLB instance. You must add at least two zones. You can add a maximum of 10 zones.

You can call the DescribeZones operation to query the most recent zone list.

ZoneMappings.N.PrivateIPv4AddressStringNo192.168.10.1

The private IP address. You must add at least two zones. You can add a maximum of 10 zones.

ZoneMappings.N.AllocationIdStringNoeip-bp1aedxso6u80u0qf****

The ID of the elastic IP address (EIP) that is associated with the Internet-facing NLB instance. You can specify one EIP for each zone. You must add at least two zones. You can add a maximum of 10 zones.

BandwidthPackageIdStringNocbwp-bp1vevu8h3ieh****

The ID of the EIP bandwidth plan that is associated with the Internet-facing NLB instance.

LoadBalancerBillingConfig.PayTypeStringNoPostPay

The billing method of the NLB instance.

Set the value to PostPay, which specifies the pay-as-you-go billing method.

ResourceGroupIdStringNorg-atstuj3rtop****

The ID of the resource group.

DryRunBooleanNofalse

Specifies whether to perform a dry run. Valid values:

  • true: performs a dry run. The system checks the required parameters, the request syntax, and the limits. If the request fails the dry run, an error message is returned. If the request passes the dry run, the DryRunOperation error code is returned.
  • false: performs a dry run and sends the request. If the request passes the dry run, a 2xx HTTP status code is returned and the operation is performed. This is the default value.
ClientTokenStringNo123e4567-e89b-12d3-a456-426655440000

The client token that you want to use to ensure the idempotence of the request.

You can use the client to generate the value, but you must ensure that the value is unique among all requests. The ClientToken value contains only ASCII characters.

Note If you do not set this parameter, the system automatically uses the value of RequestId as the value of ClientToken. The value of RequestId for each API request is different.
RegionIdStringNocn-hangzhou

The ID of the region where the NLB instance is deployed.

You can call the DescribeRegions operation to query the most recent region list.

DeletionProtectionConfig.EnabledBooleanNofalse

Specifies whether to enable deletion protection. Valid values:

  • true: yes
  • false (default): no
DeletionProtectionConfig.ReasonStringNoThe instance is in the Running state.

The reason why the deletion protection feature is enabled or disabled. The value must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The value must start with a letter.

ModificationProtectionConfig.StatusStringNoConsoleProtection

Specifies whether to enable the configuration read-only mode. Valid values:

  • NonProtection: does not enable the configuration read-only mode. You cannot set the Reason parameter. If the Reason parameter is set, the value is cleared.
  • ConsoleProtection: enables the configuration read-only mode. You can set the Reason parameter.
Note If you set this parameter to ConsoleProtection, you cannot modify instance configurations in the NLB console. However, you can modify instance configurations by calling API operations.
ModificationProtectionConfig.ReasonStringNoService guarantee period

The reason why the configuration read-only mode is enabled. The value must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The value must start with a letter.

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

Response parameters

ParameterTypeExampleDescription
RequestIdStringCEF72CEB-54B6-4AE8-B225-F876FF7BA984

The ID of the request.

LoadbalancerIdStringnlb-83ckzc8d4xlp8o****

The ID of the NLB instance.

OrderIdLong20230000

The ID of the order for the NLB instance.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateLoadBalancer
&LoadBalancerType=network
&LoadBalancerName=NLB1
&AddressType=Internet
&AddressIpVersion=ipv4
&VpcId=vpc-bp1b49rqrybk45nio****
&ZoneMappings=[{"VSwitchId":"vsw-sersdf****","ZoneId":"cn-hangzhou-a","PrivateIPv4Address":"192.168.10.1","AllocationId":"eip-bp1aedxso6u80u0qf****"}]
&BandwidthPackageId=cbwp-bp1vevu8h3ieh****
&LoadBalancerBillingConfig={"PayType":"PostPay"}
&ResourceGroupId=rg-atstuj3rtop****
&DryRun=false
&ClientToken=123e4567-e89b-12d3-a456-426655440000
&RegionId=cn-hangzhou
&DeletionProtectionConfig={"Enabled":false,"Reason":"The instance is in the Running state."}
&ModificationProtectionConfig={"Status":"ConsoleProtection","Reason":"Service guarantee period"}
&<Common request parameters>

Sample success responses

XML format

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

<CreateLoadBalancerResponse>
    <RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>
    <LoadbalancerId>nlb-83ckzc8d4xlp8o****</LoadbalancerId>
    <OrderId>20230000</OrderId>
</CreateLoadBalancerResponse>

JSON format

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

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

Error codes

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