Deallocate a Ubuntu VM from itself

元气小坏坏 提交于 2019-12-13 08:39:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!