Skip to content

Fix az acr network-rule list missing virtualNetworkSubnetResourceId#33663

Draft
Copilot wants to merge 3 commits into
devfrom
copilot/fix-az-acr-network-rule-list
Draft

Fix az acr network-rule list missing virtualNetworkSubnetResourceId#33663
Copilot wants to merge 3 commits into
devfrom
copilot/fix-az-acr-network-rule-list

Conversation

Copilot AI commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

az acr network-rule list returned virtualNetworkResourceId: null for all virtual network rules because _format_registry_response read rule.get('id'), but the 2021-08-01-preview API returns the field as virtualNetworkSubnetResourceId.

Changes (src/azure-cli/azure/cli/command_modules/acr/network_rule.py):

  • _format_registry_response: Read virtualNetworkSubnetResourceId (fallback to id for backward compat); populate both virtualNetworkResourceId (existing, now correctly valued) and virtualNetworkSubnetResourceId (new) in the output
  • acr_network_rule_add: Use virtualNetworkSubnetResourceId as the field name when appending new rules to match the API contract
  • acr_network_rule_remove: Check virtualNetworkSubnetResourceId (fallback to id) when filtering rules to remove — previously rules were never removed due to the field name mismatch

Before / After:

// Before
"virtualNetworkRules": [{ "action": "Allow", "virtualNetworkResourceId": null }]

// After
"virtualNetworkRules": [{
  "action": "Allow",
  "virtualNetworkResourceId": "/subscriptions/.../subnets/subnet1",
  "virtualNetworkSubnetResourceId": "/subscriptions/.../subnets/subnet1"
}]

Testing Guide

az acr network-rule list -n <acr-name> --subscription <subscription-id>
# virtualNetworkRules entries now include non-null virtualNetworkResourceId
# and the new virtualNetworkSubnetResourceId field

az acr network-rule add -n <acr-name> -g <rg> --vnet-name <vnet> --subnet <subnet>
az acr network-rule remove -n <acr-name> -g <rg> --vnet-name <vnet> --subnet <subnet>
# add/remove continue to work correctly

History Notes

[ACR] az acr network-rule list: Fix virtualNetworkRules entries always showing virtualNetworkResourceId: null; add virtualNetworkSubnetResourceId field to output


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

@azure-client-tools-bot-prd

azure-client-tools-bot-prd Bot commented Jun 27, 2026

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

@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi @copilot,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@azure-client-tools-bot-prd

azure-client-tools-bot-prd Bot commented Jun 27, 2026

Copy link
Copy Markdown
️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

The 2021-08-01-preview API returns virtualNetworkRules items with the
field name `virtualNetworkSubnetResourceId`, but the code was reading
`rule.get('id')` which returns None, causing all virtualNetworkRules
to show `virtualNetworkResourceId: null` in the output.

Changes:
- _format_registry_response: read virtualNetworkSubnetResourceId (with
  id fallback) and map it to both virtualNetworkResourceId (backward
  compat) and virtualNetworkSubnetResourceId in the output
- acr_network_rule_add: use virtualNetworkSubnetResourceId field when
  appending new rules to match the API field name
- acr_network_rule_remove: check virtualNetworkSubnetResourceId (with
  id fallback) when filtering rules to remove
- Update tests to verify virtualNetworkSubnetResourceId is populated

Closes #33660
Copilot AI changed the title [WIP] Fix missing virtualNetworkSubnetResourceId in az acr network-rule list Fix az acr network-rule list missing virtualNetworkSubnetResourceId Jun 27, 2026
Copilot AI requested a review from a0x1ab June 27, 2026 13:34
@azclibot

Copy link
Copy Markdown
Collaborator

Live test results — azdev test --live --series (changed test files only)

PASS

Selectors: test_acr_network_rule_commands (module)
PR head ref: copilot/fix-az-acr-network-rule-list
PR head sha: 0175719602650475675dc6c1c896bed90e6fb0a3
PR base ref: dev
New test files in PR: false

Changed test files run
src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_network_rule_commands.py

Workflow run: https://github.com/Azure/issue-sentinel/actions/runs/28290774388

Last 80 lines of azdev output

=============
| Run Tests |
=============

/home/runner/work/issue-sentinel/issue-sentinel/.venv/bin/az:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  __import__('pkg_resources').require('azure-cli==2.87.0')

=====================
| Discovering Tests |
=====================

/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/identity/tests/latest/test_identity.py:18: SyntaxWarning: invalid escape sequence '\{'
  'resource_restriction_compute': '\{"providers":\["Microsoft.Compute"\]\}',
/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/identity/tests/latest/test_identity.py:19: SyntaxWarning: invalid escape sequence '\{'
  'resource_restriction_empty': '\{"providers":\[\]\}'
/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:13533: SyntaxWarning: invalid escape sequence '\]'
  self.cmd('vmss application set -g {rg} -n {vmss} --app-version-ids {vid1} {vid2} --enable-automatic-upgrade True\]', checks=[

test index updated: /home/runner/.azdev/env_config/home/runner/work/issue-sentinel/issue-sentinel/.venv/test_index/latest.json

Test on modules: test_acr_network_rule_commands

WARNING: RUNNING TESTS LIVE
/home/runner/work/issue-sentinel/issue-sentinel/.venv/bin/az:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  __import__('pkg_resources').require('azure-cli==2.87.0')
The tests are set to run against current profile "latest"
============================= test session starts ==============================
platform linux -- Python 3.12.13, pytest-9.1.1, pluggy-1.6.0 -- /home/runner/work/issue-sentinel/issue-sentinel/.venv/bin/python
cachedir: .pytest_cache
rootdir: /home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli
plugins: forked-1.6.0, xdist-3.8.0
collecting ... collected 1 item

azure-cli/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_network_rule_commands.py::AcrNetworkRuleCommandsTests::test_acr_network_rule PASSED [100%]

- generated xml file: /home/runner/work/issue-sentinel/issue-sentinel/test-output/results.xml -
========================= 1 passed in 88.12s (0:01:28) =========================

Posted by agent-assist live-test workflow.

@azclibot azclibot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI Failure: Check the Format of Pull Request Title and Content

The Check the Format of Pull Request Title and Content CI gate failed (1 error).

Current title: Fix \az acr network-rule list` missing virtualNetworkSubnetResourceId`

The title is missing the required [ACR] component prefix and the colon after the command. Please update the PR title and description to match the required format below.

PR title & description format (required)

This repo enforces a PR format (guide). Please author the PR exactly as follows or CI's Check the Format of Pull Request Title and Content will fail.

Title

  • Start with [ACR] — square brackets [] for a customer-facing change (added to HISTORY.rst), curly {} if not. A bug fix is customer-facing, so use [].
  • Then Fix #<issue>: to link the issue (use the short #N form, not owner/repo#N).
  • Then the affected command wrapped in backticks followed by a colon — e.g. `az vm create`:. ⚠️ The format check fails if the az ... command in the title is not inside backticks.
  • Then a present-tense, capitalized verb (Fix for bug fixes; Add/Change/Deprecate/Remove otherwise) and a concise summary.
  • Recommended title (note the backticks around the command):
[ACR] `az acr network-rule list`: Fix <concise description of the fix>

Description — follow the PR template and fill in:

  • Related command — the az ... command this affects.
  • Description (mandatory) — why the bug happens, what you changed, and the resulting behavior.
  • Testing Guide — example command(s) showing the fix works.
  • History Notes — leave the title to drive the history note, or add extra lines in the same format (component in brackets + the command in backticks), e.g. [ACR] `az <command>`: <note>.
  • Keep the template checklist and tick the items you've satisfied.

Live-test result: ✅ Passed

Please fix the PR title (and description if needed) to satisfy the format gate.


Posted by agent-assist (autonomous bug-fix pipeline).

@a0x1ab

a0x1ab commented Jun 27, 2026

Copy link
Copy Markdown
Member

@copilot the automated CI and live-test review on this PR found failures. Please look into the requested changes here: #33663 (review) and push a fix.


Posted by agent-assist (autonomous bug-fix pipeline).

@azclibot

Copy link
Copy Markdown
Collaborator

Live test results — azdev test --live --series (changed test files only)

PASS

Selectors: test_acr_network_rule_commands (module)
PR head ref: copilot/fix-az-acr-network-rule-list
PR head sha: 888d9c4612c43121ecf0ba3241fde883e03ebb58
PR base ref: dev
New test files in PR: false

Changed test files run
src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_network_rule_commands.py

Workflow run: https://github.com/Azure/issue-sentinel/actions/runs/28291162535

Last 80 lines of azdev output

=============
| Run Tests |
=============

/home/runner/work/issue-sentinel/issue-sentinel/.venv/bin/az:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  __import__('pkg_resources').require('azure-cli==2.87.0')

=====================
| Discovering Tests |
=====================

/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/identity/tests/latest/test_identity.py:18: SyntaxWarning: invalid escape sequence '\{'
  'resource_restriction_compute': '\{"providers":\["Microsoft.Compute"\]\}',
/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/identity/tests/latest/test_identity.py:19: SyntaxWarning: invalid escape sequence '\{'
  'resource_restriction_empty': '\{"providers":\[\]\}'
/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:13533: SyntaxWarning: invalid escape sequence '\]'
  self.cmd('vmss application set -g {rg} -n {vmss} --app-version-ids {vid1} {vid2} --enable-automatic-upgrade True\]', checks=[

test index updated: /home/runner/.azdev/env_config/home/runner/work/issue-sentinel/issue-sentinel/.venv/test_index/latest.json

Test on modules: test_acr_network_rule_commands

WARNING: RUNNING TESTS LIVE
/home/runner/work/issue-sentinel/issue-sentinel/.venv/bin/az:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  __import__('pkg_resources').require('azure-cli==2.87.0')
The tests are set to run against current profile "latest"
============================= test session starts ==============================
platform linux -- Python 3.12.13, pytest-9.1.1, pluggy-1.6.0 -- /home/runner/work/issue-sentinel/issue-sentinel/.venv/bin/python
cachedir: .pytest_cache
rootdir: /home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli
plugins: forked-1.6.0, xdist-3.8.0
collecting ... collected 1 item

azure-cli/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_network_rule_commands.py::AcrNetworkRuleCommandsTests::test_acr_network_rule PASSED [100%]

- generated xml file: /home/runner/work/issue-sentinel/issue-sentinel/test-output/results.xml -
========================= 1 passed in 73.78s (0:01:13) =========================

Posted by agent-assist live-test workflow.

@azclibot azclibot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI Failure: Check the Format of Pull Request Title and Content

The Check the Format of Pull Request Title and Content CI gate failed.

Current title: Fix \az acr network-rule list` missing virtualNetworkSubnetResourceId`

The title must follow the required format. The current title is missing the [ACR] prefix and the Fix #<issue>: link component.

PR title & description format (required)

This repo enforces a PR format (guide). Please author the PR exactly as follows or CI's Check the Format of Pull Request Title and Content will fail.

Title

  • Start with [ACR] — square brackets [] for a customer-facing change (added to HISTORY.rst), curly {} if not. A bug fix is customer-facing, so use [].
  • Then Fix #<issue>: to link the issue (use the short #N form, not owner/repo#N).
  • Then the affected command wrapped in backticks followed by a colon — e.g. `az vm create`:. ⚠️ The format check fails if the az ... command in the title is not inside backticks.
  • Then a present-tense, capitalized verb (Fix for bug fixes; Add/Change/Deprecate/Remove otherwise) and a concise summary.
  • Recommended title (note the backticks around the command):
[ACR] `az acr network-rule list`: Fix <concise description of the fix>

Description — follow the PR template and fill in:

  • Related command — the az ... command this affects.
  • Description (mandatory) — why the bug happens, what you changed, and the resulting behavior.
  • Testing Guide — example command(s) showing the fix works.
  • History Notes — leave the title to drive the history note, or add extra lines in the same format (component in brackets + the command in backticks), e.g. [ACR] `az <command>`: <note>.
  • Keep the template checklist and tick the items you've satisfied.

Please update the PR title to match the required format. If there is no linked issue, use the format:

[ACR] `az acr network-rule list`: Fix virtualNetworkRules always showing virtualNetworkResourceId as null

Also ensure the PR description includes all required sections from the PR template (Related command, Description, Testing Guide, History Notes).


Posted by agent-assist (autonomous bug-fix pipeline).

@a0x1ab

a0x1ab commented Jun 27, 2026

Copy link
Copy Markdown
Member

@copilot the automated CI and live-test review on this PR found failures. Please look into the requested changes here: #33663 (review) and push a fix.


Posted by agent-assist (autonomous bug-fix pipeline).

@yonzhan

yonzhan commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

acr

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants