Skip to content

Commit 0901a2c

Browse files
committed
WIP 2.5
1 parent 25390da commit 0901a2c

File tree

1 file changed

+51
-37
lines changed

1 file changed

+51
-37
lines changed

articles/azure-monitor/autoscale/autoscale-using-powershell.md

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,60 +10,42 @@ ms.reviewer: akkumari
1010

1111
# Customer intent: As a user or dev ops administrator, I want to use powershell to set up autoscale so I can scale my VMSS.
1212

13-
14-
1-sentence Intro to autoscale
15-
Benefits of using Poowershell to configurye autoscale
16-
Prereqs
17-
- give powershell to create VMSS ? ( how do they create load ?)
18-
- Windows or linux ? ( linux)
19-
- provide a vm image ? (git, galery ? which user owns it ?)
20-
- assume VMSS exists ?
21-
- create an image - too complicated
22-
23-
Define the scenario
24-
scripts to create the objects.
25-
For each Object define what is required with example
26-
27-
2813
---
2914

3015
# Configure autoscale with PowerShell
3116

32-
Autoscale settings help ensure that you have the right amount of resources running to handle the fluctuating load of your application.Cyou can configure autoscale using the Azure portal, Azure CLI, PowerShell or ARM or Bicep templates.
17+
Autoscale settings help ensure that you have the right amount of resources running to handle the fluctuating load of your application. You can configure autoscale using the Azure portal, Azure CLI, PowerShell or ARM or Bicep templates.
3318

34-
This article shows you haw to configure autoscale for a Virtual Machine Scale Set using Powershell
19+
This article shows you how to configure autoscale for a Virtual Machine Scale Set using Powershell using the following steps:
20+
+ Create a scale set that you can autoscale
21+
+ Create rules to scale in and scale out
22+
+ Create a profile that uses your rules
23+
+ Apply the autoscale settings
24+
+ Update your autoscale settings with notifications
3525

3626
## Prerequisites
3727

3828
To configure autoscale using PowerShell, you need an Azure account with an active subscription. You can [create an account for free](https://azure.microsoft.com/free).
3929

40-
## Overview
41-
42-
+ Start by creating a scale set that you can autoscle
43-
+ Create rules to scale in and scale out
44-
+ Create a profile that uses your rules
45-
+ Apply the autoscale settings
46-
+ Make some changes
47-
+ Update your autoscale settings
4830

4931
## Create a Virtual Machine Scale Set
5032

51-
Create a scale set using the following commands
33+
Create a scale set using the following cmdlets
5234

5335
```azurepowershell
36+
#Set the VMSS name and resource group name
5437
55-
# Create login credtions for the VMSS.
56-
$vmPassword = ConvertTo-SecureString "ChangeThisPassword1" -AsPlainText -Force
57-
$vmCred = New-Object System.Management.Automation.PSCredential('azureuser', $vmPassword)
58-
59-
#set the VMSS name and resource group name
6038
$resourceGroupName="rg-powershell-autoscale"
6139
$vmssName="vmss-001"
6240
6341
# create a new resource group
64-
6542
New-AzResourceGroup -ResourceGroupName $resourceGroupName -Location "EastUS"
6643
44+
# Create login credentials for the VMSS
45+
$vmPassword = ConvertTo-SecureString "ChangeThisPassword1" -AsPlainText -Force
46+
$vmCred = New-Object System.Management.Automation.PSCredential('azureuser', $vmPassword)
47+
48+
6749
New-AzVmss `
6850
-ResourceGroupName $resourceGroupName `
6951
-Location "EastUS" `
@@ -76,9 +58,10 @@ New-AzVmss `
7658
-UpgradePolicyMode "Automatic" `
7759
```
7860

79-
## Create autoscale settings.
61+
## Create autoscale settings
8062

8163
To create autoscale setting using Powershell, follow the sequence below:
64+
8265
1. Create rules using `New-AzAutoscaleScaleRuleObject`
8366
1. Create a profile using `New-AzAutoscaleProfileObject`
8467
1. Create or update the autoscale settings using `Update-AzAutoscaleSetting`
@@ -148,7 +131,7 @@ $rule2=New-AzAutoscaleScaleRuleObject `
148131

149132
### Create an autoscale profile and associate the rules
150133

151-
After defining the scale rules, create a profile. The profile specifies the default, upper, and lower instance count limits, and the times that the associated rules can be applied. Use thew [`New-AzAutoscaleProfileObject`](https://learn.microsoft.com/powershell/module/az.monitor/new-azautoscaleprofileobject) command to create a new autoscale profile.
134+
After defining the scale rules, create a profile. The profile specifies the default, upper, and lower instance count limits, and the times that the associated rules can be applied. Use the [`New-AzAutoscaleProfileObject`](https://learn.microsoft.com/powershell/module/az.monitor/new-azautoscaleprofileobject) cmdlet to create a new autoscale profile.
152135

153136
```azurepowershell
154137
$profile1=New-AzAutoscaleProfileObject `
@@ -163,8 +146,10 @@ $profile1=New-AzAutoscaleProfileObject `
163146
-ScheduleTimeZone "Pacific Standard Time" `
164147
-Rule $rule1, $rule2
165148
```
166-
Parameters
167-
|Parameter| Description|
149+
150+
Parameters
151+
152+
|Parameter|Description|
168153
|---|---|
169154
|`CapacityDefault`| The number of instances that will be set if metrics are not available for evaluation. The default is only used if the current instance count is lower than the default.
170155
| `CapacityMaximum` |The maximum number of instances for the resource. The maximum number of instances is further limited by the number of cores that are available in the subscription.
@@ -205,7 +190,7 @@ To set a web hook;
205190
$webhook1=New-AzAutoscaleWebhookNotificationObject -Property @{} -ServiceUri "http://contoso.com/wbhook1"
206191
```
207192

208-
Configure the notification using the webhook and set up email notification using the [`New-AzAutoscaleNotificationObject`](https://learn.microsoft.com/powershell/module/az.monitor/new-azautoscalenotificationobject) command:
193+
Configure the notification using the webhook and set up email notification using the [`New-AzAutoscaleNotificationObject`](https://learn.microsoft.com/powershell/module/az.monitor/new-azautoscalenotificationobject) cmdlet:
209194

210195
```azurepowershell
211196
@@ -229,3 +214,32 @@ Update-AzAutoscaleSetting `
229214
230215
```
231216

217+
## Review your autoscale settings
218+
219+
To review your autoscale settings load the settings into a variable using `Get-AzAutoscaleSetting` then output the variable as follows:
220+
221+
```azurepowershell
222+
$autoscaleSetting=Get-AzAutoscaleSetting -ResourceGroupName $resourceGroupName -Name vmss-autoscalesetting1 `
223+
$autoscaleSetting | Select-Object -Property *
224+
```
225+
226+
Get your autoscale history using `AzAutoscaleHistory`
227+
```azurepowershell
228+
Get-AzAutoscaleHistory -ResourceId /subscriptions/<subscriptionId/resourceGroups/<resourcegroup name>/providers/Microsoft.Compute/virtualMachineScaleSets/<scaleset name>
229+
```
230+
231+
## Other autoscale commands
232+
233+
For a complete list of PowerShell cmdlets for autoscale, see the [Poweshell Module Browser](https://learn.microsoft.com/powershell/module/?term=azautoscale)
234+
235+
236+
237+
## Clean up resources
238+
239+
To cleanup the resources you created in this tutorial delete the resource group that you created.
240+
The following cmdlet deletes the resource group and all of its resources.
241+
```azurecli
242+
243+
Remove-AzResourceGroup -Name $resourceGroupName
244+
245+
```

0 commit comments

Comments
 (0)