Automate Azure Resources using Azure CLI

Steps:

  1. Download Azure cli using the below link

    https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-windows?tabs=azure-cli

  2. Open terminal and check for the version using the below command

    "az version"

    1. To connect azure cli downloaded in our machine with azure portal we need to run the below command

      az login

    2. It will ask to select the account to login

    3. select the account and you will see the below screen

      creating resources through Azure CLI

      1. Go the azure cli documentation and switch to the creating resources page

      2. https://learn.microsoft.com/en-us/cli/azure/reference-docs-index

      3. Go the create resource page

      4. https://learn.microsoft.com/en-us/cli/azure/manage-azure-groups-azure-cli

      5. Enter the command and execute accordingly

        az group create --name MyResourceGroup --location eastus

      6. Creating azure vm

        az vm create --resource-group rg1 --name vm1 --image Ubuntu2204 --vnet-name vnet1 --subnet sb1 --generate-ssh-keys --output json --verbose

      7. Check whether VM is created or not by logging into the azure portal

Delete the resource group to delete all the resources

        az group delete --name learn-azure-cli