Introduction
Nowadays, all developers are moving towards cutting edge technologies like Cloud computing, Containerization, Azure Container Registry, orchestration of an application/microservices, etc. Today we will discuss the below two major processes and data points in all these technologies.
- Build a .NET Core project’s Docker image build and pulling to Azure Container Registry- ACR
- Steps for deploying an application to K8S (Kubernetes) using the KubeController command - kubectl in Azure CLI
Prerequisites
- Docker for desktop installed on a machine
- Azure CLI installed on a machine
- Azure Resource Group in Azure account
Build a Docker image
- Create any .NET core project in Visual Studio 2017/2019 with a containerization option which will create a docker file in it.
- After creating it, build a project.
- Open command a prompt and check whether KubeCLI installed proper or not by using below steps
- Window + Run
- Write cmd in Run
- Write a kubectl and press Enter - which will give a detail that whether KuberController running or not
- Now do Azure login on CLI using below command
- az login
- Now time to check to get access on Azure account, before that we have to list out all Azure account by below command
Which will give a list of subscriptions in table format. In this table, the default access value - True/False, will represent that on which subscription users have access.- az account list --output table
- This subscription can be changed by a user with the below command.
- Syntax - az account set --subscription "<NameOfSubscription>"
- E.g. - az account set --subscription DemoSubscription
- Now set the project folder on the command prompt where a project is located
- Syntax - cd <Project Folder path>
- E.g. - cd D:\DemoProject
- So, now time to build an image of project Docker file and pull it to the ACR using below command
Here in the above command developers have to take care at the time of the given path of the file. If the developer already on prompt of project folder in which "Docker" file located then used below command. Whereas Docker file is located in D:\Project folder- Syntax - az acr build --registry <ACrName From Azure> --image <imageName> --file <DockerFileLocationInProjectFolder> .
- E.g. - az acr build --registry DemoACR --image test:v1 --file .\Project\Dockerfile .
If user command prompt folder is 1-2 folder out then he/she must be reached to that folder in which Docker file is located and give above command- az acr build --registry DemoACR --image test:v1 --file .\Dockerfile .
Join the conversation! Your thoughts help the community grow.