Azure Classroomnotes 21/May/2022

Azure CLI

  • Installing Azure CLI Refer Here
  • Azure CLI and Azure Powershell can be executed from azure cloud shell
    Preview
    Preview
    Preview
  • azure cli commands usage is simple Refer Here
    Preview
az <service> <command> [<arguments>]
  • Setup for working with Azure CLI, Lets configure Visual Studio Code, Ensure Azure CLI tools extension is installed
  • Any cli command will give the response in json format.
  • Lets create a resource group. Refer Here
    Preview
az group create --location 'eastus' --name 'fromcli'

Preview
* For querying the outputs azure cli supports jmes path Refer Here
* Now delete the resource group

az group delete --name 'fromcli'
  • Lets search for a vm image.
  • First lets search publishers
az vm image list-publishers --query "[*].name"
  • Lets pick Canonical and lets find offers
az vm image list-offers --publisher "Canonical" --location "eastus" --query "[*].name"
  • Lets pick sku
az vm image list-skus --location "eastus"  --offer "UbuntuServer" --publisher "Canonical"
  • Use the following cli
az vm image list-skus --location "eastus"  --offer "0001-com-ubuntu-server-focal" --publisher "Canonical" --query "[*].name"
[
  "20_04-lts",
  "20_04-lts-gen2"
]
  • The following azure cli will create a linux and windows vm in a resource group
# create a resource group
az group create --location 'southindia' --name 'fromcli2'

az vm create --resource-group 'fromcli2' --name 'myubuntuvm' `
    --image "Canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:20.04.202004230" `
    --admin-username 'qtdevops' `
    --admin-password 'motherindia@123' --size 'Standard_DS1'`
    --public-ip-sku Standard

az vm create --resource-group 'fromcli2' --name 'mywindowsserver' `
    --image "Win2019Datacenter" `
    --admin-username 'qtdevops' `
    --admin-password 'motherindia@123' --size 'Standard_DS1' `
    --public-ip-sku Standard

Preview
Preview

  • Exercise:
    • Create a Redhat 8 linux/Centos 8 vm from azure cli in the free tier
    • Find the public ip address of the vm from cli

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner