MSDN Documentation

Network Security Groups (NSGs) and Application Security Groups (ASGs) in Azure

Network Security Groups (NSGs) and Application Security Groups (ASGs) are fundamental components of Azure's network security capabilities. They allow you to define granular access control policies for your Azure resources, helping to segment your network and protect your applications.

What are Network Security Groups (NSGs)?

A Network Security Group (NSG) is a collection of security rules that can be associated with one or more virtual network interfaces (NICs), virtual machines, or subnets. NSGs act as a basic firewall, allowing or denying network traffic to Azure resources.

Key Features of NSGs:

NSG Rules Components:

Example NSG Rule (Allow HTTP inbound to a subnet):


{
  "name": "AllowHttpInbound",
  "properties": {
    "priority": 300,
    "protocol": "*",
    "access": "Allow",
    "direction": "Inbound",
    "sourceAddressPrefix": "*",
    "sourcePortRange": "*",
    "destinationAddressPrefix": "*",
    "destinationPortRange": "80",
    "description": "Allow inbound HTTP traffic"
  }
}
            

What are Application Security Groups (ASGs)?

Application Security Groups (ASGs) enable you to group virtual machines and their network interfaces based on application role. You can then use these ASGs as source or destination in NSG rules, simplifying the management of complex security policies.

Benefits of Using ASGs:

Scenario: Imagine you have web servers and database servers. You can create an ASG for 'WebServers' and another for 'DatabaseServers'. Then, you can create an NSG rule to allow traffic from 'WebServers' to 'DatabaseServers' on port 1433 (for SQL Server), instead of specifying individual IP addresses.

How ASGs and NSGs Work Together:

You create ASGs and associate NICs with them. Then, in your NSG rules, you can use the ASGs as source or destination security principals. This allows you to define rules like:

Implementing NSGs and ASGs:

You can implement NSGs and ASGs using the Azure portal, Azure CLI, Azure PowerShell, or ARM templates.

Azure Portal Steps (High-level):

  1. Navigate to the Azure portal.
  2. Create or select a Network Security Group.
  3. Define inbound and outbound security rules, using IP addresses, service tags, or ASGs.
  4. Create Application Security Groups.
  5. Associate NICs of your virtual machines with the relevant ASGs.
  6. Associate the NSG with the appropriate subnets or NICs.
Note: NSGs are stateless by default for outbound rules if not defined in conjunction with inbound rules. However, modern NSG implementations are stateful for both inbound and outbound traffic based on defined rules.

Best Practices:

By effectively utilizing Network Security Groups and Application Security Groups, you can significantly enhance the security posture of your Azure network infrastructure.