Azure App Service, a virtual machine or containers: where should your .NET application run?
Moving a .NET application to Azure? Who patches what in App Service, a VM and Container Apps, what each costs over time, and how to pick per application.
Vlado Pandžić · Founder · Senior .NET architect
Published · 4 min read
Contents
When a .NET application leaves an old server, the first question is where it runs next. In Azure, there are three realistic answers for a business application: a virtual machine, App Service, or Container Apps. The most common mistake is choosing the virtual machine because it feels familiar, and then running the same old server, only rented.
Who does what
| Virtual machine | App Service | Container Apps | |
|---|---|---|---|
| Who patches the operating system | You | Azure | Azure |
| What you manage | Everything from Windows up | Your application and its settings | Your container and its settings |
| Scaling | Bigger machine, or more machines you set up | More instances with a setting | Automatic, down to zero when idle |
| How you pay | Around the clock, used or not | For the plan, around the clock | For usage; nothing while scaled to zero |
| Fits best | Applications that need things only a full server gives | Most web applications and APIs | Containerised services, background jobs, irregular load |
App Service runs both modern .NET and older ASP.NET applications on .NET Framework, on Windows plans. You do not have to finish a migration to .NET 10 before moving to Azure.
When a virtual machine
- The application needs installed software, COM components or Windows services that App Service does not allow.
- It relies on specific operating system settings or full access to the file system.
- You need to leave an old server quickly, and the proper move comes later.
Just be clear about what you are getting: the same responsibilities as on your own server. Updates, backups, monitoring and security are still yours. If the reason for leaving was an old Windows Server, as with Windows Server 2012 R2, a virtual machine with a new Windows solves the date, not the work.
When App Service
For most .NET web applications and APIs, this is the default answer. Azure patches the operating system and the runtime, you deploy the application, and scaling out is a setting.
One feature alone often justifies it: deployment slots. A new version is deployed to a staging slot, checked there, and then swapped into production without downtime. If something goes wrong, you swap back.
az webapp deployment slot swap \
--resource-group orders-rg --name orders-app \
--slot staging --target-slot production
The usual trap is the plan size. A plan that is too large costs every hour of every day. Our article on reducing Azure costs covers where the money usually goes.
When Container Apps
- The application already runs in Docker, or you want it to.
- Background work that runs now and then: imports, reports, queue processing.
- Irregular load. A container app can scale down to zero, and while it is at zero, you pay no usage charges.
Kubernetes (AKS) is the next step up, and for one or two business applications it is rarely worth the extra operational work. It makes sense for teams that run many services.
The order that works
- Step 1Inventory: what each application needs
- Step 2Choose a target per application
- Step 3Test environment first
- Step 4Production, with monitoring from day one
Choose per application, not for the whole company. A typical result: the web applications and APIs on App Service, the nightly jobs in Container Apps, and one old application with a COM component on a virtual machine until it is rewritten.
Set up monitoring before the switch, not after the first complaint. How to do that is in our article on monitoring .NET applications with Application Insights, and Blazor-specific choices are in hosting Blazor on Azure.
How we work
This is exactly what we do. ProCoding is a .NET studio in Split, Croatia, and we move business applications to Azure: the inventory, the right target for each application, the move with a test environment first, and keeping an eye on both the application and the bill afterwards. The first step is a free 30-minute call.
Sources
- Choose an Azure compute service, Microsoft Learn
- OS and runtime patching in Azure App Service, Microsoft Learn
- Set scaling rules in Azure Container Apps, Microsoft Learn
This article is general information only, not legal, tax, financial or other professional advice. Scenarios, examples and calculations are illustrative. Terms of use and disclaimer.