Management Plane API > Networking > Services > Loadbalancer

Create a load balancer virtual server with rules

It is used to create virtual servers, the associated rules and bind the
rules to the virtual server.
To add new rules, make sure the rules which have no identifier specified,
the new rules are automatically generated and associated to the virtual
server.
If the virtual server need to consume some existed rules without change,
those rules should not be specified in this array, otherwise, the rules
are updated.

Request:

Method:
POST
URI Path(s):
/api/v1/loadbalancer/virtual-servers?action=create_with_rules
Request Headers:
n/a
Query Parameters:
n/a
Request Body:
LbVirtualServerWithRule+

Example Request:

POST https://<nsx-mgr>/api/v1/loadbalancer/virtual-servers?action=create_with_rules { "virtual_server": { "ip_protocol":"TCP", "enabled":"true", "pool_id":"356ab0ad-3fdc-48ef-b9df-8c05cedc0fc3", "default_pool_member_port" : "80", "application_profile_id":"cb2d0721-cc15-5b8e-8633-14be114eac5e", "ip_address":"123.123.123.123", "port":"80", "display_name":"LB_HTTP_VirtualServer", "description":"LB_HTTP_VirtualServer created through automation" }, "rules": [ { "resource_type" : "LbRule", "display_name": "LoginRouteRule", "description": "LbRule to route login requests to dedicated pool", "match_conditions" : [{ "type": "LbHttpRequestUriCondition", "match_type": "EQUALS", "uri": "/login", "inverse": false }], "match_strategy" : "ALL", "phase" : "HTTP_FORWARDING", "actions" : [{ "type": "LbSelectPoolAction", "pool_id": "b6a5bffa-f6a9-447c-6666-4633f9eb1234" }] }, { "resource_type" : "LbRule", "display_name": "URIRewriteRule", "description": "Sample URI rewrite rule", "match_conditions" : [{ "type": "LbHttpRequestUriCondition", "match_type": "REGEX", "uri": "/news/(?<year>\\d+)/(?<month>\\d+)/(?<article>.*)", "inverse": false }], "match_strategy" : "ALL", "phase" : "HTTP_REQUEST_REWRITE", "actions" : [{ "type": "LbHttpRequestUriRewriteAction", "uri": "/news/$year-$month-$article", "uri_arguments": "" }] } ] }

Successful Response:

Response Code:
201 Created
Response Headers:
Content-type: application/json
Response Body:
LbVirtualServerWithRule+

Example Response:

{ "virtual_server": { "resource_type" : "LbVirtualServer", "description" : "LB_HTTP_VirtualServer", "id" : "801ebbb3-90bf-403b-b061-9ec6294813b2", "display_name" : "LB_HTTP_VirtualServer", "ip_address" : "123.123.123.123", "pool_id" : "356ab0ad-3fdc-48ef-b9df-8c05cedc0fc3", "enabled" : true, "rule_ids" : ["b6a5bffa-f6a9-447c-936f-4633f9eb43a7", "c6a5bffa-f6a9-447c-936f-4633f9eb43a7"], "ip_protocol" : "TCP", "default_pool_member_port" : "80", "port" : "80", "application_profile_id" : "5563bc87-799d-4340-9715-27e43cb1e60c", "_create_user" : "admin", "_create_time" : 1506659379394, "_last_modified_user" : "admin", "_last_modified_time" : 1506659379394, "_system_owned" : false, "_protection" : "NOT_PROTECTED", "_revision" : 0 }, "rules": [ { "resource_type" : "LbRule", "id" : "b6a5bffa-f6a9-447c-936f-4633f9eb43a7", "display_name": "LoginRouteRule", "description": "LbRule to route login requests to dedicated pool", "match_conditions" : [{ "type": "LbHttpRequestUriCondition", "match_type": "EQUALS", "uri": "/login", "inverse": false }], "match_strategy" : "ALL", "phase" : "HTTP_FORWARDING", "actions" : [{ "type": "LbSelectPoolAction", "pool_id": "b6a5bffa-f6a9-447c-6666-4633f9eb1234" }], "_create_time" : 1478304339963, "_create_user" : "admin", "_last_modified_user" : "admin", "_system_owned" : false, "_last_modified_time" : 1478304339963, "_revision" : 0 }, { "resource_type" : "LbRule", "id" : "c6a5bffa-f6a9-447c-936f-4633f9eb43a7", "display_name": "URIRewriteRule", "description": "Sample URI rewrite rule", "match_conditions" : [{ "type": "LbHttpRequestUriCondition", "match_type": "REGEX", "uri": "/news/(?<year>\\d+)/(?<month>\\d+)/(?<article>.*)", "inverse": false }], "match_strategy" : "ALL", "phase" : "HTTP_REQUEST_REWRITE", "actions" : [{ "type": "LbHttpRequestUriRewriteAction", "uri": "/news/$year-$month-$article", "uri_arguments": "" }], "_create_time" : 1478304339963, "_create_user" : "admin", "_last_modified_user" : "admin", "_system_owned" : false, "_last_modified_time" : 1478304339963, "_revision" : 0 } ] }

Required Permissions:

crud

Feature:

lb_virtual_servers

Additional Errors: