2021-07-16 15:22:37 +05:30
|
|
|
# az vm
|
|
|
|
|
|
|
|
> Manage virtual machines in Azure.
|
2023-10-15 09:42:29 +02:00
|
|
|
> Part of `azure-cli` (also known as `az`).
|
2022-10-04 20:36:23 +05:30
|
|
|
> More information: <https://learn.microsoft.com/cli/azure/vm>.
|
2021-07-16 15:22:37 +05:30
|
|
|
|
2024-09-16 13:44:23 +03:00
|
|
|
- Display a table of available Virtual Machines:
|
2021-07-16 15:22:37 +05:30
|
|
|
|
2024-09-16 13:44:23 +03:00
|
|
|
`az vm list --output table`
|
2021-07-16 15:22:37 +05:30
|
|
|
|
2024-03-14 02:01:06 -03:00
|
|
|
- Create a virtual machine using the default Ubuntu image and generate SSH keys:
|
2021-07-16 15:22:37 +05:30
|
|
|
|
2025-05-11 20:07:11 +03:00
|
|
|
`az vm create {{[-g|--resource-group]}} {{rg}} {{[-n|--name]}} {{vm_name}} --image {{UbuntuLTS}} --admin-user {{azureuser}} --generate-ssh-keys`
|
2021-07-16 15:22:37 +05:30
|
|
|
|
|
|
|
- Stop a Virtual Machine:
|
|
|
|
|
2025-05-11 20:07:11 +03:00
|
|
|
`az vm stop {{[-g|--resource-group]}} {{rg}} {{[-n|--name]}} {{vm_name}}`
|
2021-07-16 15:22:37 +05:30
|
|
|
|
|
|
|
- Deallocate a Virtual Machine:
|
|
|
|
|
2025-05-11 20:07:11 +03:00
|
|
|
`az vm deallocate {{[-g|--resource-group]}} {{rg}} {{[-n|--name]}} {{vm_name}}`
|
2021-07-16 15:22:37 +05:30
|
|
|
|
|
|
|
- Start a Virtual Machine:
|
|
|
|
|
2025-05-11 20:07:11 +03:00
|
|
|
`az vm start {{[-g|--resource-group]}} {{rg}} {{[-n|--name]}} {{vm_name}}`
|
2021-07-16 15:22:37 +05:30
|
|
|
|
|
|
|
- Restart a Virtual Machine:
|
|
|
|
|
2025-05-11 20:07:11 +03:00
|
|
|
`az vm restart {{[-g|--resource-group]}} {{rg}} {{[-n|--name]}} {{vm_name}}`
|
2021-07-16 15:22:37 +05:30
|
|
|
|
2021-09-16 03:32:13 +00:00
|
|
|
- List VM images available in the Azure Marketplace:
|
2021-07-16 15:22:37 +05:30
|
|
|
|
|
|
|
`az vm image list`
|