Skip to content

Commit 3464a99

Browse files
Merge pull request #278499 from mimckitt/tutorial-updates
Update tutorial-install-apps-cli.md
2 parents 7c92289 + 7e5c47a commit 3464a99

File tree

4 files changed

+59
-22
lines changed

4 files changed

+59
-22
lines changed
-3.73 KB
Loading
-3.9 KB
Loading

articles/virtual-machine-scale-sets/tutorial-install-apps-cli.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,26 +85,25 @@ az vmss extension set \
8585
--settings customConfig.json
8686
```
8787

88-
Each VM instance in the scale set downloads and runs the script from GitHub. In a more complex example, multiple application components and files could be installed. If the scale set is scaled up, the new VM instances automatically apply the same Custom Script Extension definition and install the required application.
89-
9088
> [!CAUTION]
9189
> File names are case sensitive. Use the exact file name stated in these instructions to avoid failure.
9290
93-
## Test your scale set
94-
To allow traffic to reach the web server, create a load balancer rule with [az network lb rule create](/cli/azure/network/lb/rule). The following example creates a rule named *myLoadBalancerRuleWeb*:
91+
## Apply the extension to the existing scale set instances
92+
Upgrade all the instances to apply the custom script. The upgrade may take a couple of minutes.
9593

9694
```azurecli-interactive
97-
az network lb rule create \
98-
--resource-group myResourceGroup \
99-
--name myLoadBalancerRuleWeb \
100-
--lb-name myScaleSetLB \
101-
--backend-pool-name myScaleSetLBBEPool \
102-
--backend-port 80 \
103-
--frontend-ip-name loadBalancerFrontEnd \
104-
--frontend-port 80 \
105-
--protocol tcp
95+
az vmss update-instances --resource-group myResourceGroup --name myScaleSet --instance-ids "*"
96+
```
97+
98+
## Allow traffic to port 80
99+
To allow traffic to flow through the load balancer to the virtual machines the default network security group needs to be updated.
100+
101+
```azurecli-interactive
102+
az network nsg rule create --name AllowHTTP --resource-group myResourceGroup --nsg-name myScaleSetNSG --access Allow --priority 1010 --destination-port-ranges 80
106103
```
107104

105+
106+
## Test your scale set
108107
To see your web server in action, obtain the public IP address of your load balancer with [az network public-ip show](/cli/azure/network/public-ip). The following example obtains the IP address for *myScaleSetLBPublicIP* created as part of the scale set:
109108

110109
```azurecli-interactive
@@ -121,9 +120,18 @@ Enter the public IP address of the load balancer in to a web browser. The load b
121120

122121
Leave the web browser open so that you can see an updated version in the next step.
123122

124-
## Update app deployment
125-
Throughout the lifecycle of a scale set, you might need to deploy an updated version of your application. With the Custom Script Extension, you can reference an updated deploy script and then reapply the extension to your scale set. When the scale set was created in a previous step, the `--upgrade-policy-mode` was set to *automatic*. This setting allows the VM instances in the scale set to automatically update and apply the latest version of your application.
123+
## Change the upgrade policy
124+
In the previous section, in order to apply the updated application to all the scale set instances, a manual upgrade was needed. To enable updates to be applied automatically to all existing scale set instances, update the upgrade policy from manual to automatic. For more information on upgrade policies, see [Upgrade policies for Virtual Machine Scale Sets](virtual-machine-scale-sets-upgrade-policy.md).
126125

126+
```azurecli-interactive
127+
az vmss update \
128+
--name myScaleSet \
129+
--resource-group myResourceGroup \
130+
--set upgradePolicy.mode=automatic
131+
```
132+
133+
134+
## Update app deployment
127135
In your current shell, create a file named *customConfigv2.json* and paste the following configuration. This definition runs an updated *v2* version of the application install script:
128136

129137
```json
@@ -133,7 +141,7 @@ In your current shell, create a file named *customConfigv2.json* and paste the f
133141
}
134142
```
135143

136-
Apply the Custom Script Extension configuration to the VM instances in your scale set again with [az vmss extension set](/cli/azure/vmss/extension). The *customConfigv2.json* is used to apply the updated version of the application:
144+
Apply the Custom Script Extension configuration to the your scale set again with [az vmss extension set](/cli/azure/vmss/extension). The *customConfigv2.json* is used to apply the updated version of the application:
137145

138146
```azurecli-interactive
139147
az vmss extension set \
@@ -145,7 +153,7 @@ az vmss extension set \
145153
--settings @customConfigv2.json
146154
```
147155

148-
All VM instances in the scale set are automatically updated with the latest version of the sample web page. To see the updated version, refresh the web site in your browser:
156+
Because the scale set is now using an automatic upgrade policy, the updated application will automatically be applied to existing scale set instances. Refresh your web browser to see the updated application.
149157

150158
![Updated web page in Nginx](media/tutorial-install-apps-cli/running-nginx-updated.png)
151159

articles/virtual-machine-scale-sets/tutorial-install-apps-powershell.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ The Custom Script extension integrates with Azure Resource Manager templates. It
3131
To see the Custom Script Extension in action, create a scale set that installs the IIS web server and outputs the hostname of the scale set VM instance. The Custom Script Extension definition downloads a sample script from GitHub, installs the required packages, then writes the VM instance hostname to a basic HTML page.
3232

3333
## Create a scale set
34+
35+
Create a resource group with [New-AzResourceGroup](/powershell/module/az.compute/new-azresourcegroup). The following example creates a resource group named *myResourceGroup* in the *East US* location:
36+
37+
```azurepowershell-interactive
38+
New-AzResourceGroup -Name myResourceGroup -Location "East US"
39+
```
40+
3441
Now create a Virtual Machine Scale Set with [New-AzVmss](/powershell/module/az.compute/new-azvmss). To distribute traffic to the individual VM instances, a load balancer is also created. The load balancer includes rules to distribute traffic on TCP port 80. It also allows remote desktop traffic on TCP port 3389 and PowerShell remoting on TCP port 5985. When prompted, you can set your own administrative credentials for the VM instances in the scale set:
3542

3643
```azurepowershell-interactive
@@ -39,6 +46,7 @@ New-AzVmss `
3946
-VMScaleSetName "myScaleSet" `
4047
-OrchestrationMode "Flexible" `
4148
-Location "EastUS" `
49+
-UpgradePolicyMode "Manual" `
4250
-VirtualNetworkName "myVnet" `
4351
-SubnetName "mySubnet" `
4452
-PublicIpAddressName "myPublicIPAddress" `
@@ -57,7 +65,7 @@ $customConfig = @{
5765
}
5866
```
5967

60-
Now, apply the Custom Script Extension with [Add-AzVmssExtension](/powershell/module/az.Compute/Add-azVmssExtension). The configuration object previously defined is passed to the extension. Update and run the extension on the VM instances with [Update-AzVmss](/powershell/module/az.compute/update-azvmss).
68+
Now, apply the Custom Script Extension with [Add-AzVmssExtension](/powershell/module/az.Compute/Add-azVmssExtension). The configuration object previously defined is passed to the extension. Update the extension on the scale set profile instances with [Update-AzVmss](/powershell/module/az.compute/update-azvmss).
6169

6270
```azurepowershell-interactive
6371
# Get information about the scale set
@@ -74,11 +82,19 @@ $vmss = Add-AzVmssExtension `
7482
-TypeHandlerVersion 1.9 `
7583
-Setting $customConfig
7684
77-
# Update the scale set and apply the Custom Script Extension to the VM instances
85+
# Update the scale set
7886
Update-AzVmss `
7987
-ResourceGroupName "myResourceGroup" `
8088
-Name "myScaleSet" `
8189
-VirtualMachineScaleSet $vmss
90+
91+
```
92+
93+
## Add the extension to the existing scale set instances
94+
Perform a manual upgrade to apply the updated extension to all the existing scale set instances. The update may take a couple of minutes to complete.
95+
96+
```azurepowershell-interactive
97+
Update-AzVmssInstance -ResourceGroupName "myResourceGroup" -VMScaleSetName "myScaleSet" -InstanceId "*"
8298
```
8399

84100
Each VM instance in the scale set downloads and runs the script from GitHub. In a more complex example, multiple application components and files could be installed. If the scale set is scaled up, the new VM instances automatically apply the same Custom Script Extension definition and install the required application.
@@ -134,8 +150,21 @@ Enter the public IP address of the load balancer in to a web browser. The load b
134150

135151
Leave the web browser open so that you can see an updated version in the next step.
136152

153+
## Change the upgrade policy
154+
In the previous section, in order to apply the updated application to all the scale set instances, a manual upgrade was needed. To enable updates to be applied automatically to all existing scale set instances, update the upgrade policy from manual to automatic. For more information on upgrade policies, see [Upgrade policies for Virtual Machine Scale Sets](virtual-machine-scale-sets-upgrade-policy.md).
155+
156+
```azurepowershell-interactive
157+
$vmss = Get-AzVmss -ResourceGroupName "myResourceGroup" -VMScaleSetName "myScaleSet"
158+
159+
Update-Azvmss `
160+
-ResourceGroupName "myResourceGroup" `
161+
-Name "myScaleSet" `
162+
-UpgradePolicyMode "Automatic" `
163+
-VirtualMachineScaleSet $vmss
164+
```
165+
137166
## Update app deployment
138-
Throughout the lifecycle of a scale set, you may need to deploy an updated version of your application. With the Custom Script Extension, you can reference an updated deploy script and then reapply the extension to your scale set. When the scale set was created in a previous step, the `-UpgradePolicyMode` was set to *Automatic*. This setting allows the VM instances in the scale set to automatically update and apply the latest version of your application.
167+
Throughout the lifecycle of a scale set, you may need to deploy an updated version of your application. With the Custom Script Extension, you can reference an updated deploy script and then reapply the extension to your scale set.
139168

140169
Create a new config definition named *customConfigv2*. This definition runs an updated *v2* version of the application install script:
141170

@@ -146,7 +175,7 @@ $customConfigv2 = @{
146175
}
147176
```
148177

149-
Update the Custom Script Extension configuration to the VM instances in your scale set. The *customConfigv2* definition is used to apply the updated version of the application:
178+
Update the Custom Script Extension configuration to the VM instances in your scale set. The *customConfigv2* definition is used to apply the updated version of the application to the scale set:
150179

151180
```azurepowershell-interactive
152181
$vmss = Get-AzVmss `
@@ -161,7 +190,7 @@ Update-AzVmss `
161190
-VirtualMachineScaleSet $vmss
162191
```
163192

164-
All VM instances in the scale set are automatically updated with the latest version of the sample web page. To see the updated version, refresh the web site in your browser:
193+
Because the scale set is now using an automatic upgrade policy, the updated application will automatically be applied to existing scale set instances. Refresh your web browser to see the updated application. To see the updated version, refresh the web site in your browser:
165194

166195
![Updated web page in IIS](media/tutorial-install-apps-powershell/running-iis-updated.png)
167196

0 commit comments

Comments
 (0)