This was done in our Multi-region AWS community meetup on 27 Feb 2021.
Watch the recording of the session here: https://youtu.be/pleNadLttD8
Building a web application
I used the code from freecodecamp ASP .Net Core Web application tutorial.
Link to the tutorial : https://www.youtube.com/watch?v=C5cnZ-gZy2I
Source code: https://github.com/bhrugen/BookListRazor/tree/master/BookListRazor
Clone the repository from the Github and build it. You will need Visual Studio 2019 community eddition for this.
If your background is .Net, you can build your own fun project. If you are not from programming background, don’t worry too much about the coding part.
Provision AWS resources
For this exercise, we need a SQL Server Express RDS instance and a Windows Server 2019 EC2 instance.
Create a SQL Server Express RDS instance
https://aws.amazon.com/getting-started/hands-on/create-microsoft-sql-db/
Make sure you have allowed port 1433 on your Security Group from ‘any’ source. (0.0.0.0/0). If you want to connect to your database from your local machine, you have to add this. Or you can allow only your public IP as the source. Google “what’s my IP” to find your public IP.
Allowing DB access from the Internet is NOT a good practice. Normally, you would do this through a VPN connection. This is used only for the demo purpose.
Instead of using RDS, you can use SQL Server Docker image and run it in the same Windows server. But in this case, you may have to choose a bigger EC2 instance like m5.large because the resources in t2.micro will not be enough to run the SQL Docker instance.
You can use SQL Server Management Studio Express to connect to the database. If you are on a Mac, you can use Azure Data Studio for the same.
https://hub.docker.com/r/microsoft/mssql-server-windows-express/
Once you have the DB running, you can run Entity Framework Migrations from your Visual Studio or from .Net Core CLI to create the database table.
https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli
Create a Windows Server 2019 EC2
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/EC2_GetStarted.html
Allow RDP port in your Security Group for you to connect using a remote desktop from your machine. Again, this is NOT a good practice. Typically, you should be using a VPN or a Bastian host to connect to your machines inside your private subnet.
Setup IIS Web server and configure the web application
Install IIS https://computingforgeeks.com/install-and-configure-iis-web-server-on-windows-server/
Install .Net Core Hosting bundle and create a website on IIS https://docs.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-5.0&tabs=visual-studio
Publish your web app
Publish your web application using the folder option. https://docs.microsoft.com/en-us/visualstudio/deployment/quickstart-deploy-to-local-folder?view=vs-2019
Copy the content of the publish folder to the physical path which you assigned to your website on IIS.
You can select the ‘Brows’ option in the IIS manager to see the page in the server itself or you can copy the public IP address or the public DNS from your EC2 instance details section and past it to the browser.
Also, you can assign a DNS (example: https://mywebapp.come) for your web application using Route 53. Watch my video to see how to setup DNS.