Lab 2. Using RDS with ASP.NET Applications


In this lab you are going to launch a new MySQL RDS (Relational Database Service) instance to migrate your local MySQL database to Cloud database.


MySQL Workbench provides data modeling, SQL development, and comprehensive administration tools for server configuration, user administration, backup, and much more. In this lab MySQL workbench will help us to connect with the RDS instance we create.

Amazon Relational Database Service (Amazon RDS)/ RDS Read Replicas

Amazon Relational Database Service (Amazon RDS) makes it easy to set up, operate, and scale a relational database in the cloud. It provides cost-efficient and re-sizable capacity while managing time-consuming database administration tasks, freeing you up to focus on your applications and business. Amazon RDS Read Replicas provide enhanced performance and durability for database (DB) instances. This replication feature makes it easy to elastically scale out beyond the capacity constraints of a single DB Instance for read-heavy database workloads.

By doing this lab you will learn:

  • How to create a RDS Instance
  • How to connect the created RDS instance with your MySQL workbench
  • How to create a RDS Read Replica
  • How to connect your created RDS Read Replica with your MySQL workbench
  • How to compile codes in Visual Studio

The image shown below is the architecture for this lab.


To begin with the lab, first you have to create a RDS instance, to create a RDS instance > go to services > select RDS.

When you are on the RDS dashboard click on Get Started Now and click on Launch DB Instance. 

Note: Make a note of the region when you create the instance.


Click on MySQL and click on Select.


Click on the MySQL radio button which is next to Amazon Aurora and click Next.


Select db.t1.micro from the DB Instance Class.


Select Yes for Multi-AZ Deployment.
Select General Purpose (SSD) as your storage type.
Type 5GB as your Allocated Storage.
Give the instance Identifier a name as for me i have given ‘DinoStoreInstance‘ as my DB instance identifier name. In Master Username type ‘admin’ and type ‘Walasinsondy1‘ as the password.


select ‘Create New Security Group’ from the VPC security Group(s) (The security group allow your current IP address to connect to your instance will be created. This will make it easier for you to connect to the instance and configure it.)

Give the Database name as ‘dinostoredb’.


Enable automatic backups by selecting the period of days. As you can see it in the below image i have given 1 day. Click on Launch DB Instance.


To Launch the instance it will take 10-15mints please be patient.


When the instance is launched the status will show ‘available’. Click on the instance you created in order to get the end point.


To go to RDS instance security group click on the instance you created and select details. you will be able to see the security group as a link click on it and you will be directed to security groups.


Set the inbound rule to MySQL and select ‘My IP’ under source. click on save.


To connect your RDS instance with the MySQL click on the ‘+’ sign which is next to MySQL connection and the Setup New Connection window will appear, In that window give the following details.
Connection name= AWS DinoStore
Hostname= (End point/remove the ‘:3306’)
Password= click on store in vault and provide the master password you gave when creating the RDS instance which is ‘Walaginsondy1’.


When all the details are provided click on test connection to see if the connection has been establish between cloud and your machine. If it successful you will get a pop up message like which is shown below.


To create the tables in cloud use the same script file you used to create table in local machine. Click on > File > Open SQL script choose the script file from your local computer and click open.


After opening it. click on execute to execute to it.


To add products upload the correct CSV file with the correct imageReferences.


Change the imagereferences with the links that is given by the AWS. click on apply.

Screenshot (48)

When its applied click on finish.


Now lets create Read Replica of our dinostoredb in the RDS instances, by selecting the dinostoredb and right click to get an action menu and select Create read replica.


Give the following details when creating the Read Replica DB instance.


DB Instance Identifier=’dinostoreinstancereplica’
Keep the DB instance class the same as the main db =’micro’
Pick a different Availability Zone from the drop down list.
Click on Create Read Replica
It will take 10-15mints to get it created.


To connect the read replica you created with your local machine you have to do the same steps as you did it for connecting your dinostoredb. click on the ‘+’ and when the setup new connection window pops-up give the following details.
Connection name=’AWS Dinostore Replica’
Hostname=’’ (Endpoint)
Enter the same ‘admin and username you gave while creating the dinostoredb’


Click on Test connection to see whether the connection is establish or not.


When you are connected go to product table and see if the same information is available or not.


Go to your visual studio and click on web.config code and make changes to the use new cloud database by changing the connection strings.


the code should be like it is shown above. Add another line copied from the above with the name =’StoreSqlDbReplica’ and the appropriate link to the cloud replica database.


In the Default.aspx.cs code, under the ‘//connectstring for MySQL’ comment, change the ConfigurationManager.ConnectionStrings from ‘StoreSqlDb’ to ‘StoreSqlDbReplica’. (This pulls the images from the replica database (reads only) which takes the load off the primary database, and leaves a few more cycles for writes.)


To test the new connection open it on your browser.


Click on Create account to check out the cloud membership database in MySQL workbench.


Fill the details


Click on create user when all the fields are filled properly.


Now go to your Cloud membership database in MySQL workbench and there you will see tables with the name ‘my_asp’ and click on ‘ my_aspnet_membership



Now lets make our Primary RDS server and reboot it with failover.


Click on the Dinostoreinstance and click on Actions and select reboot.


Tick restart with failover. Click on Reboot.


While it getting restart you can check if the site is still ok and if its working. Log in using the proper credentials and check if you can login.


As you can see the image below it shows that even with a failover you can log in to your account.


When all of these steps are done you have completed the lab successfully.


By the end of this lab you have learned:

  • How to create a RDS Instance
  • How to connect the created RDS instance with your MySQL workbench
  • How to create a RDS Read Replica
  • How to connect your created RDS Read Replica with your MySQL workbench
  • How to compile codes in Visual Studio

Budget Plan

When you are using RDS, you only have to pay for what you use. There is no minimum fee. In this lab i’m using db.t1.micro and it cost me $0.0025 per hour. For this lab i have deployed a multi-Availability Zone as well therefore when you Deploy a Multi-AZ it will cost you bit higher than the actual cost and it would be $0.060 per hour ( Price varies according to different regions). If i create the same db.t1.micro instance in Asia Pacific (Tokyo) it will cost me $0.030 per hour. and there are different kind of DB instances according to your need like db.m1.medium and this will cost you in Asian Pacific (Tokyo) $0.145 per hour.

AWS will give you so many benefits to a reasonable price, you just have to decide which region you want to run your business services.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s