Hi folks!
Today let’s create the network security group that has a very important role within Microsoft Azure. It works at layer 4, where we can communicate ports and IPs between internal or external networks through a VPN.
Now let’s assign the following variables:
$NSGName=”NSG-VM-01″
$RGName= “RG_GETPRACTICAL”
$LOCATION= “UKSOUTH”
Next, we will create a variable with the name of the port and which rule will be used. In this case, I am creating an “NSG” for RDP access.
$RULES = New-AzNetworkSecurityRuleConfig -Name ‘Default-Allow-RDP’ -Direction Inbound -Priority 1000 -Access Allow -SourceAddressPrefix ‘*’ -SourcePortRange ‘*’ -DestinationAddressPrefix ‘*’ -DestinationPortRange 3389 -Protocol TCP
Now let’s create the NSG, using the following command.
$NSG = New-AzNetworkSecurityGroup -Name $NSGName -ResourceGroupName $RGName -Location $LOCATION -SecurityRules $RULES
Your NSG was successfully created.
Thanks guys and until the next post, where I will demonstrate how to create a virtual machine using all these commands at once.
Joao Paulo Costa