Task 07 — Configure Network Security Groups
DOCUMENT CATEGORY: Implementation Runbook — Task SCOPE: Phase 06 — Post-Deployment | Azure Local PURPOSE: Create NSGs that will be associated with logical networks in Task 08 MASTER REFERENCE: Network Security Groups PREREQUISITE: SDN must be enabled (Task 01)
Status: Active
Overview
With SDN enabled (Task 01), Network Security Groups provide micro-segmentation for Azure Local
VMs. NSGs must be created before logical networks so they can be associated at logical network
creation time (Task 08) using the --network-security-group parameter.
NSGs only apply to Azure Local VMs deployed from Azure interfaces (Azure Portal, Azure CLI, ARM Templates).
NSGs do NOT apply to:
- Hyper-V VMs deployed locally
- VMs managed by SCVMM
- AKS workloads
NSG Concepts
Rule Components
| Component | Description |
|---|---|
| Priority | 100-4096 (lower = higher priority) |
| Direction | Inbound or Outbound |
| Source | IP address, CIDR, Service Tag, or * |
| Destination | IP address, CIDR, Service Tag, or * |
| Protocol | TCP, UDP, ICMP, or * |
| Port | Single port, range, or * |
| Action | Allow or Deny |
Default Rules
NSGs include implicit default rules:
- AllowVnetInBound (Priority 65000) — Allow intra-VNet traffic
- AllowAzureLoadBalancerInBound (Priority 65001) — Allow health probes
- DenyAllInBound (Priority 65500) — Deny all other inbound
- AllowVnetOutBound (Priority 65000) — Allow outbound to VNet
- AllowInternetOutBound (Priority 65001) — Allow outbound to Internet
- DenyAllOutBound (Priority 65500) — Deny all other outbound
Values from infrastructure.yml
The script reads these keys from infrastructure.yml (schema 5). Each key, with its type, default and example, is in the variables reference.
azure.tenant_id, azure.subscription_id, azure.resource_group, azure.location, azure.custom_location, tags, sdn.enabled
networking.network_security_groups[]: name
rules[]: name, priority, direction, access, protocol, source_address_prefixes, destination_address_prefixes,
source_port_ranges, destination_port_ranges, description
IIC NSG Design
Three NSGs aligned with the IIC logical networks:
nsg-iic-management
For ln-iic01-management-100 — admin access only from management CIDR.
| Rule | Priority | Direction | Port | Source | Action |
|---|---|---|---|---|---|
| Allow-RDP-Management | 100 | Inbound | 3389 | 10.100.0.0/24 | Allow |
| Allow-WinRM | 110 | Inbound | 5985-5986 | 10.100.0.0/24 | Allow |
| Allow-SSH | 120 | Inbound | 22 | 10.100.0.0/24 | Allow |
| Allow-HTTPS-WAC | 130 | Inbound | 443 | 10.100.0.0/24 | Allow |
| Deny-All-Inbound | 4000 | Inbound | * | * | Deny |
nsg-iic-production
For ln-iic01-production-200 — web traffic from any, RDP from management only.
| Rule | Priority | Direction | Port | Source | Action |
|---|---|---|---|---|---|
| Allow-HTTPS | 100 | Inbound | 443 | * | Allow |
| Allow-HTTP | 110 | Inbound | 80 | * | Allow |
| Allow-RDP-Management | 200 | Inbound | 3389 | 10.100.0.0/24 | Allow |
| Deny-All-Inbound | 4000 | Inbound | * | * | Deny |
nsg-iic-avd
For ln-iic01-avd-300 — RDP from management, outbound for AVD agent.
| Rule | Priority | Direction | Port | Source | Action |
|---|---|---|---|---|---|
| Allow-RDP-Internal | 100 | Inbound | 3389 | 10.100.0.0/24 | Allow |
| Allow-AVD-Agent | 110 | Outbound | 443 | * | Allow |
| Deny-All-Inbound | 4000 | Inbound | * | * | Deny |
Execution Options
- Azure Portal
- Orchestrated Script
- Azure CLI
Create a Network Security Group
- Navigate to Azure Portal → Azure Arc → Azure Local → your cluster
- Go to Networking → Network Security Groups
- Click + Create
- Configure:
- Name:
nsg-iic-management - Custom Location: Select the cluster's custom location
- Name:
- Click Review + Create → Create
Add Security Rules
- Open the NSG resource
- Go to Settings → Inbound security rules
- Click + Add
- Configure each rule per the tables above
- Click Add
Repeat for nsg-iic-production and nsg-iic-avd.
NSGs will be associated with logical networks in Task 08 — Logical Network Creation.
PowerShell
When to use: Run the task from a management workstation or a pipeline. The script reads
infrastructure.ymland carries no values of its own.
Script
| Script | What it does |
|---|---|
scripts/deploy/04-cluster-deployment/phase-06-post-deployment/task-07-configure-nsgs/powershell/New-NetworkSecurityGroup.ps1 | Creates the Azure Local network security groups, and their rules, that networking.network_security_groups of infrastructure.yml lists. Supports -WhatIf. |
Requires: PowerShell 7.
Run
./New-NetworkSecurityGroup.ps1 -InfrastructureFile ./infrastructure.yml -WhatIf
Azure CLI
When to use: Run the task from a host that has the Azure CLI and not the Az PowerShell modules. The script is PowerShell 7 that calls
az; it readsinfrastructure.ymland carries no values of its own.
Script
| Script | What it does |
|---|---|
scripts/deploy/04-cluster-deployment/phase-06-post-deployment/task-07-configure-nsgs/azurecli/New-NetworkSecurityGroup.azcli.ps1 | Creates the Azure Local network security groups, and their rules, that networking.network_security_groups of infrastructure.yml lists, with the Azure CLI. Supports -WhatIf. |
Requires: PowerShell 7 and the Azure CLI, signed in with az login --tenant <azure.tenant_id>. Needs the Azure CLI extension stack-hci-vm (az extension add --name stack-hci-vm); the script does not install it.
SDN enabled by Azure Arc must be on (sdn.enabled true), or the script stops with exit code 2 and creates nothing; it does not turn SDN on. A group needs at least one rule, and the script refuses a group without rules. Run it before the logical network script of Task 08. Nothing is deleted: an existing rule that differs from the file is reported.
Run
./New-NetworkSecurityGroup.azcli.ps1 -InfrastructureFile ./infrastructure.yml -WhatIf
./New-NetworkSecurityGroup.azcli.ps1 -InfrastructureFile ./infrastructure.yml
Common NSG Patterns
Web Server NSG
| Rule | Direction | Port | Source | Action |
|---|---|---|---|---|
| Allow-HTTPS | Inbound | 443 | * | Allow |
| Allow-HTTP | Inbound | 80 | * | Allow |
| Allow-RDP-Mgmt | Inbound | 3389 | Management CIDR | Allow |
| Deny-All | Inbound | * | * | Deny |
Database Server NSG
| Rule | Direction | Port | Source | Action |
|---|---|---|---|---|
| Allow-SQL | Inbound | 1433 | App Server CIDR | Allow |
| Allow-RDP-Mgmt | Inbound | 3389 | Management CIDR | Allow |
| Deny-All | Inbound | * | * | Deny |
Application Server NSG
| Rule | Direction | Port | Source | Action |
|---|---|---|---|---|
| Allow-App-Port | Inbound | 8080 | Web Server CIDR | Allow |
| Allow-RDP-Mgmt | Inbound | 3389 | Management CIDR | Allow |
| Deny-All | Inbound | * | * | Deny |
NIC Configuration Note
If you provision multiple static NICs on an Azure Local VM, all NICs receive the default gateway by default.
Resolution: Remove the default gateway from secondary NICs to prevent:
- Asymmetric networking
- Packet loss
- Unpredictable network behavior
# Inside the VM - remove default gateway from secondary NIC
Remove-NetRoute -InterfaceAlias "Ethernet 2" -DestinationPrefix "0.0.0.0/0" -Confirm:$false
Verification
List NSGs
az stack-hci-vm network nsg list --resource-group rg-iic-platform-01 --subscription <subscription-id> -o table
List NSG Rules
az stack-hci-vm network nsg rule list --nsg-name nsg-iic-management --resource-group rg-iic-platform-01 --subscription <subscription-id> -o table
Day 2 Operations
For ongoing NSG management (adding/removing rules, associating/dissociating from networks, troubleshooting), see Phase 01: SDN Operations — Task 02: Configure NSGs.
Alternatives
The procedures in this task use the methods shown in the tabs above. The toolkit is PowerShell 7 only and has no Bash scripts. A few tasks that act on Azure also have an Azure CLI script written in PowerShell. The script status page of the toolkit lists which task has which script.
Troubleshooting
| Issue | Possible Cause | Resolution |
|---|---|---|
| Configuration fails | Incorrect parameters | Verify variable values in infrastructure.yml |
| Permission denied | Insufficient RBAC role | Check Azure role assignments |
Navigation
| ← Previous | Task 06 — VM Image Downloads |
| ↑ Phase Index | Phase 06 — Post-Deployment Index |
| → Next | Task 08 — Logical Network Creation |
Version Control
| Version | Date | Author | Changes |
|---|---|---|---|
| 1.0.0 | 2025-07-25 | Azure Local Cloud | Initial release — NSG creation before logical networks |