,

Azure Fundamental – Azure CLI -Command Line Interface (Part-9)

Posted by

Azure CLI

Azure Command-Line Interface (CLI) is a set of commands used to create and manage Azure resources. It is designed for those who prefer to manage Azure resources through a command-line interface rather than through the Azure Portal.

Key Features:

  1. Cross-Platform: Available on Windows, macOS, and Linux.
  2. Scriptable: Can be used in scripts to automate Azure resource management.
  3. Interactive: Supports an interactive mode that helps users discover and execute commands.
  4. Resource Management: Allows for the creation, deletion, updating, and querying of Azure resources.

Benefits of Using Azure CLI

  1. Efficiency: Quick and efficient management of Azure resources.
  2. Automation: Enables automation of routine tasks, reducing manual effort.
  3. Consistency: Provides a consistent interface for managing resources across different platforms.
  4. Integration: Easily integrates with CI/CD pipelines and other automation tools.
  5. Accessibility: Accessible from any command-line interface, providing flexibility and convenience.

Install Azure CLI

Installation Overview

https://learn.microsoft.com/en-us/cli/azure/install-azure-cli

Install on Windows

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

Install on Linux

https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt

Install on Mac

https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-macos

Some Examples:

To Login

az login
or 
az login tenant_id

To Check AZ version

az version

Create VM using Azure CLI

Start with creating a Resource Group

az group create --name learn-azure-cli --location eastus

Set the Resource Group as default (Optional)

az config set defaults.group=learn-azure-cli

Create VM with Vnet

# Create PowerShell variable
$vmName = "TutorialVM1"

az vm create `
    --resource-group $resourceGroup `
    --name $vmName `
    --image Ubuntu2204 `
    --vnet-name $vnetName `
    --subnet $subnetName `
    --generate-ssh-keys `
    --output json `
    --verbose

Delete the Resource Group to delete all the resources

az group delete --name learn-azure-cli
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x