Skip to content

{Network} Optimize import logic in network module#32838

Draft
ReaNAiveD wants to merge 22 commits intoAzure:devfrom
ReaNAiveD:network-optimization
Draft

{Network} Optimize import logic in network module#32838
ReaNAiveD wants to merge 22 commits intoAzure:devfrom
ReaNAiveD:network-optimization

Conversation

@ReaNAiveD
Copy link
Member

@ReaNAiveD ReaNAiveD commented Feb 24, 2026

Related command

az network --help

Description

Lazy-load AAZ commands for az network via directory-tree navigation

The original commands.py used a dict-based registration pattern that eagerly imported every AAZ command class at module load time. Running any az network subcommand — or even az network --help — caused all command classes across all network subgroups to be imported and instantiated, regardless of which subcommand the user actually invoked.

Changes:

Replaced the monolithic registration in commands.py with a directory-tree layout under operations/latest/network/, where each command lives in its own file (e.g., _create.py, _list.py). The core function _load_aaz_by_path() navigates this tree guided by CLI args at runtime, so only the relevant subtree is ever imported.

  • commands.py no longer contains any AAZ imports or registrations
  • Each command/command-group is discovered on-demand from the filesystem
  • Updated the help parser to display command groups that have no eagerly-loaded child commands, since subcommands in subgroups are now intentionally deferred to avoid unnecessary imports

⚠️WARNING: Current Azure CLI builds with AAZ Compact enabled. The refactor should be merged along with a build pipeline update!

Result:

Current Azure CLI on DevBox:
image

Optimized Network --help on DevBox:
image


We update the import logic of aaz modules and refactor aaz-based customization into structure of aaz commands.

Testing Guide

History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change
[Component Name 2] az command b: Add some customer-facing feature


This checklist is used to make sure that common guidelines for a pull request are followed.

@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Feb 24, 2026

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Feb 24, 2026

❌AzureCLI-BreakingChangeTest
❌network
rule cmd_name rule_message suggest_message
1007 - ParaRemove network cross-region-lb address-pool update cmd network cross-region-lb address-pool update removed parameter admin_state please add back parameter admin_state for cmd network cross-region-lb address-pool update
1007 - ParaRemove network cross-region-lb rule create cmd network cross-region-lb rule create removed parameter backend_pool please add back parameter backend_pool for cmd network cross-region-lb rule create
1007 - ParaRemove network cross-region-lb rule update cmd network cross-region-lb rule update removed parameter backend_pool please add back parameter backend_pool for cmd network cross-region-lb rule update
1007 - ParaRemove network lb address-pool update cmd network lb address-pool update removed parameter admin_state please add back parameter admin_state for cmd network lb address-pool update
1007 - ParaRemove network lb address-pool update cmd network lb address-pool update removed parameter vnet please add back parameter vnet for cmd network lb address-pool update
1007 - ParaRemove network lb frontend-ip create cmd network lb frontend-ip create removed parameter vnet_name please add back parameter vnet_name for cmd network lb frontend-ip create
1007 - ParaRemove network lb frontend-ip update cmd network lb frontend-ip update removed parameter vnet_name please add back parameter vnet_name for cmd network lb frontend-ip update
1007 - ParaRemove network lb rule create cmd network lb rule create removed parameter backend_pools please add back parameter backend_pools for cmd network lb rule create
1007 - ParaRemove network lb rule update cmd network lb rule update removed parameter backend_pools please add back parameter backend_pools for cmd network lb rule update
⚠️ 1006 - ParaAdd network cross-region-lb address-pool address add cmd network cross-region-lb address-pool address add added parameter ip_address
⚠️ 1006 - ParaAdd network cross-region-lb address-pool address add cmd network cross-region-lb address-pool address add added parameter subnet
⚠️ 1006 - ParaAdd network cross-region-lb address-pool address add cmd network cross-region-lb address-pool address add added parameter virtual_network
⚠️ 1009 - ParaPropRemove network cross-region-lb address-pool address add cmd network cross-region-lb address-pool address add update parameter frontend_ip_address: removed property required=True
⚠️ 1006 - ParaAdd network cross-region-lb address-pool address update cmd network cross-region-lb address-pool address update added parameter ip_address
⚠️ 1006 - ParaAdd network cross-region-lb address-pool address update cmd network cross-region-lb address-pool address update added parameter subnet
⚠️ 1006 - ParaAdd network cross-region-lb address-pool address update cmd network cross-region-lb address-pool address update added parameter virtual_network
⚠️ 1006 - ParaAdd network cross-region-lb address-pool update cmd network cross-region-lb address-pool update added parameter tunnel_interfaces
⚠️ 1006 - ParaAdd network cross-region-lb frontend-ip create cmd network cross-region-lb frontend-ip create added parameter gateway_lb
⚠️ 1006 - ParaAdd network cross-region-lb frontend-ip create cmd network cross-region-lb frontend-ip create added parameter private_ip_address_version
⚠️ 1006 - ParaAdd network cross-region-lb frontend-ip create cmd network cross-region-lb frontend-ip create added parameter private_ip_address
⚠️ 1006 - ParaAdd network cross-region-lb frontend-ip create cmd network cross-region-lb frontend-ip create added parameter private_ip_allocation_method
⚠️ 1006 - ParaAdd network cross-region-lb frontend-ip create cmd network cross-region-lb frontend-ip create added parameter subnet
⚠️ 1006 - ParaAdd network cross-region-lb frontend-ip update cmd network cross-region-lb frontend-ip update added parameter gateway_lb
⚠️ 1006 - ParaAdd network cross-region-lb frontend-ip update cmd network cross-region-lb frontend-ip update added parameter private_ip_address_version
⚠️ 1006 - ParaAdd network cross-region-lb frontend-ip update cmd network cross-region-lb frontend-ip update added parameter private_ip_address
⚠️ 1006 - ParaAdd network cross-region-lb frontend-ip update cmd network cross-region-lb frontend-ip update added parameter private_ip_allocation_method
⚠️ 1006 - ParaAdd network cross-region-lb frontend-ip update cmd network cross-region-lb frontend-ip update added parameter subnet
⚠️ 1006 - ParaAdd network cross-region-lb rule create cmd network cross-region-lb rule create added parameter backend_address_pools
⚠️ 1006 - ParaAdd network cross-region-lb rule create cmd network cross-region-lb rule create added parameter disable_outbound_snat
⚠️ 1006 - ParaAdd network cross-region-lb rule create cmd network cross-region-lb rule create added parameter enable_tcp_reset
⚠️ 1006 - ParaAdd network cross-region-lb rule create cmd network cross-region-lb rule create added parameter idle_timeout_in_minutes
⚠️ 1009 - ParaPropRemove network cross-region-lb rule create cmd network cross-region-lb rule create update parameter backend_port: removed property required=True
⚠️ 1009 - ParaPropRemove network cross-region-lb rule create cmd network cross-region-lb rule create update parameter frontend_port: removed property required=True
⚠️ 1009 - ParaPropRemove network cross-region-lb rule create cmd network cross-region-lb rule create update parameter protocol: removed property required=True
⚠️ 1006 - ParaAdd network cross-region-lb rule update cmd network cross-region-lb rule update added parameter backend_address_pools
⚠️ 1006 - ParaAdd network cross-region-lb rule update cmd network cross-region-lb rule update added parameter disable_outbound_snat
⚠️ 1006 - ParaAdd network cross-region-lb rule update cmd network cross-region-lb rule update added parameter enable_tcp_reset
⚠️ 1006 - ParaAdd network cross-region-lb rule update cmd network cross-region-lb rule update added parameter idle_timeout_in_minutes
⚠️ 1006 - ParaAdd network lb address-pool address add cmd network lb address-pool address add added parameter frontend_ip_address
⚠️ 1009 - ParaPropRemove network lb address-pool address add cmd network lb address-pool address add update parameter ip_address: removed property required=True
⚠️ 1006 - ParaAdd network lb address-pool address update cmd network lb address-pool address update added parameter frontend_ip_address
⚠️ 1006 - ParaAdd network lb address-pool update cmd network lb address-pool update added parameter vnet_id
⚠️ 1006 - ParaAdd network lb frontend-ip create cmd network lb frontend-ip create added parameter private_ip_allocation_method
⚠️ 1006 - ParaAdd network lb frontend-ip update cmd network lb frontend-ip update added parameter private_ip_allocation_method
⚠️ 1006 - ParaAdd network lb rule create cmd network lb rule create added parameter backend_address_pools
⚠️ 1009 - ParaPropRemove network lb rule create cmd network lb rule create update parameter backend_port: removed property required=True
⚠️ 1009 - ParaPropRemove network lb rule create cmd network lb rule create update parameter frontend_port: removed property required=True
⚠️ 1009 - ParaPropRemove network lb rule create cmd network lb rule create update parameter protocol: removed property required=True
⚠️ 1006 - ParaAdd network lb rule update cmd network lb rule update added parameter backend_address_pools

Please submit your Breaking Change Pre-announcement ASAP if you haven't already. Please note:

  • Breaking changes can only be merged during the designated breaking change window
  • A pre-announcement must be released at least one month in advance

For more details on how to introduce breaking changes, refer to the documentation: azure-cli/doc/how_to_introduce_breaking_changes.md

@yonzhan
Copy link
Collaborator

yonzhan commented Feb 24, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants