Did you know you can containerize your asp.net MVC with docker application and upload to Azure Container Registry and host them using Azure Kubernetes Cluster and start monitoring your container using Azure Monitor? In this article, I will explain all of this in this article. This article will help you to prepare for az-303: Microsoft Azure Architect Technologies.
Monitors the performance of containers deployed to several platforms. You can monitor below:
- Azure Kubernetes Service (AKS)
- Self-managed K8 cluster hosted on Azure using AKS Engine
- Azure Container Instances
- Self-managed K8 clusters hosted on Azure Stack or on-premises
- Azure Red Hat OpenShift
- Azure Arc enabled Kubernetes
Let’s create and deploy a docker container to AKS. Source code for azure app insight for docker container.
- First create MVC asp.net project select docker Linux support.
- Run project locally
- Package this app in container and deploy into container registry
- You can use Docker hub or Azure Container Registry
- Next I am going to use Azure Container Registry Service to create new container registry.
- Under repository of my container registry My MVC application docker image will appear.
- Visual Studio will package my app into a docker image and deploy to my azure docker container registry.
- Once my docker image any docker host like Azure Container Instances or Azure Kubernetes Service (AKS).
- Right click application and publish
- Select Docker Container Registry
- Next select azure container registry
- Select your resource group and azure container registry to publish then select publish. It will take some time to publish your image to Azure Container Registry.
The name “Kubernetes” stems from an ancient Greek word for “helmsman,” (someone who steers a ship, like a container ship) which explains the ship wheel logo.
Azure Container Registry has Docker Image and in order to connect to your own docker container image you will get container name and registry name that will help you to host your docker image to any Azure container hosting services.
Azure Kubernetes Cluster host the docker container and exposes the container into public 8080 port using in-built high performance load balancer.
- You need pod workflow from Kubernetes Cluster which will connect to the container registry using container name and registry name and create internal 80 port for your app.
- Next you need service to expose internal port 80 to public 8080 over load balancer.
While creating Kubernetes Cluster remember 3 things.
- Authentication method : required to connect Azure Container Registry to get the docker image.
- Integration : Which Container Registry to select your own Container Registry that is we created where we have our docker image.
- You can check the performance of your container by going to the Monitor Insights. Once our container will be deployed to the Kubernetes then we can observe performance.
Here is the YML for creating POD in k8 cluster.
apiVersion: v1 kind: Pod metadata: name: insights-demo01 # give any name labels: app: insights-demo01 # app name component: netcore-app spec: containers: # which container u want to deploy - image: regdemo01.azurecr.io/appcontainerinsightsdemo:latest # <NameOfTheContainerRegistry>/<NAMEofTheDockerContainer>:latest name: webapi ports: - containerPort: 80
YML for creating service in K8 cluster.
apiVersion: v1 kind: Service metadata: labels: app: insights-demo01 # give any name name: insights-demo01 # give any name spec: ports: - port: 8080 # public port protocol: TCP targetPort: 80 # internal port selector: app: insights-demo01 component: netcore-app type: LoadBalancer
Follow the video steps to create the Kubernetes Cluster including pod and service.
Thanks for reading my article till end. I hope you learned something special today. If you enjoyed this article then please share to your friends and if you have suggestions or thoughts to share with me then please write in the comment box.
- Please subscribe to All-Access Membership PRO plan to access current and future angular, node.js and related courses.
- Please subscribe to All-Access Membership ELITE plan to get everything from PRO plan. Additionally, you will get access to a monthly live Q&A video call with
Rupeshand you can ask doubts/questions and get more help, tips and tricks.
Your bright future is awaiting for you so visit today FullstackMaster and allow me to help you to board on your dream software company as a new Software Developer, Architect or Lead Engineer role.