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-machine-scale-sets/tutorial-autoscale-cli.md
+5-14Lines changed: 5 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,12 @@ ms.author: jushiman
6
6
ms.topic: tutorial
7
7
ms.service: virtual-machine-scale-sets
8
8
ms.subservice: autoscale
9
-
ms.date: 11/22/2022
9
+
ms.date: 12/16/2022
10
10
ms.reviewer: mimckitt
11
11
ms.custom: avverma, devx-track-azurecli
12
12
13
13
---
14
14
# Tutorial: Automatically scale a Virtual Machine Scale Set with the Azure CLI
15
-
16
15
When you create a scale set, you define the number of VM instances that you wish to run. As your application demand changes, you can automatically increase or decrease the number of VM instances. The ability to autoscale lets you keep up with customer demand or respond to application performance changes throughout the lifecycle of your app. In this tutorial you learn how to:
17
16
18
17
> [!div class="checklist"]
@@ -28,14 +27,13 @@ When you create a scale set, you define the number of VM instances that you wish
28
27
- This tutorial requires version 2.0.32 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
29
28
30
29
## Create a scale set
31
-
32
-
Create a resource group with [az group create](/cli/azure/group) as follows:
30
+
Create a resource group with [az group create](/cli/azure/group).
33
31
34
32
```azurecli-interactive
35
33
az group create --name myResourceGroup --location eastus
36
34
```
37
35
38
-
Now create a Virtual Machine Scale Set with [az vmss create](/cli/azure/vmss). The following example creates a scale set with an instance count of *2*, and generates SSH keys if they don't exist:
36
+
Now create a Virtual Machine Scale Set with [az vmss create](/cli/azure/vmss). The following example creates a scale set with an instance count of *2*, and generates SSH keys if they don't exist.
39
37
40
38
```azurecli-interactive
41
39
az vmss create \
@@ -49,7 +47,6 @@ az vmss create \
49
47
```
50
48
51
49
## Define an autoscale profile
52
-
53
50
To enable autoscale on a scale set, you first define an autoscale profile. This profile defines the default, minimum, and maximum scale set capacity. These limits let you control cost by not continually creating VM instances, and balance acceptable performance with a minimum number of instances that remain in a scale-in event. Create an autoscale profile with [az monitor autoscale create](/cli/azure/monitor/autoscale#az-monitor-autoscale-create). The following example sets the default, and minimum, capacity of *2* VM instances, and a maximum of *10*:
54
51
55
52
```azurecli-interactive
@@ -64,7 +61,6 @@ az monitor autoscale create \
64
61
```
65
62
66
63
## Create a rule to autoscale out
67
-
68
64
If your application demand increases, the load on the VM instances in your scale set increases. If this increased load is consistent, rather than just a brief demand, you can configure autoscale rules to increase the number of VM instances in the scale set. When these VM instances are created and your applications are deployed, the scale set starts to distribute traffic to them through the load balancer. You control what metrics to monitor, how long the application load must meet a given threshold, and how many VM instances to add to the scale set.
69
65
70
66
Create a rule with [az monitor autoscale rule create](/cli/azure/monitor/autoscale/rule#az-monitor-autoscale-rule-create) that increases the number of VM instances in a scale set when the average CPU load is greater than 70% over a 5-minute period. When the rule triggers, the number of VM instances is increased by three.
@@ -78,10 +74,9 @@ az monitor autoscale rule create \
78
74
```
79
75
80
76
## Create a rule to autoscale in
81
-
82
77
On an evening or weekend, your application demand may decrease. If this decreased load is consistent over a period of time, you can configure autoscale rules to decrease the number of VM instances in the scale set. This scale-in action reduces the cost to run your scale set as you only run the number of instances required to meet the current demand.
83
78
84
-
Create another rule with [az monitor autoscale rule create](/cli/azure/monitor/autoscale/rule#az-monitor-autoscale-rule-create) that decreases the number of VM instances in a scale set when the average CPU load then drops below 30% over a 5-minute period. The following example defines the rule to scale in the number of VM instances by one:
79
+
Create another rule with [az monitor autoscale rule create](/cli/azure/monitor/autoscale/rule#az-monitor-autoscale-rule-create) that decreases the number of VM instances in a scale set when the average CPU load then drops below 30% over a 5-minute period. The following example defines the rule to scale in the number of VM instances by one.
85
80
86
81
```azurecli-interactive
87
82
az monitor autoscale rule create \
@@ -92,7 +87,6 @@ az monitor autoscale rule create \
92
87
```
93
88
94
89
## Generate CPU load on scale set
95
-
96
90
To test the autoscale rules, generate some CPU load on the VM instances in the scale set. This simulated CPU load causes the autoscales to scale out and increase the number of VM instances. As the simulated CPU load is then decreased, the autoscale rules scale in and reduce the number of VM instances.
97
91
98
92
To connect to an individual instance, see [Tutorial: Connect to Virtual Machine Scale Set instances](tutorial-connect-to-instances-cli.md)
@@ -142,7 +136,6 @@ exit
142
136
```
143
137
144
138
## Monitor the active autoscale rules
145
-
146
139
To monitor the number of VM instances in your scale set, use **watch**. It takes 5 minutes for the autoscale rules to begin the scale-out process in response to the CPU load generated by **stress** on each of the VM instances:
147
140
148
141
```azurecli-interactive
@@ -169,21 +162,19 @@ Every 2.0s: az vmss list-instances --resource-group myResourceGroup --name mySca
169
162
Once **stress** stops on the initial VM instances, the average CPU load returns to normal. After another 5 minutes, the autoscale rules then scale in the number of VM instances. Scale in actions remove VM instances with the highest IDs first. When a scale set uses Availability Sets or Availability Zones, scale in actions are evenly distributed across those VM instances. The following example output shows one VM instance deleted as the scale set autoscales in:
Exit *watch* with `Ctrl-c`. The scale set continues to scale in every 5 minutes and remove one VM instance until the minimum instance count of two is reached.
176
169
177
170
## Clean up resources
178
-
179
171
To remove your scale set and additional resources, delete the resource group and all its resources with [az group delete](/cli/azure/group). 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.
180
172
181
173
```azurecli-interactive
182
174
az group delete --name myResourceGroup --yes --no-wait
183
175
```
184
176
185
177
## Next steps
186
-
187
178
In this tutorial, you learned how to automatically scale in or out a scale set with the Azure CLI:
> This tutorial uses Uniform Orchestration mode. We recommend using Flexible Orchestration for new workloads. For more information, see [Orchestration modes for Virtual Machine Scale Sets in Azure](virtual-machine-scale-sets-orchestration-modes.md).
When you create a scale set, you define the number of VM instances that you wish to run. As your application demand changes, you can automatically increase or decrease the number of VM instances. The ability to autoscale lets you keep up with customer demand or respond to application performance changes throughout the lifecycle of your app. In this tutorial you learn how to:
22
20
23
21
> [!div class="checklist"]
@@ -244,7 +242,6 @@ To remove your scale set and additional resources, delete the resource group and
Copy file name to clipboardExpand all lines: articles/virtual-machine-scale-sets/tutorial-connect-to-instances-cli.md
+7-15Lines changed: 7 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,13 @@ author: ju-shim
5
5
ms.author: jushiman
6
6
ms.topic: tutorial
7
7
ms.service: virtual-machine-scale-sets
8
-
ms.date: 11/29/2022
8
+
ms.date: 12/16/2022
9
9
ms.reviewer: mimckitt
10
10
ms.custom: mimckitt, devx-track-azurecli
11
11
12
12
---
13
13
14
14
# Tutorial: Connect to Virtual Machine Scale Set instances using the Azure CLI
15
-
16
15
A Virtual Machine Scale Set allows you to deploy and manage a set of virtual machines. Throughout the lifecycle of a Virtual Machine Scale Set, you may need to run one or more management tasks. In this tutorial you learn how to:
17
16
18
17
> [!div class="checklist"]
@@ -25,9 +24,7 @@ A Virtual Machine Scale Set allows you to deploy and manage a set of virtual mac
25
24
26
25
This article requires version 2.0.29 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
27
26
28
-
29
27
## List instances in a scale set
30
-
31
28
If you do not have a scale set already created, see [Tutorial: Create and manage a Virtual Machine Scale Set with the Azure CLI](tutorial-create-and-manage-cli.md)
32
29
33
30
List all the instances in your Virtual Machine Scale Set.
Using the VM name of the instance you want to connect to, use [az vm nic list](/cli/) to find the NIC name.
47
+
Use [az vm nic list](/cli/azure/vm/nic#az-vm-nic-list) and the name of the individual VM instance to find the NIC name.
53
48
54
49
```azurecli-interactive
55
50
az vm nic list \
@@ -68,7 +63,7 @@ az vm nic list \
68
63
]
69
64
```
70
65
71
-
Using the VM name and NIC name, get the private IP address of the NIC, the Inbound NAT rule name and load balancer name using [az vm nic show](/cli).
66
+
Using the VM name and NIC name, get the private IP address of the NIC, the Inbound NAT rule name and load balancer name using [az vm nic show](/cli/azure/vm/nic#az-vm-nic-show).
72
67
73
68
74
69
```azurecli-interactive
@@ -114,16 +109,14 @@ az vm nic show --resource-group myResourceGroup --vm-name myScaleSet_0e7d4d21 --
Using the backend pool name and load balancer name, get the port for the private IP address of the instance you want to connect to.
126
-
119
+
Using the backend pool name and load balancer name, get the port for the private IP address of the instance you want to connect to with [az network lb list-mapping](/cli/azure/network/lb#az-network-lb-list-mapping).
Copy file name to clipboardExpand all lines: articles/virtual-machine-scale-sets/tutorial-connect-to-instances-powershell.md
+7-18Lines changed: 7 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,13 @@ author: ju-shim
5
5
ms.author: jushiman
6
6
ms.topic: tutorial
7
7
ms.service: virtual-machine-scale-sets
8
-
ms.date: 11/29/2022
8
+
ms.date: 12/16/2022
9
9
ms.reviewer: mimckitt
10
10
ms.custom: mimckitt, devx-track-azurepowershell
11
11
12
12
---
13
13
14
14
# Tutorial: Connect to Virtual Machine Scale Set instances using Azure PowerShell
15
-
16
15
A Virtual Machine Scale Set allows you to deploy and manage a set of virtual machines. Throughout the lifecycle of a Virtual Machine Scale Set, you may need to run one or more management tasks. In this tutorial you learn how to:
17
16
18
17
> [!div class="checklist"]
@@ -21,13 +20,9 @@ A Virtual Machine Scale Set allows you to deploy and manage a set of virtual mac
21
20
22
21
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
If you don't have a scale set already created, see [Tutorial: Create and manage a Virtual Machine Scale Set with Azure PowerShell](tutorial-create-and-manage-powershell.md).
32
27
33
28
List all the instances in your Virtual Machine Scale Set using [Get-AzVM](/powershell/module/az.compute/get-azvm).
@@ -43,11 +38,8 @@ myResourceGroup myScaleSet_Instance1 eastus Standard_DS1_v2 Windows
43
38
myResourceGroup myScaleSet_Instance2 eastus Standard_DS1_v2 Windows myScaleSet-instance2-nic
44
39
```
45
40
46
-
47
41
## Get NIC information
48
-
49
-
50
-
Using the NIC name, get the private IP address of the NIC, the backend address pool name and load balancer name using [Get-AzNetworkInterface](/powershell/module/az.network/get-aznetworkinterface).
42
+
Using the NIC name, get the private IP address of the NIC, the backend address pool name and load balancer name with [Get-AzNetworkInterface](/powershell/module/az.network/get-aznetworkinterface).
If you run the above command and find your load balancer doesn't have any inbound NAT rules, you can add inbound NAT rules using [Add-AzLoadBalancerInboundNatRuleConfig](/powershell/module/az.network/add-azloadbalancerinboundnatruleconfig). Once complete, run [Get-AzLoadBalancerBackendAddressInboundNatRulePortMapping](/powershell/module/az.network/add-azloadbalancerinboundnatruleconfig) again.
Get the public IP of the load balancer using [GetAzPublicIpAddress](/powershell/module/az.network/get-azpublicipaddress).
125
115
126
116
```azurepowershell-interactive
@@ -152,7 +142,6 @@ Sku : {
152
142
```
153
143
154
144
## Connect to your instance
155
-
156
145
Remote Desktop to your machine using the Public IP address of the load balancer and the Port mapping to the machine instance you want to connect to.
157
146
158
147
:::image type="content" source="media/virtual-machine-scale-sets-connect-to-instances/tutorial-connect-to-instances-powershell-rdp.png" alt-text="Screenshot of remote desktop application from Windows machine.":::
@@ -167,4 +156,4 @@ In this tutorial, you learned how to list the instances in your scale set and co
167
156
168
157
169
158
> [!div class="nextstepaction"]
170
-
> [Modify a scale set](tutorial-modify-scale-sets-cli.md)
159
+
> [Modify a scale set](tutorial-modify-scale-sets-powershell.md)
0 commit comments