azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

Fix `az acr network-rule list` missing virtualNetworkSubnetResourceId

Open Copilot opened this issue 5 months ago • 8 comments

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.

Copilot avatar Jun 27 '26 13:06 Copilot

️✔️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

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

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

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 avatar Jun 27 '26 13:06 azclibot

@copilot the automated CI and live-test review on this PR found failures. Please look into the requested changes here: https://github.com/Azure/azure-cli/pull/33663#pullrequestreview-4585357411 and push a fix.


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

a0x1ab avatar Jun 27 '26 13:06 a0x1ab

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 avatar Jun 27 '26 13:06 azclibot

@copilot the automated CI and live-test review on this PR found failures. Please look into the requested changes here: https://github.com/Azure/azure-cli/pull/33663#pullrequestreview-4585392125 and push a fix.


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

a0x1ab avatar Jun 27 '26 13:06 a0x1ab

acr

yonzhan avatar Jun 27 '26 23:06 yonzhan

@copilot the automated CI and live-test review on this PR found failures. Please look into the requested changes here: https://github.com/Azure/azure-cli/pull/33663#pullrequestreview-4592348233 and push a fix.


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

a0x1ab avatar Jun 29 '26 13:06 a0x1ab

@copilot the automated CI and live-test review on this PR found failures. Please look into the requested changes here: https://github.com/Azure/azure-cli/pull/33663#pullrequestreview-4592348233 and pu...

The CI failure is due to the GitHub PR title not matching the required format. The title needs to be updated to:

[ACR] Fix #33660: `az acr network-rule list`: fix missing virtualNetworkSubnetResourceId

And the PR description should include Fixes #33660 at the top.

I don't have permission to update the PR title directly (gh returns 403). Could you update the PR title and description accordingly? All code changes and the HISTORY.rst entry are already correct.

Copilot avatar Jun 29 '26 13:06 Copilot

@copilot the automated CI and live-test review on this PR found failures. Please look into the requested changes here: https://github.com/Azure/azure-cli/pull/33663#pullrequestreview-4622069914 and push a fix.


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

a0x1ab avatar Jul 03 '26 01:07 a0x1ab

@copilot the automated CI and live-test review on this PR found failures. Please look into the requested changes here: https://github.com/Azure/azure-cli/pull/33663#pullrequestreview-4622069914 and pu...

After investigating all 3 CI failures:

  1. Build failure (Azure.azure-cli) — caused by the credential scanner sub-job failing; the other 90+ sub-jobs passed.

  2. Credential Scanner — our PR diff (HISTORY.rst, network_rule.py, test_acr_network_rule_commands.py) contains no credentials or secret-like values. The scanner is flagging pre-existing base64-encoded TLS certificate chains in Azure async-operation URLs inside test_acr_network_rule.yaml (12 occurrences of MIIHwzCCBqugAwIBAgIQ...). That recording file was not modified by this PR — it already exists in the dev base branch. This is a pre-existing false-positive that affects this PR because the scanner scans the whole repository, not just the diff.

  3. PR title format — the title needs to be updated to:

    [ACR] Fix #33660: `az acr network-rule list`: Fix null `virtualNetworkResourceId` and add `virtualNetworkSubnetResourceId`
    

    and Fixes #33660 should be added at the top of the description. I'm unable to update the PR title via the GitHub API (returns 403). Could you please update the PR title and description directly?

Copilot avatar Jul 03 '26 01:07 Copilot