To add an inbound or outbound security rule to an Azure VM means you have to add the rule to the NSG assigned to the NIC that was created earlier. Fortunately, doing that isn't difficult.
To add an inbound or outbound rule, you need to run the following cmdlet:
Add-AzureRmNetworkSecurityRuleConfig -NetworkSecurityGroup $NSG -Name HTTP-Rule -Description "Allow HTTP" -Access Allow -Protocol Tcp-Direction Inbound -Priority 1020 -SourceAddressPrefix *-SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 80
After that, you have to save the preceding configuration by running the following cmdlet:
Set-AzureRmNetworkSecurityGroup -NetworkSecurityGroup $NSG