Azure Portal & CLI Basics
Navigating and Managing Azure Resources
Table of Contents
- Azure Portal Overview
- Portal Navigation & Features
- Azure CLI Installation
- CLI Basic Commands
- Azure PowerShell
- Best Practices
1. Azure Portal Overview
The Azure Portal (portal.azure.com) is a web-based, unified console that provides access to all your Azure resources. It's designed for both beginners and experienced users.
Portal Interface Layout:
┌─────────────────────────────────────────────────────────────────────────┐
│ Microsoft Azure [Search] [?] [⚙️] │
├─────────────────────────────────────────────────────────────────────────┤
│ ← → ↻ │ All services │ Resource groups │ Create a resource │ [Bell] │
├────────┴────────────────────────────────────────────────────────────────┤
│ │
│ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ │
│ │ Dashboard │ │ Cost │ │ Help & │ │
│ │ Management │ │ Management │ │ Support │ │
│ └────────────────┘ └────────────────┘ └────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────────────────┐ │
│ │ Resources │ │
│ │ + New ↺ Refresh ≡ Filter 🔍 Search all resources │ │
│ ├──────────────────────────────────────────────────────────────────┤ │
│ │ Name │ Type │ Location │ Resource Group │ │
│ │ ───────────── │ ────────── │ ───────── │ ────────────────── │ │
│ │ myVM │ Virtual │ East US │ myResourceGroup │ │
│ │ mystorage001 │ Storage │ West US │ myResourceGroup │ │
│ └──────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
Key Portal Features:
- Global Search - Find any resource, service, or documentation
- Dashboard - Customizable overview of your resources
- Resource Explorer - View and manage all resources
- Notifications - Alerts and important messages
- Cloud Shell - Integrated terminal for CLI commands
- Cost Analysis - Track spending and budgets
2. Portal Navigation & Features
Creating Your First Resource:
Step-by-Step:
- Click "Create a resource" in the left navigation
- Browse or search for the resource type (e.g., "Virtual Machine")
- Select the resource from marketplace
- Fill in required fields:
- Subscription
- Resource Group (create new or select existing)
- Instance name
- Region
- Size (VM size, tier, etc.)
- Configure optional settings (networking, storage, etc.)
- Review and create
- Wait for deployment to complete
Essential Portal Views:
Resource Groups View:
Resource Groups
├── Production-RG
│ ├── VM-Production-01
│ ├── SQL-Database-Prod
│ └── Storage-Prod
├── Development-RG
│ ├── VM-Dev-01
│ └── Storage-Dev
└── Staging-RG
├── VM-Staging-01
└── SQL-Staging
All Resources View:
- Filter by type, subscription, tag
- Sort by name, date, type
- Bulk operations (delete, move, tag)
Using Cloud Shell:
Azure Cloud Shell is a browser-based terminal for managing Azure resources.
Access: Click the >_ icon in the portal toolbar
Features:
- Pre-installed Azure CLI
- PowerShell support
- File storage (persistent $HOME)
- Git integration
- Docker, kubectl, and more
Storage for Cloud Shell:
- Requires an Azure Storage account
- Creates a file share in Cloud Shell container
3. Azure CLI Installation
The Azure Command-Line Interface (CLI) is a cross-platform tool for managing Azure resources.
Installation on macOS:
# Using Homebrew
brew update
brew install azure-cli
# Verify installation
az --version
Installation on Windows:
Option 1: MSI Installer
- Download from: https://aka.ms/installazurecliwindows
- Run the installer and follow prompts
Option 2: Winget
winget install Microsoft.Azure.CLI
Installation on Linux (Ubuntu/Debian):
# Add Microsoft repository
curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /tmp/microsoft.gpg
sudo mv /tmp.microsoft.gpg /etc/apt/trusted.gpg.d/
echo "deb [arch=amd64] https://packages.microsoft.com/ubuntu/$(lsb_release -rs)/main main" | sudo tee /etc/apt/sources.list.d/azure-cli.list
# Install Azure CLI
sudo apt update
sudo apt install azure-cli
Installation using pip:
# Install via pip
pip install azure-cli
# Or specific version
pip install azure-cli==2.50.0
4. CLI Basic Commands
Authentication & Setup:
# Login to Azure
az login
# Login with specific tenant
az login --tenant <tenant-id>
# Login with service principal
az login --service-principal -u <app-id> -p <password> --tenant <tenant-id>
# Logout
az logout
# Show current account
az account show
# List all subscriptions
az account list -o table
Resource Group Operations:
# Create a resource group
az group create --name myResourceGroup --location eastus
# List resource groups
az group list -o table
# Show resource group details
az group show --name myResourceGroup
# Delete resource group
az group delete --name myResourceGroup --yes --no-wait
# Update resource group tags
az group update --name myResourceGroup --set tags.Environment=Dev
Virtual Machine Operations:
# Create a VM (basic)
az vm create \
--resource-group myResourceGroup \
--name myVM \
--image UbuntuLTS \
--admin-username azureuser \
--generate-ssh-keys
# Create VM with custom size
az vm create \
--resource-group myResourceGroup \
--name myVM \
--image UbuntuLTS \
--size Standard_D2s_v3
# List VMs in resource group
az vm list --resource-group myResourceGroup -o table
# Start a VM
az vm start --resource-group myResourceGroup --name myVM
# Stop a VM
az vm stop --resource-group myResourceGroup --name myVM
# Restart a VM
az vm restart --resource-group myResourceGroup --name myVM
# Get VM details
az vm show --resource-group myResourceGroup --name myVM
# Delete a VM
az vm delete --resource-group myResourceGroup --name myVM --yes
Storage Account Operations:
# Create storage account
az storage account create \
--name mystorageaccount \
--resource-group myResourceGroup \
--location eastus \
--sku Standard_LRS
# List storage accounts
az storage account list -o table
# Get storage account connection string
az storage account show-connection-string \
--name mystorageaccount \
--resource-group myResourceGroup
# Delete storage account
az storage account delete --name mystorageaccount --resource-group myResourceGroup
Using Query and Output:
# JSON output (default)
az vm list
# Table output
az vm list -o table
# List with query
az vm list --query "[].{Name:name, State:powerState}" -o table
# Filter results
az vm list --query "[?powerState=='Running']"
Getting Help:
# General help
az --help
# Command-specific help
az vm --help
# Subcommand help
az vm create --help
# Examples
az vm create --help --examples
5. Azure PowerShell
Azure PowerShell provides cmdlets for managing Azure resources.
Installation:
# Install Az module (PowerShell 7+)
Install-Module -Name Az -AllowClobber -Scope CurrentUser
# Or install Az for Windows PowerShell
Install-Module -Name Az -AllowClobber -Scope AllUsers
Authentication:
# Connect to Azure
Connect-AzAccount
# Connect to specific tenant
Connect-AzAccount -Tenant <tenant-id>
# Connect with subscription
Connect-AzAccount -SubscriptionId <subscription-id>
Common Cmdlets:
# Resource Group operations
New-AzResourceGroup -Name "myResourceGroup" -Location "eastus"
Get-AzResourceGroup
Remove-AzResourceGroup -Name "myResourceGroup" -Force
# VM operations
New-AzVM -ResourceGroupName "myResourceGroup" -Name "myVM" -Image UbuntuLTS
Get-AzVM
Start-AzVM -ResourceGroupName "myResourceGroup" -Name "myVM"
Stop-AzVM -ResourceGroupName "myResourceGroup" -Name "myVM"
# Storage operations
New-AzStorageAccount -ResourceGroupName "myResourceGroup" -Name "mystorage" -SkuName Standard_LRS
6. Best Practices
CLI Best Practices:
- Use descriptive names - Makes resources easier to identify
- Tag resources - Organize and track costs
- Use resource groups - Group related resources
- Script everything - Enable reproducibility
- Use --what-if - Preview changes before applying
Example Script - Deploy Complete Environment:
#!/bin/bash
# Deploy complete development environment
RG_NAME="DevEnvironment"
LOCATION="eastus"
# Create resource group
echo "Creating resource group..."
az group create --name $RG_NAME --location $LOCATION
# Create virtual network
echo "Creating virtual network..."
az network vnet create \
--resource-group $RG_NAME \
--name dev-vnet \
--address-prefixes 10.0.0.0/16 \
--subnet-name default \
--subnet-prefixes 10.0.0.0/24
# Create storage account
echo "Creating storage account..."
az storage account create \
--resource-group $RG_NAME \
--name devstor$(date +%s) \
--sku Standard_LRS \
--location $LOCATION
# Create VM
echo "Creating virtual machine..."
az vm create \
--resource-group $RG_NAME \
--name dev-vm \
--image UbuntuLTS \
--size Standard_B1s \
--admin-username devuser \
--generate-ssh-keys
echo "Deployment complete!"
Secure Practices:
- Never store credentials in scripts - Use Key Vault or managed identities
- Use service principals - For automation
- Enable MFA - For user accounts
- Use least privilege - Grant minimal required permissions
- Rotate secrets regularly - Implement secret rotation
Quick Reference - Common CLI Commands:
┌─────────────────────────────────────────────────────────────────┐
│ AZURE CLI CHEAT SHEET │
├─────────────────────────────────────────────────────────────────┤
│ Login: az login │
│ Show account: az account show │
│ List subs: az account list │
│ Create RG: az group create -n <name> -l <location> │
│ List RG: az group list │
│ Create VM: az vm create -g <rg> -n <name> --image <img> │
│ List VM: az vm list -g <rg> │
│ Start VM: az vm start -g <rg> -n <name> │
│ Stop VM: az vm stop -g <rg> -n <name> │
│ Delete VM: az vm delete -g <rg> -n <name> --yes │
│ Create SA: az storage account create -n <name> -g <rg> │
│ Get SA keys: az storage account keys list -n <name> -g <rg> │
│ Help: az <command> --help │
└─────────────────────────────────────────────────────────────────┘
Practice Exercises:
- Exercise 1: Create a resource group and a storage account using CLI
- Exercise 2: Create a Linux VM, SSH into it, then delete it
- Exercise 3: Write a script that creates a complete environment
- Exercise 4: Use Cloud Shell to manage resources
- Exercise 5: Export your resource configuration using CLI
Next Steps:
- Explore Azure Resource Manager templates
- Learn about Azure Policy and governance
- Practice with Azure DevOps pipelines
Azure Integration Hub - Learning Roadmap Level: Beginner | Topic: Azure Portal & CLI Basics