1. How do you deploy ASP.NET Core to an Azure VM/IIS?
We can deploy an ASP.NET Core application to an Azure Windows Virtual Machine (VM) using IIS and Azure Pipelines.
How does it work?
-
Create Azure VM: Create a Windows Server VM in Azure.
-
Install IIS: Enable IIS and install the ASP.NET Core Hosting Bundle.
-
Configure IIS: Create a website, configure its application pool (
No Managed Code), and set up HTTPS. -
Install Azure DevOps Agent: Install a self-hosted agent on the VM and register it with Azure DevOps.
-
Build Application: Azure Pipeline builds and publishes the ASP.NET Core application.
-
Deploy: Deployment pipeline copies the published files to the IIS website folder.
-
Restart and Verify: Restart or recycle the application as needed and verify it works.
Deployment Flow
Developer
↓
Git Repository
↓
Azure CI Pipeline
↓
dotnet restore
↓
dotnet build
↓
dotnet test
↓
dotnet publish
↓
Build Artifact
↓
Azure CD Pipeline
↓
Azure Windows VM
↓
IIS Website Folder
↓
ASP.NET Core Application
↓
Health Check
Example
Publish the ASP.NET Core application:
dotnet publish -c Release -o ./publish
Example IIS deployment folder:
C:\inetpub\wwwroot\MyApplication
The deployment pipeline copies the published files into this folder.
Important: For a real Production deployment, use a safe deployment procedure to avoid locked files, preserve configuration, and minimize downtime. A self-hosted agent is one approach; remote deployment is also possible.
Interview Answer
We deploy ASP.NET Core applications to Azure Windows VMs using IIS and Azure Pipelines. The CI pipeline builds and publishes the application, while the CD pipeline copies the artifact to the IIS website folder. Finally, we verify the application using health checks.
2. How do deployments differ for App Service, Container Apps, and AKS?
All three Azure services can host ASP.NET Core applications, but their deployment methods are different.
Simple Comparison
|
Feature |
Azure App Service |
Azure Container Apps |
Azure AKS |
|---|---|---|---|
|
Hosting |
Managed web hosting |
Managed container hosting |
Managed Kubernetes |
|
Deployment |
Publish application or container |
Deploy container image |
Deploy Kubernetes resources |
|
Docker required? |
No |
Yes |
Yes |
|
Kubernetes knowledge |
No |
No |
Yes |
|
Scaling |
Built-in scaling |
Container-based autoscaling |
Kubernetes-based scaling |
|
Complexity |
Low |
Medium |
High |
|
Best suited for |
Web APIs and websites |
Containerized APIs and microservices |
Complex microservices systems |
A. Azure App Service Deployment
Developer
↓
Git Repository
↓
Azure Pipeline
↓
dotnet publish
↓
Build Artifact
↓
Deploy to Azure App Service
↓
Application Running
Key Point: We can deploy ASP.NET Core directly without creating a Docker image.
B. Azure Container Apps Deployment
Developer
↓
Git Repository
↓
Azure Pipeline
↓
Build Docker Image
↓
Push Image to Azure Container Registry
↓
Deploy Image to Azure Container Apps
↓
Container Running
Key Point: Azure Container Apps runs Docker-compatible container images and automatically manages much of the underlying infrastructure.
C. Azure Kubernetes Service (AKS) Deployment
Developer
↓
Git Repository
↓
Azure Pipeline
↓
Build Docker Image
↓
Push Image to Azure Container Registry
↓
Deploy using Kubernetes YAML / Helm
↓
AKS Cluster
↓
Kubernetes Pods
↓
Application Running
Key Point: AKS provides more control over container orchestration, networking, scaling, and deployments, but requires Kubernetes knowledge.
Interview Answer
Azure App Service allows us to deploy ASP.NET Core applications directly without Docker.
Azure Container Apps requires container images and provides managed container hosting with automatic scaling.
AKS also uses container images, but deployments are managed through Kubernetes resources such as Deployments, Services, and Pods.
Remember:
-
App Service: Deploy application files.
-
Container Apps: Deploy container images.
-
AKS: Deploy container images using Kubernetes.