Skip to main content
Version: 1.0.0

Task 06: Network Security Groups

Runbook Azure

DOCUMENT CATEGORY: Runbook
SCOPE: NSG deployment and association
PURPOSE: Secure management and bastion subnets with NSG rules
MASTER REFERENCE: Microsoft Learn - NSG Overview

Status: Active

Overview

This task creates two Network Security Groups (NSGs) and associates them with the management subnet and AzureBastionSubnet. These NSGs enforce least-privilege network access for Bastion traffic, CI/CD runner access, and on-premises connectivity.

Task Classification

Execution Target: Azure-Only (control-plane API operation) Tab Profile: 3 tabs — Azure Portal · Azure CLI / PowerShell · Standalone Script

Terraform Reference

Module: azurelocal-toolkit File: nsg.tf Mode: Management

Components Created

ResourceName PatternPurpose
NSG (Management)nsg-azrl-{env}-{region}-01Management subnet security
NSG (Bastion)nsg-bastion-{env}-{region}-01AzureBastionSubnet security
Subnet Association (2x)Bind NSGs to subnets

Management NSG Rules

PriorityNameDirectionSourceDestination PortsAction
110Bastion-SSH-RDP-InboundInboundAzureBastionSubnet CIDR22, 3389Allow
120Azure Local Cloud-Runners-SSH-InboundInboundCI/CD runner subnet22Allow
130Azure-Local-OnPrem-InboundInboundOn-prem mgmt + OOB CIDRs*Allow

Bastion NSG Rules (Microsoft Required)

PriorityNameDirectionSourceDestination PortsAction
120AllowHttpsInboundInboundInternet443Allow
130AllowGatewayManagerInboundInboundGatewayManager443Allow
140AllowAzureLoadBalancerInboundInboundAzureLoadBalancer443Allow
150AllowBastionHostCommunicationInboundInboundVirtualNetwork80, 5701Allow
120AllowSSHRDPOutboundOutbound*22, 3389Allow
130AllowAzureCloudOutboundOutbound*443Allow
140AllowBastionCommunicationOutboundOutboundVirtualNetwork5701, 8080Allow
150AllowSessionOutboundOutbound*80Allow
4090DenyAllOutboundOutbound**Deny

Prerequisites

  • Task 01: Virtual Network completed — Subnets exist
  • On-premises management and OOB CIDRs confirmed
  • CI/CD runner subnet CIDR confirmed (if applicable)

Variables from variables.yml

VariableConfig PathExample (IIC)
Subscription IDazure.subscriptions.<name>.id(per environment)
Resource Groupnetwork.azure_vnets.management.resource_grouprg-azrlmgmt-azl-eus-01
Bastion Subnet CIDRnetwork.azure_vnets.management.subnets.bastion.cidr10.250.1.64/26
Management Subnet CIDRnetwork.azure_vnets.management.subnets.management.cidr10.250.1.32/27

Single Subscription Model

Landing Zone Placement

FieldValueConfig Path
SubscriptionCustomer subscriptionazure.subscriptions.<name>.id
Resource Grouprg-azrlmgmt-{env}-{region}-01network.azure_vnets.management.resource_group
Management NSGnsg-azrl-{env}-{region}-01Derived from naming convention
Bastion NSGnsg-bastion-{env}-{region}-01Derived from naming convention

Execution Options

Azure Portal

When to use: Learning Azure Local, single deployment, prefer visual interface

Procedure — Management NSG

  1. Create NSG:
  • Search for Network security groups+ Create | Field | Value | Source | |-------|-------|--------| | Name | nsg-azrl-{env}-{region}-01 | Naming convention | | Region | Your region | azure.region | | Resource Group | Management RG | network.azure_vnets.management.resource_group |
  1. Add Inbound Rules — Navigate to Inbound security rules+ Add for each:

Rule 1: Bastion SSH/RDP

FieldValue
SourceIP Addresses
Source IPAzureBastionSubnet CIDR
Destination port ranges22, 3389
ProtocolAny
ActionAllow
Priority110
NameBastion-SSH-RDP-Inbound

Rule 2: CI/CD Runners SSH

FieldValue
SourceIP Addresses
Source IPCI/CD runner subnet CIDR
Destination port ranges22
Priority120
NameAzure Local Cloud-Runners-SSH-Inbound

Rule 3: On-Prem Inbound

FieldValue
SourceIP Addresses
Source IPsOn-prem mgmt CIDR, OOB CIDR
Destination port ranges*
Priority130
NameAzure-Local-OnPrem-Inbound
  1. Associate NSG to Management Subnet:
  • NSG → Subnets+ Associate → Select VNet and management subnet

Procedure — Bastion NSG

  1. Create Bastion NSG:
  • Create second NSG named nsg-bastion-{env}-{region}-01
  1. Add Required Bastion Rules: Add all inbound/outbound rules per the Bastion NSG Rules table above. These are Microsoft-required for Bastion to function.

  2. Associate NSG to AzureBastionSubnet:

  • NSG → Subnets+ Associate → Select AzureBastionSubnet

Validation

  • Both NSGs created with correct rules
  • Management NSG associated with management subnet
  • Bastion NSG associated with AzureBastionSubnet
  • Bastion connectivity still works (Task 05)

Validation

  • Management NSG has 3 inbound rules
  • Bastion NSG has all required rules (9 rules)
  • Both NSGs associated with correct subnets
  • Bastion connectivity still works

CAF/WAF Landing Zone Model

In the CAF/WAF model, NSGs follow the same pattern but are deployed in the Connectivity subscription where the VNet resides.

Landing Zone Placement

FieldValueConfig Path
SubscriptionConnectivity subscriptionazure.subscriptions.connectivity.id
Resource Grouprg-azrlconn-{env}-{region}-01network.azure_vnets.management.resource_group

Execution Options

Azure Portal

Follow the same procedure as Single Subscription → Azure Portal, targeting the Connectivity subscription.

Validation

  • NSGs in Connectivity subscription
  • Associated with correct subnets

Validation

  • NSGs deployed in Connectivity subscription
  • Subnet associations correct

Troubleshooting

IssueRoot CauseRemediation
Bastion stops working after NSGMissing required Bastion rulesAdd all Microsoft-required Bastion inbound/outbound rules
SSH from runner failsPriority or CIDR mismatchVerify CI/CD subnet CIDR in rule 120
On-prem cannot reach Azure VMsNSG blocking on-prem to mgmtVerify on-prem CIDRs in rule 130
DenyAllOutbound blocks BastionBastion outbound rules missingEnsure outbound rules 120-150 exist before DenyAll at 4090


Alternatives

The procedures in this task use the scripted methods shown in the tabs above. Additional deployment methods including Azure CLI and Bash scripts are available in the azurelocal-toolkit repository under scripts/deploy/.

MethodDescription
Azure CLIPowerShell-based Azure CLI scripts for Azure resource operations
BashLinux/macOS compatible shell scripts for pipeline environments
PreviousUpNext
Task 05: Azure BastionManual Deployment IndexTask 07: NAT Gateway

Version Control

  • Created: 2025-09-15 by Hybrid Cloud Solutions
  • Last Updated: 2026-03-03 by Hybrid Cloud Solutions
  • Version: 4.0.0
  • Tags: azure-local, nsg, networking, security
  • Keywords: NSG, network security group, firewall rules, subnet security, Bastion NSG
  • Author: Hybrid Cloud Solutions

Version Control

VersionDateAuthorChanges
1.0.02025-03-25Azure Local CloudInitial release