How would you migrate a legacy .NET Framework app to containers?

AdvancedProduction.NET builds (dotnet CLI)
Answer

Short answer

First decide: lift and shift into Windows containers (fast, keeps .NET Framework, large images, needs Windows nodes), or re-platform to modern .NET so it runs in Linux containers (more work, but smaller, cheaper and fully cloud-native). Most teams containerise as-is first if needed, then migrate project by project using the .NET Upgrade Assistant.

Option A: Windows containers (keep .NET Framework)

FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2022
COPY ./publish/ /inetpub/wwwroot

Runs on AKS/EKS Windows node pools. Images are several GB.

Option B: Upgrade to modern .NET

  1. Inventory dependencies — are there .NET 8 versions? (WCF server, Web Forms and some libraries have no direct equivalent.)
  2. Run the .NET Upgrade Assistant; convert projects to SDK-style csproj targeting net8.0.
  3. Replace web.config/ConfigurationManager with appsettings.json + environment variables.
  4. Replace Windows-only APIs (registry, GDI, Windows auth) or isolate them.
  5. Containerise with the multi-stage Linux Dockerfile; add health checks and probes.
  6. Strangler pattern: move endpoints gradually behind a gateway, run old and new side by side.

What to say in the interview

"I'd assess dependencies first. Short term, Windows containers on a Windows node pool can work without code changes. The real target is upgrading to .NET 8 with the Upgrade Assistant, externalising config to appsettings and env vars, then running in Linux containers — often migrating gradually with a strangler pattern."

All Build Tools (Java, Node.js, Python, .NET) questions Roadmap: .NET apps: dotnet build & publish

More on .NET builds (dotnet CLI)