Azure Classroomnotes 24/Sep/2023

Azure CLI

  • Azure CLI interacts with azure from command line using credentials
  • To use azure command line, we have two ways
    • Azure CLI
    • Azure Powershell
  • Azure CLI installation: Refer Here
  • Common commands Refer Here
  • Azure CLI Cheatsheet Refer Here
  • Using Azure CLI Refer Here
  • Generic Syntax
az <service> [<sub-resouce>] <action> [--arg1 value1 .. --argn valuen]
  • Examples
az group create --name test --location eastus

Resource group from cli

  • Lets create a resource group called fromcli
  • Linux
az group create \
    --name 'fromcli' \
    --location 'centralindia' \
    --tags env=dev purpose=learning

Preview
* Windows

az group create `
    --name 'fromcli' `
    --location 'centralindia' `
    --tags env=dev purpose=learning
  • Lets get all the resource groups Refer Here
    Preview
  • Delete the resource group az group delete -n fromcli --yes
  • Check if fromcli resource group exists or not
az group exists --name fromcli

Create a cosmos db

  • Steps:
    • Create a resource group
    • Create a cosmos db account for mongo
    • list the cosmos db created and check if it exists
az group create --name fromcli --location centralindia
az cosmosdb create \
    --name qtcosmosacc \
    --resource-group fromcli \
    --kind mongodb

az cosmosdb mongodb database create \
    --account-name qtcosmosacc \
    --resource-group fromcli \
    --name students
az group delete --name fromcli --yes --no-wait
  • Powershell equivalent
az group create --name fromcli --location centralindia
az cosmosdb create ``
    --name qtcosmosacc `
    --resource-group fromcli `
    --kind mongodb

az cosmosdb mongodb database create `
    --account-name qtcosmosacc `
    --resource-group fromcli `
    --name students

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner