Azure
Deploy And Run .NET Core 7 Internet API On Azure Kubernetes Service (AKS)
We’ll be taught concerning the Containerization of .NET Core Internet API utilizing Docker after which deploy it on Azure Container Registry and run that picture into Azure Kubernetes Service (AKS).
Agenda
- Overview
- Implementation of .NET Core Internet API
- Dockerization of utility
- Deploy utility picture on Azure Container Registry
- Run utility picture inside Azure Kubernetes Service (AKS)
Stipulations
- Visual Studio 2022
- Docker Desktop
- .NET Core 7 SDK and Runtime
- Azure Portal Subscription
Overview
Within the software program world, all of us need to automate issues and scale back guide work associated to the deployment and administration of various utility parts, in that case, azure supplies many providers for that like azure container registry and container occasion as I’ve proven under diagram.
- Azure container registry shops personal docker photographs and manages the identical.
- Azure container occasion is a managed service that helps us to run a container straight on the azure cloud with out requiring every other infrastructure like a digital machine (VM) and like that.
- Additionally, it helps to automate our utility deployment through the use of CI/CD instruments during which we configure some automation steps which construct and deploy our utility docker picture contained in the container registry and after that, we are able to simply run that picture contained in the azure container occasion in an remoted surroundings very effectively.
- Azure Kubernetes Service (AKS) is an open-source and totally managed container orchestration service out there on the Azure public cloud and used to deploy and handle completely different container photographs.
- AKS has provisioning to auto-scale sources with none downtime as per the requirement.
Implementation of .NET Core Internet API
Step 1
Create a brand new .NET Core 7 Internet API
Step 2
Configure your utility
Step 3
Present further data
Step 4
Add docker assist inside the applying utilizing Visual Studio
Step 5
Run the applying utilizing the docker (Be aware: Make certain Docker Desktop is put in and operating in your machine)
Deploy utility picture on Azure Container Registry
Step 1
Login on Azure Portal
Step 2
Create Useful resource Group
Step 3
After that, Create a brand new Azure Container Registry
Step 4
Subsequent, right-click on the applying resolution and click on on publish
Step 5
Click on on Docker Container Registry and press Subsequent
Step 6
Choose Azure Container Registry and Click on Subsequent
Step 7
After that, choose the subscription and container registry which we created earlier and click on on end.
Step 8
Subsequent, click on on Publish and it’ll add a docker picture on the azure container registry.
Step 9
Right here you’ll be able to see utility picture particulars contained in the repository part of our container registry on the Azure portal.
Run utility picture inside Azure Container Occasion
Step 1
Crete the AKS Service on Azure
Subsequent, configure container registry which we created earlier
Step 2
Open AKS and there we are able to discover particulars about AKS
Step 3
Click on on join button and the credentials will get populated
Right here you’ll be able to see two instructions, that you could execute in your native CMD however for that, you want Azure CLI as a result of with out that AZ command won’t work. So, obtain Azure CLI from the next URL
https://be taught.microsoft.com/en-us/cli/azure/install-azure-cli-windows?tabs=azure-cli
Step 4
Open CMD and enter the az login command it is going to open a window contained in the browser and you could present Azure credentials
az login
Additionally, enter the 2 aks instructions after login as I confirmed within the above picture.
Step 5
Create a pod.yml file and apply
apiVersion: v1
type: Pod
metadata:
identify: weather-forecast-app
labels:
app: weatherforecast-aks
part: weatherforecast-app
spec:
containers:
- picture: jdleaningregistry.azurecr.io/weatherforecastapplication:newest
identify: weatherforecast-webapi
ports:
- containerPort: 80
Step 6
Subsequent, create a service.yml file and apply
apiVersion: v1
type: Service
metadata:
labels:
app: weatherforecast-aks
identify: weatherforecast-aks
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 80
selector:
app: weatherforecast-aks
part: weatherforecast-app
kind: LoadBalancer
Step 7
You possibly can see the standing and particulars about pods and providers utilizing a number of instructions as I confirmed under
Step 8
In order for you extra particulars associated to pods and providers then execute describe instructions associated to Kubernetes
kubectl describe pod <podname>
kubectl describe svc <service identify>
Step 9
Open the AKS on Azure and click on on Companies and ingresses inside that we are able to see climate forecast particulars like exterior IP addresses and ports.
Step 10
Lastly, hit the general public IP URL to fetch knowledge
http://20.204.233.158:8080/weatherforecast
Conclusion
Right here we focus on the Containerization of purposes utilizing Azure container registry and occasion. Additionally, the step-by-step like the best way to create the useful resource and run it on Azure.
Comfortable Studying!