edit-icon download-icon

ApsaraDB for RDS

Last Updated: Mar 21, 2018

ApsaraDB for RDS (Relational Database Service) is a stable and reliable online database service that supports the elastic scaling function. ApsaraDB for RDS is based on the Apsara distributed system and high-performance storage of ephemeral SSD and supports MySQL, SQL Server, and PostgreSQL engines. ApsaraDB for RDS offers a complete set of solutions for backup, recovery, monitoring, migration, disaster recovery, and troubleshooting database operation and maintenance. For more information, see ApsaraDB for RDS.

This tutorial uses the CreateDBInstance API of ApsaraDB RDS to show you how to use Alibaba Cloud C# SDK to create an ApsaraDB for RDS instance.

Note: Running the code in this example will create an ApsaraDB RDS instance and generate fees.

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Profile;
  4. using Aliyun.Acs.Core.Exceptions;
  5. using Aliyun.Acs.Rds.Model.V20140815;
  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 a request and set parameters
  16. CreateDBInstanceRequest request = new CreateDBInstanceRequest();
  17. request.Engine = "MySQL";
  18. request.EngineVersion = "5.6";
  19. request.DBInstanceClass = "rds.mys2.small";
  20. request.DBInstanceStorage = 5;
  21. request.DBInstanceNetType = "Internet";
  22. request.SecurityIPList = "11.11.11.11";
  23. request.PayType = "Postpaid";
  24. request.ClientToken = "ETnLKlblzczshOTUbOCziJZNwHlYBQ";
  25. // Initiate the request and print the handling result
  26. CreateDBInstanceResponse response = client.GetAcsResponse(request);
  27. Console.WriteLine("DBInstanceId: {0}", response.DBInstanceId);
  28. }
  29. catch (ServerException e)
  30. {
  31. Console.WriteLine(e.ErrorCode);
  32. Console.WriteLine(e.ErrorMessage);
  33. }
  34. catch (ClientException e)
  35. {
  36. Console.WriteLine(e.ErrorCode);
  37. Console.WriteLine(e.ErrorMessage);
  38. }
  39. }
  40. }
Thank you! We've received your feedback.