az vm run-command
注意VM内コマンド実行
az vm run-command invoke -g <rg> -n <vm> --command-id RunShellScript --scripts '<cmd>'
ネットワーク経由のログインなしにVM内でコマンド実行。SSH/RDP不通時の復旧手段(FW設定の修正等)として強力。
実行例
az vm run-command invoke -g rg -n web01 --command-id RunShellScript --scripts 'systemctl restart sshd'SSHを修復
書式
az vm run-command invoke -g rg -n vm --command-id RunShellScript|RunPowerShellScript --scripts cmd