You can call this operation to switch the network type of an ApsaraDB for Redis instance. You can switch the network type of an instance from the classic network to Virtual Private Cloud (VPC).

For more information about how to perform the corresponding operation in the console, see Switch to VPC network.

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 No SwitchNetwork

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

InstanceId String Yes r-j6cxxxxxxxxxxxxxx

The ID of the instance.

TargetNetworkType String No VPC

The network type to which you want to switch. Currently, you can only switch from classic network to VPC. Set this parameter to VPC.

VpcId String No vpc-bp1xxxxxxxxxxxxxxxxxx

The ID of the VPC where the instance is deployed after you switch the network type of the instance to VPC.

RetainClassic String No True

Specifies whether to retain the connection address of the classic network.

  • True
  • False
Note Default value: False.
VSwitchId String No vsw-sdrxxxxxxxxxxxxxxxxxx

The ID of the VSwitch in the VPC network after you switch the network type of the instance to VPC. This parameter is required if the VpcId parameter is specified.

ClassicExpiredDays String No 30

The retention period of the connection address of the classic network. Unit: days. Valid values: 14, 30, 60, and 120. This parameter is required if RetainClassic is set to True.

Note For more information about how to modify the retention period after the network type is switched to VPC, see ModifyInstanceNetExpireTime.
RegionId String No cn-hangzhou

The ID of the region.

Response parameters

Parameter Type Example Description
RequestId String F0997EE8-F4C2-4503-9168-85177ED78C70

The ID of the request.

TaskId String 578678678

The ID of the task.

Examples

Sample requests

https://r-kvstore.aliyuncs.com
?Action=SwitchNetwork
&InstanceId=r-j6cxxxxxxxxxxxxx
&TargetNetworkType=VPC
&VpcId=vpc-bp1xxxxxxxxxxxxxxxxxx
&VSwitchId=vsw-sdrxxxxxxxxxxxxxxxxxx
&RetainClassic=True
&ClassicExpiredDays=30
&<Common request parameters>

Sample success responses

XML format

<SwitchNetworkResponse>
      <TaskId>578678678</TaskId>
      <requestId>F0997EE8-F4C2-4503-9168-85177ED78C70</requestId>
</SwitchNetworkResponse>

JSON format

{   
    "TaskId":"578678678",
    "requestId": "F0997EE8-F4C2-4503-9168-85177ED78C70"
}

Error codes

HttpCode Error code Error message Description
400 InvalidToken.Malformed The Specified parameter "Token" is not valid. The error message returned because the verification of the token failed.
400 VpcServiceError Invoke vpc service failed. The error message returned because calling the VPC service failed.
400 IzNotSupportVpcError Specify iz not support vpc. The error message returned because the specified iz does not support VPC.
400 IzNotSupportSwitchNetworkError Specify iz not support switch network. The error message returned because the specified iz does not support network switching.
400 VpcId is wrong. VpcId is wrong. The error message returned because the specified VPC ID is incorrect.

For a list of error codes, visit the API Error Center.