All Products
Search
Document Center

Alibaba Cloud SDK:Configure an endpoint

Last Updated:May 27, 2022

This topic describes how to configure an endpoint in the Classic SDK.

An endpoint is a domain name of an Alibaba Cloud service API. For example, an endpoint of the Elastic Compute Service (ECS) API can be ecs.cn-hangzhou.aliyuncs.com.

If an endpoint cannot be retrieved, you must specify an endpoint. The Classic SDK provides four addressing modes for endpoints. The following list describes the addressing modes by priority in descending order:

  1. User-defined addressing mode: This mode is assigned the highest priority. In this mode, you can specify an exact endpoint.

// The mode globally takes effect.
IClientProfile profile = DefaultProfile.GetProfile("<regionId>", "<ACCESS_KEY_ID>", "<ACCESS_KEY_SECRET>");
profile.AddEndpoint("<endpointName>", "<regionId>", "<product>", "<domain>");

// The mode takes effect only on the current request.
DescribeRegionsRequest request = new DescribeRegionsRequest();
request.SetEndpoint("<Endpoint>");

2. Concatenation-based addressing mode: In this mode, an endpoint is generated by concatenating data. This mode takes effect only when API requests are sent over a virtual private cloud (VPC) or the SDK for an Alibaba Cloud service uses an endpoint data file. For more information about an endpoint data file, visit ECS endpoint data file.

// Send an request over the Internet.
request.ProductNetwork = "public"; // The default value of the productNetwork parameter is public. You do not need to configure the parameter.

// Send a cross-origin request.
request.ProductNetwork = "share";

// Send an IPv6 request.
request.ProductNetwork = "ipv6";

// Send a request by using a proxy.
request.ProductNetwork = "proxy";

// Send a request over an internal network.
request.ProductNetwork = "inner";

// Send a request over a network that supports both IPv4 and IPv6.
request.ProductNetwork = "dualstack";

// Send a request over a VPC.
request.ProductNetwork = "vpc";