Endpoint configuration
Configure an endpoint in the Classic SDK to specify the network domain name used for API requests.
An endpoint is the network domain name of an API service, such as ecs.cn-hangzhou.aliyuncs.com.
If an endpoint cannot be automatically retrieved, you must configure one manually. The Classic SDK provides two addressing modes, listed by priority in descending order:
-
User-defined addressing mode: Has the highest priority. You can specify an exact endpoint.
// Takes effect globally.
IClientProfile profile = DefaultProfile.GetProfile(
// The region ID.
"<your-region-id>",
// Get the AccessKey ID of a Resource Access Management (RAM) user from an environment variable.
Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_ID"),
// Get the AccessKey secret of the RAM user from an environment variable.
Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
profile.AddEndpoint("<endpointName>", "<regionId>", "<product>", "<domain>");
DefaultAcsClient client = new DefaultAcsClient(profile);
// Takes effect only for the current request.
DescribeRegionsRequest request = new DescribeRegionsRequest();
request.SetEndpoint("<Endpoint>");
2. Concatenation-based addressing mode: The endpoint is generated from concatenated data. This mode takes effect only when API requests are sent over a virtual private cloud (VPC) or the SDK of an Alibaba Cloud service uses an endpoint data file. For more information about an endpoint data file, visit GitHub.
// Send a 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 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";