Skip to content

Commit 2635a25

Browse files
authored
Merge pull request #99872 from MicahMcKittrick-MSFT/patch-288
MicrosoftDocs/azure-docs#42966
2 parents 30ab463 + 719a0d7 commit 2635a25

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

articles/virtual-machine-scale-sets/tutorial-use-custom-image-powershell.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ $image = New-AzImageConfig -Location "EastUS" -SourceVirtualMachineId $vm.ID
109109
New-AzImage -Image $image -ImageName "myImage" -ResourceGroupName "myResourceGroup"
110110
```
111111

112+
## Configure the Network Security Group Rules
113+
Before creating the Scale Set, we need to configure the associating Network Security Group rules to allow access to HTTP, RDP and Remoting
114+
115+
```azurepowershell-interactive
116+
$rule1 = New-AzNetworkSecurityRuleConfig -Name web-rule -Description "Allow HTTP" -Access Allow -Protocol Tcp -Direction Inbound -Priority 100 -SourceAddressPrefix Internet -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 80
117+
118+
$rule2 = New-AzNetworkSecurityRuleConfig -Name rdp-rule -Description "Allow RDP" -Access Allow -Protocol Tcp -Direction Inbound -Priority 110 -SourceAddressPrefix Internet -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389
119+
120+
$rule3 = New-AzNetworkSecurityRuleConfig -Name remoting-rule -Description "Allow PS Remoting" -Access Allow -Protocol Tcp -Direction Inbound -Priority 120 -SourceAddressPrefix Internet -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 5985
121+
122+
New-AzNetworkSecurityGroup -Name "myNSG" -ResourceGroupName "myResourceGroup" -Location "EastUS" -SecurityRules $rule1,$rule2,$rule3
123+
```
112124

113125
## Create a scale set from the custom VM image
114126
Now create a scale set with [New-AzVmss](/powershell/module/az.compute/new-azvmss) that uses the `-ImageName` parameter to define the custom VM image created in the previous step. 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, as well as allow remote desktop traffic on TCP port 3389 and PowerShell remoting on TCP port 5985. When prompted, provide your own desired administrative credentials for the VM instances in the scale set:
@@ -120,6 +132,7 @@ New-AzVmss `
120132
-VMScaleSetName "myScaleSet" `
121133
-VirtualNetworkName "myVnet" `
122134
-SubnetName "mySubnet" `
135+
-SecurityGroupName "myNSG"
123136
-PublicIpAddressName "myPublicIPAddress" `
124137
-LoadBalancerName "myLoadBalancer" `
125138
-UpgradePolicyMode "Automatic" `

0 commit comments

Comments
 (0)