Title: Deploying compute workloads by using images and containers
Introduction: All my articles are compiled into simple steps with detailed screen shots and elaborative description. By following these steps even, a novice programmer should be able to replicate scenario. Please go through the steps and provide your valuable feedback to make my next articles more clearer and intent.
This is my 13th article on Azure.
Please follow below links for my previous Azure articles
Azure Key Vault With Logic App
Azure Key Vault With Data Factory
Accessing Azure Blob Containers
Follow below mentioned 19 steps to create and deploy resources using images and containers
After completing this blog, you will be able to do
- Learn various commands to deal with azure resources
- Deploying work loads by using images and containers
Sample Description: We will create virtual machine, Container registry and deploy workloads.
Step 1: Open Azure portal (https://portal.azure.com)
Step 2: Click on arrow mark on top of portal page to launch command line tool in azure.
Step 3 : Create resource group by using az group command
az group create -l westus -n WorkLoadGroups
Step 4: Create a virtual machine by using below command. We are going to create Linux VM.
Az vm create –resource-group WorkLoadGroups –name VMSri –image debian –admin-username usersri –admin-password Testingtool@1234
Step 5: By using below command create a new variable and read ipaddress of the newly create vm
myVMIp=$(az vm list-ip-addresses –resource-group WorkLoadGroups –name VMSri –query ‘[].{ip:virtualMachine.network.publicIpAddresses[0].ipAddress}’ –output tsv)
Step 6: Use below SSH command to connect to VM. It ask for login confirmation- anser yes. Then it will prompt for password. Provide the password. Finally it will connect you to virtual machine by using command line
Ssh usersri@$myVMIp
Step 7: In next steps we will we will create a console application using commands.
First create folder by using below command
Mkdir matetilabs
Then create another folder ipcheck using mkdir ipcheck
Navigate to ipcheck folder.
Step 8: Create new console application using below command
dotnet new console –output . –name ipcheck
Step 9: Add new file to newly created console app by using below command
Touch Dockerfile
Step 10 : Now click on open editor icon in command prompt to launch editor in azure. Navigate to the project you create earlier.
Step 11: Open Program.cs file and update the logic. Snap shot looks like below
Step 12: Open Docker file and update the content as shown below
Step 13: Now go back to azure portal and create a new azure container registry as shown below
Step 14: Access the container created in above step. Go to repositories tab and look for the resources, it will be empty
Step 15: In next steps we are going to deploy application in the repository.
Use below command to read the name of the registry we created
az acr list –query “max_by([], &creationDate).name” –output tsv
Step 16: By using below command save name of the repository to command variable
acrName=$(az acr list –query “max_by([], &creationDate).name” –output tsv)
Step 17: Navigate to the application we created earlier. Then use below command to deploy application in to the registry we created.
az acr build –registry $acrName –image ipcheck:latest .
And application deployed successfully to registry.
Step 18: Now go back to registry and refresh the repositories. You will see ipcheck got deployed there.
Step 19: Click on ipcheck and latest, you will see below json get generated from application.
Just now we have seen how to deploy resources in to containers using images.
Happy coding!!!
2 thoughts on “Deploying compute workloads by using images and containers”