问题
I am using a Ubuntu 16.04 VM in Azure to run some GPU computation. Typically, I run my experiments at night and I would like to deallocate the VM when the computation is over (to save some money). Is there any command that I can run from the VM I want to deallocate to actually deallocate it? Shall I just use the Azure CLI? Thanks in advance.
回答1:
Yes, it is possible.
When your script works successful, you could judge the return value. Then, execute Azure CLI to deallocate your VM.
##your script
if [$? -eq 0];then
az vm deallocate --resource-group myResourceGroup --name myVM
fi
Notes: If you don't use static IP, it will change IP when you deallocate your VM. Also, if you want to start your VM automatically, you could use Azure automation runbook.
回答2:
Yeah, you would want to use Azure Cli or Azure Cli 2.0
az vm deallocate --resource-group myResourceGroup --name myVM
or with the cli
azure vm deallocate -g myResourceGroup -n myVM
来源:https://stackoverflow.com/questions/44648067/deallocate-a-ubuntu-vm-from-itself