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:
- Cross-Platform: Available on Windows, macOS, and Linux.
- Scriptable: Can be used in scripts to automate Azure resource management.
- Interactive: Supports an interactive mode that helps users discover and execute commands.
- Resource Management: Allows for the creation, deletion, updating, and querying of Azure resources.
Benefits of Using Azure CLI
- Efficiency: Quick and efficient management of Azure resources.
- Automation: Enables automation of routine tasks, reducing manual effort.
- Consistency: Provides a consistent interface for managing resources across different platforms.
- Integration: Easily integrates with CI/CD pipelines and other automation tools.
- 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