Date

AKS Lab: Azure Container Instance

Summary

In this Lab article we will create Azure Container Instance with Azure Container Registry Image. We will be using this same Azure Container Instance in Azure Kubernetes Cluster Scale

Prerequisites

Azure subscription for Azure Container Instance, Azure Container Registry and Azure CLI module for Windows

Azure Container Instance

  • ACI : Azure Container Instance is “Serverless Platform”, don’t need to provision any container hosting infrastructure to Azure
  • Cost: Pay/seconds billing model
  • Container Group duration: CPU (per vCPU-s)/Memory (per GB-s)
  • In Some regions : Extra cost for Windows Containers
  • Suitable only for quick deploy/destroy model. Not suitable for Production

Use Case:

  • Not recommended for ‘Production’
  •  Containers on Demand (Continuous integration build agent): Scale out to support multiple concurrent build
  • Short lived experiments
  • Batch jobs
  • Elastic scale for Kubernetes cluster : To handle bust in demand, or quick scale to manage extra workload
  • Virtual Kubelet: Allow Kubernetes to treat Azure Container instances as a Virtual Node in K8s Cluster

Creating Azure Container Instance

Sample:

PS C:\> az container create `
-n Portfolio `
--image <Docker Image-Name | ACR> `
--ip-address public `
--port 80 `
--os-type Windows ` # Default: Linux 
--cpu 2 --memory 2 `   # CPU: vCPU | Memory : GB
--restart-policy never ` # always, onfailure 
--azure-file-volume  # Credential, mount path, share- name

Step by Step process

1. Create new group for Azure Container group

 az group create -n azContainer -l eastus 

2. Save Password and Username for Azure Repository into a variable

List Container Image in the ACR repository

 az acr repository list -n "acrRepository" -o table 

Result

———

Portfolio

Verify credentials for ACR repository

 az acr credential show -n acrRepository 

{
  "passwords": [
    {
      "name": "password",
      "value": "BwfBmC+rExxxxxxxxxxxxxxxxxEArWW"
    },
    {
      "name": "password2",
      "value": "zLLU7ExxxxxxxxxxxxxxxxxxxxcyUBG"
    }
  ],
  "username": "Profile"

Save ACR repository Username and Password into a variable and verify

 $acrPassword = az acr credential show -n acrRepository --query "passwords[0].value" -o tsv 

 $acrPassword 

BwfBmC+rExxxxxxxxxxxxxxxxxEArWW

 $acrUsername = "Profile"

 $acrUsername 

Profile

3. Create Azure Container

 az container create -g azContainer `  

 >> -n portfolio ` 

 >> --image  acrrepository.azurecr.io/portfolio:latest `  

 >> --registry-username $acrUsername `  

 >> --registry-password $acrPassword `   

 >> --dns-name-label " portfolio" --port 80 ` 

 >> --os-type Windows ` 

 >> --cpu 2 --memory 2  

Sample Output

{

 "containers": [
	{
	  "command": null,
	  "environmentVariables": [],
	  "image": "acrrepository.azurecr.io/poerfolio:latest",
. 
.
.
.
.
.
.

"dnsNameLabel": "portfolio",		

"fqdn": "portfolio.eastus.azurecontainer.io",

   

4. Open Web-Browser and use FQDN: “portfolio.eastus.azurecontainer.io” to access website running inside Azure Container

IMAGE: IIS website running inside Azure Container

Additional Information

1. Check Container logs

 az container logs -n portfolio -g azContainer 

2. Delete Azure Container Group

 az group delete -g azContainer -y 

3. Access Powershell inside Container :

 az container exec -n portfolio -g azContainer --exec-command powershell 

AZmachina

Knowledge Shared = Knowledge2

We have created AZmachina blog to share our knowledge on Docker & Container and Kubernetes on Windows Servers with curious and enthusiastic novice learner. We hope that this will help them to take a swim in this vast ocean of Window Containers and Kubernetes

Happy Learning !
Recent Posts
Categories
Archives
Sumeet Kumar

Sumeet Kumar

I am Windows Core Engineer with 7+ years of experience in Windows Hyper-v, Failover Cluster, Windows Storage, Volume Shadow Copy (VSS), Docker & Containers on Windows Servers, Backup & Recovery, VMware vSphere EXSi & vCenter Server

RELATED

Articles

Leave a Reply

Your email address will not be published. Required fields are marked *