Understanding and Setting up Azure NSGs with PowerShell

Adam Bertram
Microsoft Azure
Published in
9 min readJan 19, 2021

--

Originally published at https://adamtheautomator.com by Adam Listek on January 19, 2021.

Azure Network Security Groups or Azure NSGs allow you to filter network traffic both inbound and outbound, from one or more Azure resources. If you’re ever needed to prevent access to an Azure resource, you must understand how NSGs work.

In this article, you’re going to learn the purpose of the Azure NSG and how to get them set up with the PowerShell scripting language.

Prerequisites

  • An Azure resource to target. This tutorial will be using a pay-as-you-go subscription and a Windows Server 2019 Azure virtual machine.
  • PowerShell 7+. Earlier version of PowerShell may work but this tutorial is using PowerShell 7.0.1 for configuration.
  • The Azure Az module PowerShell module

Understanding Azure NSGs

Think of an Azure NSG as a firewall. A firewall consists of rules defining actions to take on incoming and outgoing traffic called rulesets. Firewalls typically come with default rulesets which are rules that dictate what can and can’t traverse through the firewall; Azure NSGs have similar.

Unlike traditional firewalls, Azure NSGs also have a cloud concept called service tags. Services tags are Azure’s way of abstracting address ranges to make them easier to manage.

--

--

Adam Bertram
Microsoft Azure

A 20-year veteran of IT, crypto geek, content creator, consultant and overall problem solver.