@@ -157,7 +157,8 @@ details, or when CLI access is unavailable.
157157** When to use:** Automated or repeatable deployment. Reads all logical network definitions
158158from ` networking.logical_networks[] ` in ` variables.yml ` and creates every enabled
159159entry. Entries with ` enabled: false ` are skipped. Already-existing networks are skipped.
160- Run from the management server (toolkit repo root).
160+ Run from the management server (toolkit repo root). Add ` -AssociateNsg ` to attach
161+ NSGs during creation (requires SDN enabled and NSGs from Task 07).
161162
162163** Script:**
163164[ ` Invoke-LogicalNetworks-Orchestrated.ps1 ` ] ( https://github.com/AzureLocal-docs-azl-toolkit/-/blob/main/scripts/deploy/04-cluster-deployment/phase-06-post-deployment/task-08-logical-network-creation/powershell/Invoke-LogicalNetworks-Orchestrated.ps1 )
@@ -201,6 +202,11 @@ scripts/deploy/04-cluster-deployment/phase-06-post-deployment/
201202.PARAMETER WhatIf
202203 Dry-run mode: logs all planned operations without making any changes.
203204
205+ .PARAMETER AssociateNsg
206+ When specified, associates NSGs with logical networks during creation.
207+ Each logical network entry must have an nsg_name field in the config.
208+ Requires SDN enabled on the cluster and NSGs created in Task 07.
209+
204210.PARAMETER LogPath
205211 Override log file path. Default: logs\task-08-logical-network-creation\
206212 <YYYY-MM-DD_HHmmss>_LogicalNetworks.log (relative to CWD).
@@ -217,6 +223,10 @@ scripts/deploy/04-cluster-deployment/phase-06-post-deployment/
217223 # Specific config file:
218224 .\...\Invoke-LogicalNetworks-Orchestrated.ps1 -ConfigPath "configs/infrastructure-azl-demo.yml"
219225
226+ .EXAMPLE
227+ # With NSG association (requires SDN enabled + NSGs from Task 07):
228+ .\...\Invoke-LogicalNetworks-Orchestrated.ps1 -AssociateNsg
229+
220230.NOTES
221231 Requires: powershell-yaml module (Install-Module powershell-yaml -Scope CurrentUser)
222232 Requires: az CLI authenticated (az login)
@@ -229,6 +239,7 @@ param(
229239 [PSCredential]$Credential,
230240 [string[]] $TargetNode = @(),
231241 [switch] $WhatIf,
242+ [switch] $AssociateNsg,
232243 [string] $LogPath = ""
233244)
234245
@@ -535,8 +546,8 @@ foreach ($lnet in $logicalNetworks) {
535546 $createArgs += @("--tags", "displayName=$($lnet.display_name)")
536547 }
537548
538- # Associate NSG if specified (created in Task 07)
539- if ($lnet.nsg_name) {
549+ # Associate NSG if -AssociateNsg switch is set and nsg_name is defined
550+ if ($AssociateNsg -and $ lnet.nsg_name) {
540551 $createArgs += @("--network-security-group", $lnet.nsg_name)
541552 Write-Log " NSG association: $($lnet.nsg_name)"
542553 }
@@ -619,7 +630,10 @@ $custom_location_id = "/subscriptions/a1b2c3d4-e5f6-7890-abcd-ef1234567890/resou
619630
620631# Hyper-V virtual switch name (from Get-VMSwitch on a cluster node)
621632$vm_switch_name = "ConvergedSwitch(hci)"
622-
633+ # ─── NSG Association ─────────────────────────────────────────────────────────────
634+ # Set to $true to associate NSGs with logical networks during creation.
635+ # Requires SDN enabled on the cluster and NSGs created in Task 07.
636+ $associate_nsg = $false
623637# ─── Logical Networks ────────────────────────────────────────────────────────────
624638# ip_allocation_method: "Static" or "Dynamic"
625639# Static — requires address_prefix, default_gateway, ip_pools
@@ -638,7 +652,7 @@ $logical_networks = @(
638652 ip_pools = @(
639653 @{ name = "pool-mgmt-vms"; start = "10.100.0.50"; end = "10.100.0.200"; type = "vm" }
640654 )
641- nsg_name = "nsg-iic-management"
655+ nsg_name = "nsg-iic-management" # only used when $associate_nsg = $true
642656 routes = @()
643657 },
644658
@@ -654,7 +668,7 @@ $logical_networks = @(
654668 ip_pools = @(
655669 @{ name = "pool-prod-vms"; start = "10.200.0.50"; end = "10.200.0.250"; type = "vm" }
656670 )
657- nsg_name = "nsg-iic-production"
671+ nsg_name = "nsg-iic-production" # only used when $associate_nsg = $true
658672 routes = @()
659673 },
660674
@@ -668,7 +682,7 @@ $logical_networks = @(
668682 dns_servers = @("10.100.0.10", "10.100.0.11")
669683 domain_name = "azurelocal.cloud"
670684 }
671- nsg_name = "nsg-iic-avd"
685+ nsg_name = "nsg-iic-avd" # only used when $associate_nsg = $true
672686 routes = @()
673687 }
674688)
0 commit comments