Easily Deploy ASP.NET Core to Azure AKS for fast and scalable applications. Our Kubernetes Support team is ready to assist you.
Deploy ASP.NET Core to Azure AKS
Deploying ASP.NET Core applications allows developers to make their web apps accessible in a production environment. It involves preparing the application, setting up a hosting environment, and ensuring proper configuration, process management, and monitoring. This article includes a step-by-step guide to deploy ASP.NET Core apps to Azure AKS, from publishing and creating a cluster to defining Kubernetes resources and testing your application.
Deploy asp.net Core to Azure aks
Deploying ASP.NET Core apps makes your web application available in production. It includes publishing with dependencies, choosing a host like IIS, Nginx, cloud platforms, or Docker, and configuring settings, process management, and monitoring for reliable performance and secure user access.
Prerequisites
Before starting, make sure you have:
-
-
- A Windows machine (Windows Server 2016 or later, or Windows 10 or newer)
- Internet Information Services (IIS) 7
- Visual Studio 2022
- Folder structures:
- ASP.NET Core: C:\IISPublish\ZohoAPICore
- ASP.NET MVC 4: C:\IISPublish\ZohoNet4
- Proper ASP.NET permissions: Right-click C:\IISPublish, go to Security, click Edit, and give full control to the IUSR user
-
Step 1: Prepare Your Resources
-
-
- In Azure, create a resource group called hello-aks.
- Verify that the Azure Container Registry (ACR) has your ASP.NET Core Docker image published.
- To publish a Docker image, use this example command:
-
dotnet publish /t:PublishContainer -p ContainerImageTag=1.0.0 \
-p ContainerRegistry=helloaksacr.azurecr.io
Troubleshoot Kubernetes Immutable Field errors with ease.
Step 2: Establish an AKS Cluster
-
-
- Use the Azure CLI login to access it.
- To establish the AKS cluster, use:
-
az aks create --resource-group hello-aks --name hello-aks-cluster --node-count 1 \
--node-vm-size Standard_B2ls_v2 --attach-acr helloaksacr --generate-ssh-keys
This makes a cluster with one node and allows it to access your ACR’s photos.
Step 3: Define Kubernetes Resources
-
-
- Make an ASP.NET Core application deployment:
-
apiVersion: apps/v1
kind: Deployment
metadata:
name: helloaks-deployment
spec:
selector:
matchLabels:
app: helloaks-api
template:
metadata:
labels:
app: helloaks-api
spec:
containers:
- name: helloaks-api
image: helloaksacr.azurecr.io/helloaks-api:1.0.0
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 8080
To make your app publicly accessible, create a service:
apiVersion: v1
kind: Service
metadata:
name: helloaks-service
spec:
type: LoadBalancer
selector:
app: helloaks-api
ports:
- port: 80
targetPort: 8080
Quick fix for Kubernetes Timed Out Waiting for the Condition error.
Step 4: Deploy to AKS
-
-
- Connect to your cluster:
-
az aks get-credentials --resource-group hello-aks --name hello-aks-cluster
Apply your Kubernetes resources:
kubectl apply -f hello-aks.yaml
Check pod status:
kubectl get pods
Get the public IP address of the service:
kubectl get service
Step 5: Test Your ASP.NET Core App
-
-
- Access your app using the public IP:
-
GET http://PUBLIC-IP/weatherforecast
Example response:
[
{"date":"2024-02-09","temperatureC":2,"summary":"Cool","temperatureF":35},
{"date":"2024-02-10","temperatureC":-13,"summary":"Freezing","temperatureF":9},
{"date":"2024-02-11","temperatureC":6,"summary":"Sweltering","temperatureF":42},
{"date":"2024-02-12","temperatureC":38,"summary":"Warm","temperatureF":100},
{"date":"2024-02-13","temperatureC":36,"summary":"Bracing","temperatureF":96}
]
Kubernetes Session Affinity explained for smooth service delivery.
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
In conclusion, following these steps makes it easy to Deploy ASP.NET Core to Azure AKS efficiently. This approach ensures your application runs reliably in a scalable, cloud-native environment while providing secure access and smooth performance for end-users.
In brief, our Support Experts demonstrated how to fix the “554 5.7.1 : Relay access denied” error.
0 Comments