Deploy ASP.NET Core to Azure App Service

The $5000/month bill mistake and how to avoid it. 7 mins.

Your First "Aha" Moment: Azure App Service is just IIS in the cloud. But with slots, auto-scale, and a credit card attached.

1. App Service Plan = Your Azure Bill

Free F1: 60 min/day compute. Sleeps. Good for demo. Bad for users.
Basic B1: ~$13/month. Always on. No slots. No auto-scale.
Standard S1: ~$70/month. Has slots + 5 deploy slots. Minimum for prod.
Premium P1v3: ~$200/month. VNet, Private Endpoint, faster CPU.

Career-Killer Mistake #1: Choosing P1v3 "to be safe".
What happens: $200/month * 3 envs = $600/month. For a CRUD API with 10 users. CTO fires you.
Fix: Start B1. Load test. Move to S1 only if you need slots. Scale up, not out.

2. Deploy in 3 Ways - Pick One

MethodSpeedUse When
VS Publish30sFirst-time, testing. Never for prod.
Azure CLI1 minaz webapp up --name myapp --resource-group rg
GitHub Actions3 minProduction. CI/CD. Auto-deploy on push.

3. Deployment Slots = Zero Downtime

Problem: Deploy to prod. App restarts. Users see 502 for 30s.

Fix: 1. Deploy to staging slot. 2. Warm it up: hit myapp-staging.azurewebsites.net. 3. Click "Swap" with prod. Instant DNS switch. 0s downtime.

az webapp deployment slot swap -g rg -n myapp --slot staging --target-slot production

4. Secrets: Never in appsettings.json

Wrong: Commit "ConnectionStrings": {"Default": "Server=prod;..."} to git.
Right: Azure Portal โ†’ App Service โ†’ Configuration โ†’ Connection strings. Or Azure Key Vault.

Code: builder.Configuration.AddEnvironmentVariables() reads them. Name = ConnectionStrings__Default.

Stop Here. Think. App Service logs to /LogFiles. Download via Kudu: myapp.scm.azurewebsites.net.
Next: Docker. Why every startup uses it and banks are scared of it.

Quick Check ๐Ÿง 

Next: Docker Azure locks you in. Docker Basics teaches you to build once, run anywhere. K8s, AWS, on-prem. Let's go โ†’

Comments on Deploy to Azure (0)

No comments yet. Be the first to share your thoughts!