4.5 Ubuntu VM Azure Command Line Management
20210829 An Azure virtual machine (and in fact all Azure services) can be managed through the Azure command line tool.
wajig update wajig install ca-certificates curl apt-transport-https lsb-release gnupg curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null AZ_REPO=$(lsb_release -cs) echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | sudo tee /etc/apt/sources.list.d/azure-cli.list wajig update wajig install azure-cli
There is no repos for Ubuntu 21.04 (hirsute) so edit
/etc/apt/sources.list.d/azure-cli.list to replace
This will pop up a browser window to establish your login credentials.
Managing a VM
I usually have a single resource group for my VM, both with the same
name. Thus, in the below examples, my resource group and VM are both
$ az resource list --name aidev $ az vm list --output table --show-details $ az vm start --resource-group aidev --name aidev $ az vm deallocate --resource-group aidev --name aidev
Note that a stopped VM continues to be billed. Be sure to deallocate (rather than stop) to avoid billing.
We can list the invoices since the beginning of 2020:
az billing invoice list --period-start-date "2021-01-01" --period-end-date "`date --iso`"
The JSON processor can be utilised to format the output:
az billing invoice list --period-start-date "2020-01-01" --period-end-date "`date --iso`" | jq '..billedAmount.value'
Your donation will support ongoing availability and give you access to the PDF version of the book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0.