You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/virtual-machines/linux/tutorial-manage-vm.md
+66-55Lines changed: 66 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ author: cynthn
5
5
ms.service: virtual-machines
6
6
ms.collection: linux
7
7
ms.topic: tutorial
8
-
ms.date: 03/23/2018
8
+
ms.date: 03/23/2023
9
9
ms.author: cynthn
10
10
ms.custom: mvc, devx-track-azurecli
11
11
@@ -25,18 +25,19 @@ Azure virtual machines provide a fully configurable and flexible computing envir
25
25
> * Resize a VM
26
26
> * View and understand VM state
27
27
28
-
This tutorial uses the CLI within the [Azure Cloud Shell](../../cloud-shell/overview.md), which is constantly updated to the latest version. To open the Cloud Shell, select **Try it** from the top of any code block.
28
+
This tutorial uses the CLI within the [Azure Cloud Shell](../../cloud-shell/overview.md), which is constantly updated to the latest version.
29
29
30
30
If you choose to install and use the CLI locally, this tutorial requires that you are running the Azure CLI version 2.0.30 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI](/cli/azure/install-azure-cli).
31
31
32
32
## Create resource group
33
33
34
34
Create a resource group with the [az group create](/cli/azure/group) command.
35
35
36
-
An Azure resource group is a logical container into which Azure resources are deployed and managed. A resource group must be created before a virtual machine. In this example, a resource group named *myResourceGroupVM* is created in the *eastus* region.
36
+
An Azure resource group is a logical container into which Azure resources are deployed and managed. A resource group must be created before a virtual machine. In this example, a resource group named *myResourceGroupVM* is created in the *eastus2* region.
37
+
37
38
38
39
```azurecli-interactive
39
-
az group create --name myResourceGroupVM --location eastus
40
+
az group create --name myResourceGroupVM --location eastus2
40
41
```
41
42
42
43
The resource group is specified when creating or modifying a VM, which can be seen throughout this tutorial.
@@ -45,24 +46,25 @@ The resource group is specified when creating or modifying a VM, which can be se
45
46
46
47
Create a virtual machine with the [az vm create](/cli/azure/vm) command.
47
48
48
-
When you create a virtual machine, several options are available such as operating system image, disk sizing, and administrative credentials. The following example creates a VM named *myVM* that runs Ubuntu Server. A user account named *azureuser* is created on the VM, and SSH keys are generated if they do not exist in the default key location (*~/.ssh*):
49
+
When you create a virtual machine, several options are available such as operating system image, disk sizing, and administrative credentials. The following example creates a VM named *myVM* that runs SUSE Linux Enterprise Server (SLES). A user account named *azureuser* is created on the VM, and SSH keys are generated if they do not exist in the default key location (*~/.ssh*):
49
50
50
51
```azurecli-interactive
51
52
az vm create \
52
53
--resource-group myResourceGroupVM \
53
54
--name myVM \
54
-
--image UbuntuLTS \
55
+
--image SLES \
56
+
--public-ip-sku Standard \
55
57
--admin-username azureuser \
56
58
--generate-ssh-keys
57
59
```
58
60
59
-
It may take a few minutes to create the VM. Once the VM has been created, the Azure CLI outputs information about the VM. Take note of the `publicIpAddress`, this address can be used to access the virtual machine..
61
+
It may take a few minutes to create the VM. Once the VM has been created, the Azure CLI outputs information about the VM. Take note of the `publicIpAddress`, this address can be used to access the virtual machine.
A full list can be seen by adding the `--all` parameter. The image list can also be filtered by `--publisher` or `–-offer`. In this example, the list is filtered for all images with an offer that matches *CentOS*.
121
+
A full list can be seen by adding the `--all` parameter. The image list can also be filtered by `--publisher` or `–-offer`. In this example, the list is filtered for all images, published by OpenLogic, with an offer that matches *CentOS*.
120
122
121
123
```azurecli-interactive
122
-
az vm image list --offer CentOS --all --output table
124
+
az vm image list --offer CentOS --publisher OpenLogic --all --output table
> Canonical has changed the **Offer** names they use for the most recent versions. Before Ubuntu 20.04, the **Offer** name is UbuntuServer. For Ubuntu 20.04 the **Offer** name is `0001-com-ubuntu-server-focal` and for Ubuntu 22.04 it's `0001-com-ubuntu-server-jammy`.
141
151
142
-
To deploy a VM using a specific image, take note of the value in the *Urn* column, which consists of the publisher, offer, SKU, and optionally a version number to [identify](cli-ps-findimage.md#terminology) the image. When specifying the image, the image version number can be replaced with `latest`, which selects the latest version of the distribution. In this example, the `--image` parameter is used to specify the latest version of a CentOS 6.5 image.
152
+
To deploy a VM using a specific image, take note of the value in the *Urn* column, which consists of the publisher, offer, SKU, and optionally a version number to [identify](cli-ps-findimage.md#terminology) the image. When specifying the image, the image version number can be replaced with `latest`, which selects the latest version of the distribution. In this example, the `--image` parameter is used to specify the latest version of a CentOS 8.5.
143
153
144
154
```azurecli-interactive
145
-
az vm create --resource-group myResourceGroupVM --name myVM2 --image OpenLogic:CentOS:6.5:latest --generate-ssh-keys
155
+
az vm create --resource-group myResourceGroupVM --name myVM2 --image OpenLogic:CentOS:8_5:latest --generate-ssh-keys
146
156
```
147
157
148
158
## Understand VM sizes
@@ -153,45 +163,45 @@ A virtual machine size determines the amount of compute resources such as CPU, G
153
163
154
164
The following table categorizes sizes into use cases.
|[General purpose](../sizes-general.md)|B, Dsv3, Dv3, DSv2, Dv2, Av2, DC| Balanced CPU-to-memory. Ideal for dev / test and small to medium applications and data solutions. |
159
-
|[Compute optimized](../sizes-compute.md)| Fsv2 | High CPU-to-memory. Good for medium traffic applications, network appliances, and batch processes. |
160
-
|[Memory optimized](../sizes-memory.md)| Esv3, Ev3, M, DSv2, Dv2 | High memory-to-core. Great for relational databases, medium to large caches, and in-memory analytics. |
161
-
|[Storage optimized](../sizes-storage.md)| Lsv2, Ls | High disk throughput and IO. Ideal for Big Data, SQL, and NoSQL databases. |
162
-
|[GPU](../sizes-gpu.md)| NV, NVv2, NC, NCv2, NCv3, ND | Specialized VMs targeted for heavy graphic rendering and video editing. |
163
-
|[High performance](../sizes-hpc.md)| H | Our most powerful CPU VMs with optional high-throughput network interfaces (RDMA). |
@@ -202,8 +212,8 @@ In the previous VM creation example, a size was not provided, which results in a
202
212
az vm create \
203
213
--resource-group myResourceGroupVM \
204
214
--name myVM3 \
205
-
--image UbuntuLTS \
206
-
--size Standard_F4s \
215
+
--image SLES \
216
+
--size Standard_D2ds_v4 \
207
217
--generate-ssh-keys
208
218
```
209
219
@@ -224,7 +234,7 @@ az vm list-vm-resize-options --resource-group myResourceGroupVM --name myVM --qu
224
234
If the desired size is available, the VM can be resized from a powered-on state, however it is rebooted during the operation. Use the [az vm resize](/cli/azure/vm) command to perform the resize.
225
235
226
236
```azurecli-interactive
227
-
az vm resize --resource-group myResourceGroupVM --name myVM --size Standard_DS4_v2
237
+
az vm resize --resource-group myResourceGroupVM --name myVM --size Standard_D4s_v3
228
238
```
229
239
230
240
If the desired size is not on the current cluster, the VM needs to be deallocated before the resize operation can occur. Use the [az vm deallocate](/cli/azure/vm) command to stop and deallocate the VM. Note, when the VM is powered back on, any data on the temp disk may be removed. The public IP address also changes unless a static IP address is being used.
@@ -275,9 +285,9 @@ az vm get-instance-view \
275
285
Output:
276
286
277
287
```output
278
-
odeDisplayStatusLevel
279
-
------------------ ----------------------
280
-
PowerState/running VM running Info
288
+
CodeLevelDisplayStatus
289
+
------------------ ----------------------
290
+
PowerState/running Info VM running
281
291
```
282
292
283
293
To retrieve the power state of all the VMs in your subscription, use the [Virtual Machines - List All API](/rest/api/compute/virtualmachines/listall) with parameter **statusOnly** set to *true*.
@@ -308,9 +318,9 @@ az vm start --resource-group myResourceGroupVM --name myVM
308
318
309
319
### Deleting VM resources
310
320
311
-
You can delete a VM, but by default this only deletes the VM resource, not the disks and networking resources the VM uses. You can change the default behavior to delete other resources when you delete the VM. For more information, see [Delete a VM and attached resources](../delete.md).
321
+
Depending on how you delete a VM, it may only delete the VM resource, not the networking and disk resources. You can change the default behavior to delete other resources when you delete the VM. For more information, see [Delete a VM and attached resources](../delete.md).
312
322
313
-
Deleting a resource group also deletes all resources contained within, such as the VM, virtual network, and disk. The `--no-wait` parameter returns control to the prompt without waiting for the operation to complete. The `--yes` parameter confirms that you wish to delete the resources without an additional prompt to do so.
323
+
Deleting a resource group also deletes all resources in the resource group, like the VM, virtual network, and disk. The `--no-wait` parameter returns control to the prompt without waiting for the operation to complete. The `--yes` parameter confirms that you wish to delete the resources without an additional prompt to do so.
314
324
315
325
```azurecli-interactive
316
326
az group delete --name myResourceGroupVM --no-wait --yes
@@ -331,3 +341,4 @@ Advance to the next tutorial to learn about VM disks.
331
341
332
342
> [!div class="nextstepaction"]
333
343
> [Create and Manage VM disks](./tutorial-manage-disks.md)
0 commit comments