Azure PowerShell Quickstarts

Login to Azure

Authenticate with your Azure subscription using the Connect-AzAccount cmdlet.

Connect-AzAccount
# Follow the browser prompt to sign in.

Create a Virtual Machine

Quickly provision a Windows Server VM with a single command.

New-AzVm `
  -ResourceGroupName "DemoRG" `
  -Name "DemoVM" `
  -Location "EastUS" `
  -Image "Win2019Datacenter" `
  -Size "Standard_DS1_v2" `
  -Credential (Get-Credential)

Manage Resource Groups

Create, list, and delete resource groups.

# Create
New-AzResourceGroup -Name "DemoRG" -Location "EastUS"

# List
Get-AzResourceGroup

# Delete
Remove-AzResourceGroup -Name "DemoRG" -Force

Deploy a Web App

Deploy an ASP.NET Core app to Azure App Service.

az webapp create `
  --resource-group DemoRG `
  --plan DemoPlan `
  --name DemoWebApp `
  --runtime "DOTNETCORE|6.0"

Setup Azure Kubernetes Service (AKS)

Provision a managed Kubernetes cluster.

az aks create `
  --resource-group DemoRG `
  --name DemoAKS `
  --node-count 3 `
  --generate-ssh-keys
az aks get-credentials --resource-group DemoRG --name DemoAKS

Configure Storage Accounts

Create a storage account and a container.

# Create storage account
az storage account create `
  --name demostorage123 `
  --resource-group DemoRG `
  --location eastus `
  --sku Standard_LRS

# Create container
az storage container create `
  --account-name demostorage123 `
  --name mycontainer

Configure Monitoring & Alerts

Set up a basic metric alert for CPU usage.

az monitor metrics alert create `
  --resource-group DemoRG `
  --name HighCpuAlert `
  --scopes /subscriptions//resourceGroups/DemoRG/providers/Microsoft.Compute/virtualMachines/DemoVM `
  --condition "max CPU > 80" `
  --description "Alert when CPU > 80%" `
  --action-group