本示例介绍如何使用阿里云.NET SDK调用RDS的CreateDBInstance接口创建一个RDS实例。

阿里云关系型数据库(Relational Database Service,简称RDS)是一种稳定可靠、可弹性伸缩的在线数据库服务。基于阿里云分布式文件系统和高性能存储,RDS 支持MySQL、SQL Server、PostgreSQL和PPAS(Postgre Plus Advanced Server,一种高度兼容 Oracle 的数据库)引擎,并且提供了容灾、备份、恢复、监控和迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。

阿里云2000元代金券免费领,最新优惠1折抢购,2核4G云服务器仅799元/3年,新老用户同享,立即抢购>>>

示例代码

注意 运行该示例代码将创建RDS实例,并产生实际费用。

using System; using Aliyun.Acs.Core; using Aliyun.Acs.Core.Profile; using Aliyun.Acs.Core.Exceptions; using Aliyun.Acs.Rds.Model.V20140815;  class Sample {     static void Main(string[] args)     {         // 创建客户端实例         IClientProfile clientProfile = DefaultProfile.GetProfile("<your-region-id>", "<your-access-key-id>", "<your-access-key-secret>");         DefaultAcsClient client = new DefaultAcsClient(clientProfile);          try         {             // 创建API请求并设置参数             CreateDBInstanceRequest request = new CreateDBInstanceRequest();             request.Engine = "MySQL";             request.EngineVersion = "5.6";             request.DBInstanceClass = "rds.mys2.small";             request.DBInstanceStorage = 5;             request.DBInstanceNetType = "Internet";             request.SecurityIPList = "11.11.11.11";             request.PayType = "Postpaid";             request.ClientToken = "ETnLKlblzczshOTUbOCziJZNwHlYBQ";              // 请求并打印处理结果             CreateDBInstanceResponse response = client.GetAcsResponse(request);             Console.WriteLine("DBInstanceId: {0}", response.DBInstanceId);         }         catch (ServerException e)         {             Console.WriteLine(e.ErrorCode);             Console.WriteLine(e.ErrorMessage);         }         catch (ClientException e)         {             Console.WriteLine(e.ErrorCode);             Console.WriteLine(e.ErrorMessage);         }     } }