An Azure service that is used to provision Windows and Linux virtual machines.
If the VM is still not accessible, verify the actual power state first, then use the next recovery actions based on that result.
- Check the VM power state in Azure CLI:
az vm get-instance-view \
--name <vm-name> \
--resource-group <resource-group> \
--query instanceView.statuses[1] --output table
Expected result:
-
VM runningmeans the guest OS has started from the hypervisor perspective. -
VM stoppedstill incurs compute charges. -
VM deallocateddoes not incur compute charges and cannot accept connections.
- If the VM is
DeallocatedorStopped, start it:
az vm start -g <resource-group> -n <vm-name>
Then wait 1–2 minutes and check the power state again. Azure Bastion guidance requires the VM to be in the Running power state before it can accept connections.
- If the VM shows
Runningbut SSH still fails, restart the VM to clear underlying compute issues:
az vm restart --resource-group <resource-group> --name <vm-name>
Portal path:
- VM > Restart
- If restart does not help, redeploy the VM to a new Azure host:
az vm redeploy --resource-group <resource-group> --name <vm-name>
Portal path:
- VM > Help > Redeploy
Warning:
- Redeploy can cause loss of ephemeral disk data.
- Dynamic public IP addresses associated with the VM are updated.
- If the VM is stuck in
Failedstate in the portal, run reapply:
az vm reapply -g <resource-group> -n <vm-name>
Portal path:
- VM > Support + troubleshooting > Redeploy + reapply > Reapply
- If the VM is
Runningbut Linux is still unreachable, check whether SSH permissions or ownership are broken. If the Azure Linux VM Agent is Ready, use:
- VM > Operations > Run Command > RunShellScript
For Ubuntu:
#!/bin/bash
mkdir -p /var/run/sshd;chmod 755 /var/run/sshd;chown root:root /var/run/sshd
For RHEL:
#!/bin/bash
mkdir -p /var/empty/sshd;chmod 755 /var/empty/sshd;chown root:root /var/empty/sshd
For SUSE:
#!/bin/bash
mkdir -p /var/lib/empty;chmod 755 /var/lib/empty;chown root:root /var/lib/empty
If the VM Agent is not ready, use the Serial Console instead and run the same OS-specific commands there.
References:
- Tutorial: Create and Manage Linux VMs with the Azure CLI
- Troubleshoot SSH connections to an Azure Linux VM that fails, errors out, or is refused
- Troubleshoot Azure Bastion session failures due to unhealthy target VMs
- Virtual machine stuck in a failed state
- Troubleshoot SSH connection issues in Azure Linux VM due to permission and ownership issues