@@ -20,7 +20,54 @@ This script creates a virtual machine scale set running Windows Server 2016 and
20
20
21
21
## Sample script
22
22
23
- [ !code-powershell[ main] ( ../../../powershell_scripts/virtual-machine-scale-sets/install-apps/install-apps.ps1 " Install apps into a scale set ")]
23
+ ``` powershell
24
+ # Provide your own secure password for use with the VM instances
25
+ $cred = Get-Credential
26
+
27
+ # Create a virtual machine scale set and supporting resources
28
+ # A resource group, virtual network, load balancer, and NAT rules are automatically
29
+ # created if they do not already exist
30
+ New-AzVmss `
31
+ -ResourceGroupName "myResourceGroup" `
32
+ -VMScaleSetName "myScaleSet" `
33
+ -Location "EastUS" `
34
+ -VirtualNetworkName "myVnet" `
35
+ -SubnetName "mySubnet" `
36
+ -PublicIpAddressName "myPublicIPAddress" `
37
+ -LoadBalancerName "myLoadBalancer" `
38
+ -UpgradePolicyMode "Automatic" `
39
+ -Credential $cred
40
+
41
+ # Create a configuration object to store the Custom Script Extension definition
42
+ $customConfig = @{
43
+ "fileUris" = (,"https://raw.githubusercontent.com/Azure-Samples/compute-automation-configurations/master/automate-iis.ps1");
44
+ "commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File automate-iis.ps1"
45
+ }
46
+
47
+ # Get information about the scale set
48
+ $vmss = Get-AzVmss `
49
+ -ResourceGroupName "myResourceGroup" `
50
+ -VMScaleSetName "myScaleSet"
51
+
52
+ # Add the Custom Script Extension to install IIS and configure basic website
53
+ $vmss = Add-AzVmssExtension `
54
+ -VirtualMachineScaleSet $vmss `
55
+ -Name "customScript" `
56
+ -Publisher "Microsoft.Compute" `
57
+ -Type "CustomScriptExtension" `
58
+ -TypeHandlerVersion 1.10 `
59
+ -Setting $customConfig
60
+
61
+ # Update the scale set and apply the Custom Script Extension to the VM instances
62
+ Update-AzVmss `
63
+ -ResourceGroupName "myResourceGroup" `
64
+ -Name "myScaleSet" `
65
+ -VirtualMachineScaleSet $vmss
66
+
67
+ # Get the public IP address of your load balancer. To see your scale set in action, open this address in a web browser
68
+ Get-AzPublicIpAddress -ResourceGroupName "myResourceGroup" | Select IpAddress
69
+ ```
70
+
24
71
25
72
## Clean up deployment
26
73
Run the following command to remove the resource group, scale set, and all related resources.
0 commit comments