Search for a command to run...
Complete guide for installing and configuring Azure Command Line Interface (CLI) across different operating systems.
The Azure Command Line Interface (Azure CLI) is a cross-platform command-line tool for managing Azure resources.
# Get packages needed for the installation process
sudo apt update
sudo apt install -y ca-certificates curl apt-transport-https lsb-release gnupg
# Download and install the Microsoft signing key
curl -sL https://packages.microsoft.com/keys/microsoft.asc | \
gpg --dearmor | \
sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null
# Add the Azure CLI software repository
AZ_REPO=$(lsb_release -cs)
echo "deb [arch=`dpkg --print-architecture`] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | \
sudo tee /etc/apt/sources.list.d/azure-cli.list
# Install Azure CLI
sudo apt update
sudo apt install -y azure-cli
# Verify installation
az --version
# Login to Azure
az login
# List subscriptions
az account list
# Set default subscription
az account set --subscription "My Subscription"
# Set default output format
az configure --defaults output=table
# Set default location
az configure --defaults location=westus2
# View current configuration
az configure --list-defaults
# Login with different account
az login --use-device-code
# Switch between accounts
az account set --subscription "Other Subscription"
# List accounts
az account list --output table
# Create resource group
az group create --name myResourceGroup --location westus2
# List resource groups
az group list --output table
# Delete resource group
az group delete --name myResourceGroup --yes
# Create VM
az vm create \
--resource-group myResourceGroup \
--name myVM \
--image UbuntuLTS \
--admin-username azureuser \
--generate-ssh-keys
# List VMs
az vm list --output table
# Start/Stop VM
az vm start --resource-group myResourceGroup --name myVM
az vm stop --resource-group myResourceGroup --name myVM
Resource Management
# Use resource groups for organization
az group create --name myApp-prod --location westus2 --tags Environment=Production
# Use tags for resource tracking
az resource tag --tags Environment=Production \
--resource-group myResourceGroup \
--name myResource \
--resource-type "Microsoft.Web/sites"
Security
# Use service principals for automation
az ad sp create-for-rbac --name myApp
# Manage role assignments
az role assignment create \
--assignee <principal-id> \
--role Contributor \
--resource-group myResourceGroup
Automation
# Create deployment from template
az deployment group create \
--resource-group myResourceGroup \
--template-file template.json \
--parameters parameters.json
// ~/.azure/config
{
"defaults": {
"group": "myResourceGroup",
"location": "westus2",
"vm": {
"image": "UbuntuLTS",
"size": "Standard_DS2_v2"
}
}
}
# Set environment variables
export AZURE_SUBSCRIPTION_ID="your-subscription-id"
export AZURE_TENANT_ID="your-tenant-id"
export AZURE_CLIENT_ID="your-client-id"
export AZURE_CLIENT_SECRET="your-client-secret"
# List available extensions
az extension list-available --output table
# Install extension
az extension add --name <extension-name>
# Update all extensions
az extension update --all
# Remove extension
az extension remove --name <extension-name>
Complete guide for installing and configuring Google Cloud Command Line Interface (gcloud CLI) across different operating systems.
A comprehensive guide for installing and configuring HashiCorp Terraform, an Infrastructure as Code (IaC) tool for building, changing, and versioning infrastructure safely and efficiently.