☁️ 1. Overview
A .NET Core application typically includes:
Frontend: ASP.NET Razor pages, React, Angular, or Blazor.
Backend: ASP.NET Core Web API.
Database: SQL Server or PostgreSQL.
Hosting: On AWS compute or container services.
๐งฉ 2. AWS Services You Can Use to Host .NET Core Apps
Service Type Use Case
AWS Elastic Beanstalk Platform as a Service (PaaS) Easiest way to deploy .NET apps — AWS handles scaling, load balancing, and provisioning.
Amazon EC2 Infrastructure as a Service (IaaS) Gives full control of the OS and runtime — ideal for custom environments.
Amazon ECS (Fargate) Container Service For Dockerized .NET Core apps, fully managed container orchestration.
Amazon EKS (Kubernetes) Managed Kubernetes For microservices or large distributed .NET workloads.
AWS Lambda + API Gateway Serverless Run small, event-driven .NET functions without managing servers.
AWS App Runner PaaS Simplified container hosting service — great for web APIs and microservices.
⚙️ 3. Prerequisites
Before deployment, make sure you have:
✅ A working .NET Core app (e.g., ASP.NET Core Web API or MVC).
✅ AWS account → https://aws.amazon.com
✅ AWS CLI installed and configured:
aws configure
✅ AWS Toolkit for Visual Studio (optional but recommended).
✅ Docker (if deploying containers).
๐งฑ 4. Option 1 — Deploy to AWS Elastic Beanstalk (Simplest Method)
Step 1: Prepare Your Application
In your project directory:
dotnet publish -c Release
This generates files in /bin/Release/net8.0/publish.
Step 2: Create Elastic Beanstalk Environment
Go to AWS Management Console → Elastic Beanstalk → Create New Application.
Choose:
Platform: .NET Core on Linux or .NET on Windows Server
Environment Type: Web server environment
Upload your published ZIP from step 1.
Elastic Beanstalk automatically:
Creates an EC2 instance
Configures Load Balancer, Auto-scaling, and Application Monitoring
Step 3: Deploy via AWS CLI (optional)
You can deploy directly from your terminal:
eb init
# Choose region and platform (.NET Core)
eb create my-dotnet-env
eb deploy
✅ Once deployed, your app will be available at a URL like:
http://my-dotnet-env.us-east-1.elasticbeanstalk.com
๐งฐ 5. Option 2 — Deploy Using AWS EC2 (Manual Setup)
This gives you full control of the hosting environment.
Step 1: Create an EC2 Instance
Launch a Windows Server or Amazon Linux 2 EC2 instance.
Open ports 80 (HTTP) and 443 (HTTPS) in the Security Group.
Step 2: Install .NET Runtime
If using Linux:
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
sudo yum install dotnet-runtime-8.0 -y
If using Windows:
Download and install .NET Hosting Bundle from Microsoft’s website.
Step 3: Copy and Run App
Upload your published files (via SCP, WinSCP, or AWS SSM):
scp -i key.pem -r ./publish ec2-user@<EC2-IP>:/var/www/myapp
Run the app:
cd /var/www/myapp
dotnet ServerApp.dll
✅ Your app is live at http://<EC2-IP>:5000
(Optional: use Nginx or IIS to serve it on port 80 with SSL).
๐ณ 6. Option 3 — Deploy as Containers (ECS or App Runner)
Step 1: Dockerize Your App
Create a Dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "MyApp.dll"]
Step 2: Push to Amazon ECR (Elastic Container Registry)
aws ecr create-repository --repository-name mydotnetapp
docker build -t mydotnetapp .
docker tag mydotnetapp:latest <account-id>.dkr.ecr.us-east-1.amazonaws.com/mydotnetapp:latest
aws ecr get-login-password | docker login --username AWS --password-stdin <account-id>.dkr.ecr.us-east-1.amazonaws.com
docker push <account-id>.dkr.ecr.us-east-1.amazonaws.com/mydotnetapp:latest
Step 3: Deploy to ECS (Fargate)
Create a new ECS cluster.
Define a task definition with your ECR image.
Choose Fargate (serverless containers).
Set up a service and Application Load Balancer.
✅ AWS runs your .NET app in containers with automatic scaling and monitoring.
⚡ 7. Option 4 — Deploy Serverless with AWS Lambda
If your app is lightweight (e.g., APIs or background tasks):
Step 1: Create a Lambda-Ready Project
dotnet new serverless.AspNetCoreWebAPI -n MyLambdaApp
Step 2: Deploy with AWS SAM
sam build
sam deploy --guided
Step 3: Access via API Gateway
After deployment, AWS provides an API Gateway endpoint:
https://xyz123.execute-api.us-east-1.amazonaws.com/Prod/
✅ Fully serverless — no servers, no scaling headaches, pay only per request.
๐พ 8. Option 5 — Use AWS App Runner (Fastest Container Hosting)
Push your Dockerized app to GitHub or ECR.
Open AWS App Runner in the console.
Create a new service → choose Container registry or GitHub repository.
Configure build and deploy settings.
App Runner handles:
Building your app,
Running it in containers,
Scaling automatically.
✅ Great for web APIs — no need to manage ECS or EC2.
๐ง 9. Adding a Database
You can connect your .NET Core app to:
Database Type AWS Service Notes
SQL Server Amazon RDS (Relational Database Service) Fully managed SQL instance.
PostgreSQL / MySQL Amazon RDS Scalable open-source options.
NoSQL Amazon DynamoDB Serverless document storage.
Caching Amazon ElastiCache Redis or Memcached for high-speed caching.
Example connection string (RDS SQL Server):
"ConnectionStrings": {
"DefaultConnection": "Server=mydb.xxxxx.us-east-1.rds.amazonaws.com;Database=myappdb;User Id=admin;Password=MyPassword;"
}
๐ 10. CI/CD Pipeline with AWS CodePipeline
You can automate build and deployment with:
AWS CodeCommit → source control
AWS CodeBuild → builds .NET projects
AWS CodeDeploy / Elastic Beanstalk / ECS → deploys app
AWS CodePipeline → orchestrates the workflow
Example .buildspec.yml:
version: 0.2
phases:
build:
commands:
- dotnet restore
- dotnet publish -c Release -o ./publish
artifacts:
files:
- '**/*'
base-directory: ./publish
๐ 11. Monitoring and Logging
Amazon CloudWatch → monitor performance, logs, and health checks.
AWS X-Ray → trace API calls and application latency.
Elastic Beanstalk Console → real-time app metrics and health.
Example for logging in .NET Core:
builder.Logging.AddAWSProvider();
builder.Logging.SetMinimumLevel(LogLevel.Information);
๐ 12. Security and IAM
Use AWS IAM Roles for access control (e.g., access to S3 or RDS).
Store secrets in AWS Secrets Manager:
var secretValue = await client.GetSecretValueAsync(new GetSecretValueRequest { SecretId = "MyDbSecret" });
Enable HTTPS with AWS Certificate Manager and Elastic Load Balancer.
✅ 13. Summary — Choosing the Right Hosting Option
Scenario Best AWS Service
Beginner / Simple Web App Elastic Beanstalk
Need Full Control EC2
Containerized App ECS / App Runner
Microservices / Kubernetes EKS
Serverless APIs AWS Lambda + API Gateway
Continuous Delivery CodePipeline + CodeBuild
๐ Bottom Line
Hosting a .NET Core app on AWS is flexible — whether you want a managed service (Elastic Beanstalk), full control (EC2), container orchestration (ECS/EKS), or serverless (Lambda).
For most developers starting out:
๐ข AWS Elastic Beanstalk is the easiest and most efficient way to host .NET Core apps in the cloud.
Learn Dot Net Course in Hyderabad
Read More
Introduction to Cloud Services in Full Stack .NET Development
Deploying Full Stack .NET Applications on Azure
Cloud and Deployment in Dot Net
Continuous Integration and Continuous Deployment (CI/CD) in .NET
Visit Our Quality Thought Institute in Hyderabad
Subscribe by Email
Follow Updates Articles from This Blog via Email
No Comments