Deploying ASP.NET Core to the Cloud (Azure, AWS, Docker)

You’ve built your app — now it’s time to ship it. In this post, we’ll explore how to deploy your ASP.NET Core app to the cloud using Azure, AWS, and Docker — all with real-world simplicity.
☁️ Option 1: Deploy to Azure App Service
🔹 Step 1: Publish Locally
dotnet publish -c Release -o ./publish
🔹 Step 2: Deploy via Azure CLI
az login
az webapp up --name MyAspNetApp --resource-group MyResourceGroup --runtime "DOTNET|8.0"
Azure will:
- Provision the web app
- Upload your files
- Generate a public URL
✅ Best for:
- Rapid deployments
- Built-in scaling, logging, SSL
☁️ Option 2: Deploy to AWS with Elastic Beanstalk
🔹 Step 1: Install EB CLI
pip install awsebcli
eb init
eb create MyAspNetEnv
eb deploy
🔹 Step 2: Configure .ebextensions for ASP.NET Core
commands:
01-install-dotnet:
command: |
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 8.0
✅ Best for:
- .NET shops on AWS
- Auto-scaling, managed infra
🐳 Option 3: Deploy with Docker
🔹 Step 1: Create Dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY . .
RUN dotnet publish -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "YourApp.dll"]
🔹 Step 2: Build and Run
docker build -t my-aspnet-app .
docker run -d -p 8080:80 my-aspnet-app
✅ Best for:
- Portability
- DevOps automation
- Kubernetes deployment
⚙️ CI/CD with GitHub Actions
Create .github/workflows/deploy.yml:
name: Build and Deploy
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- run: dotnet build
- run: dotnet test
- run: dotnet publish -c Release -o out
You can add deploy steps to Azure, AWS, or Docker Hub.
🧠 Final Thoughts
You don’t need to be a DevOps guru to ship to production. With tools like Azure, AWS, and Docker, deployment is no longer scary.
✅ Up Next
Let’s wrap up the series with something cool: building and consuming reusable .NET SDKs.
➡️ Building & Using .NET SDKs →
Time to go live 🚀