edit-icon download-icon

Virtual Private Cloud

Last Updated: Mar 21, 2018

Virtual Private Cloud (VPC) is a private network established in Alibaba Cloud. VPCs are logically isolated from other virtual networks in Alibaba Cloud. You have full control over your VPC, such as specifying the IP address range of your VPC, and configuring route tables and network gateways. You can also use Alibaba Cloud resources such as ECS, RDS, and SLB in your own VPC. For more information, see VPC documentation.

This tutorial uses the CreateVpc API of VPC to show you how to use Alibaba Cloud C# SDK to call VPC APIs.

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Profile;
  4. using Aliyun.Acs.Core.Exceptions;
  5. using Aliyun.Acs.Vpc.Model.V20160428;
  6. class Sample
  7. {
  8. static void Main(string[] args)
  9. {
  10. // Create a client instance
  11. IClientProfile clientProfile = DefaultProfile.GetProfile("<your-region-id>", "<your-access-key-id>", "<your-access-key-secret>");
  12. DefaultAcsClient client = new DefaultAcsClient(clientProfile);
  13. try
  14. {
  15. // Create and initiate the CreateVpcRequest
  16. CreateVpcRequest createRequest = new CreateVpcRequest();
  17. CreateVpcResponse createResponse = client.GetAcsResponse(createRequest);
  18. // Create and initiate the DescribeVpcAttributeRequest
  19. DescribeVpcAttributeRequest describeRequest = new DescribeVpcAttributeRequest();
  20. describeRequest.VpcId = createResponse.VpcId;
  21. DescribeVpcAttributeResponse describeResponse = client.GetAcsResponse(describeRequest);
  22. Console.WriteLine("vpcId: {0}", describeResponse.VpcId);
  23. }
  24. catch (ServerException e)
  25. {
  26. Console.WriteLine(e.ErrorCode);
  27. Console.WriteLine(e.ErrorMessage);
  28. }
  29. catch (ClientException e)
  30. {
  31. Console.WriteLine(e.ErrorCode);
  32. Console.WriteLine(e.ErrorMessage);
  33. }
  34. }
  35. }
Thank you! We've received your feedback.