Forum Discussion
How to recover VM (node) by using azure cli
To recover an Azure VM (node) using Azure CLI from macOS to a Linux VM, try these steps.
1. Install Azure CLI (if not installed)
brew install azure-cli
2. Login to Azure
az login
3. Check VM Status
az vm show --resource-group <ResourceGroup> --name <VMName> --query "powerState" -o tsv
4. Restart VM (if needed)
az vm restart --resource-group <ResourceGroup> --name <VMName>
5. Start VM (if stopped)
az vm start --resource-group <ResourceGroup> --name <VMName>
6. Restore VM from Snapshot (if needed)
Find the snapshot:
az snapshot list --resource-group <ResourceGroup> --output table
Create a new disk from the snapshot:
az disk create --resource-group <ResourceGroup> --name <NewDiskName> --source <SnapshotName>
Attach the new disk to the VM:
az vm disk attach --resource-group <ResourceGroup> --vm-name <VMName> --name <NewDiskName>
7. Connect via SSH
ssh <username>@<vm-ip>
If your VM is still down, check logs:
az vm get-instance-view --resource-group <ResourceGroup> --name <VMName> --output json
I hope it helps you