Skip to content

[VM] fix az vmss extension set not updating existing extension - #33752

Closed
Aditya Pujara (a0x1ab) with Copilot wants to merge 2 commits into
devfrom
copilot/az-vmss-extension-update-fix
Closed

[VM] fix az vmss extension set not updating existing extension#33752
Aditya Pujara (a0x1ab) with Copilot wants to merge 2 commits into
devfrom
copilot/az-vmss-extension-update-fix

Conversation

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Related command
az vmss extension set

Description

Since v2.88.0, az vmss extension set throws (BadRequest) Multiple VMExtensions per handler not supported when the extension already exists, instead of updating it.

Root cause: set_vmss_extension filters out the existing extension before appending the updated one. The filter used the key type_properties_type to match the extension type — a key that is never present in the dict returned by get_vmss_by_aaz (the correct key is type, because VMSSShow._output clears the read-only outer type and client-flattens properties.type as type). Since the filter always evaluated to True, no extension was ever removed, and appending the new one created a duplicate handler, triggering the API error.

Fix: Change the filter key from type_properties_typetype.

# Before (broken — key never matched, old extension never removed)
[x for x in extensions if
 x.get('type_properties_type', '').lower() != extension_name.lower() or
 x.get('publisher', '').lower() != publisher.lower()]

# After (fixed)
[x for x in extensions if
 x.get('type', '').lower() != extension_name.lower() or
 x.get('publisher', '').lower() != publisher.lower()]

A unit test is added to test_custom_vm_commands.py to prevent regression.

Testing Guide

# Update an existing VMSS extension — should succeed without "Multiple VMExtensions" error
az vmss extension set \
  --vmss-name myVMSS \
  --resource-group myRG \
  --name CustomScript \
  --extension-instance-name myScript \
  --version 2.1 \
  --publisher Microsoft.Azure.Extensions \
  --settings '{"commandToExecute": "echo updated"}'

Unit test (no live environment needed):

python -m pytest src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py::TestSetVmssExtension -v

History Notes

[VM] az vmss extension set: Fix updating an existing extension — previously threw BadRequest: Multiple VMExtensions per handler not supported instead of replacing the extension.


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

@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-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI changed the title [WIP] Fix az vmss extension set not updating existing extensions [VM] fix az vmss extension set not updating existing extension Jul 20, 2026
@x-engineering-agent

Copy link
Copy Markdown
Contributor

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

PASS

Selectors: test_custom_vm_commands (module)
PR head ref: copilot/az-vmss-extension-update-fix
PR head sha: 815239d16d0d13757dcd7201d3fcefc5673b4e7b
PR base ref: dev
New test files in PR: false

Changed test files run
src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py

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

Last 80 lines of azdev output

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


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

/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=[
/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":\[\]\}'

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

Test on modules: test_custom_vm_commands

WARNING: RUNNING TESTS LIVE
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 7 items

azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py::TestVmCustom::test_get_access_extension_upgrade_info PASSED [ 14%]
azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py::TestVmCustom::test_get_extension_instance_name PASSED [ 28%]
azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py::TestVmCustom::test_get_extension_instance_name_when_type_none PASSED [ 42%]
azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py::TestVmCustom::test_merge_secrets PASSED [ 57%]
azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py::TestVMBootLog::test_vm_boot_log_handle_unicode PASSED [ 71%]
azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py::TestVMBootLog::test_vm_boot_log_init_storage_sdk PASSED [ 85%]
azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py::TestSetVmssExtension::test_set_vmss_extension_updates_existing PASSED [100%]

- generated xml file: /home/runner/work/issue-sentinel/issue-sentinel/test-output/results.xml -
============================== 7 passed in 0.35s ===============================

Posted by agent-assist live-test workflow.

@x-engineering-agent x-engineering-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI Review Summary — PR #33752

Live test (Tester): ✅ Passed — dispatch_live_test_workflow ran the targeted live test for the changed test file(s) against this PR's head commit and it succeeded.

CI checks: 2 failed, 12 still pending, 70 passed (out of 84 total).

Failed checks

  1. Test Homebrew Formulahttps://github.com/Azure/azure-cli/runs/88397257389
  2. Build Rpm Packages Red Hat Universal Base Image 9 ARM64https://github.com/Azure/azure-cli/runs/88391383327

Please investigate these two failures. If they are caused by this PR's changes (e.g. packaging manifest/spec files, module metadata, or version pins touched by the fix), correct them. If they look like transient/environmental infrastructure failures unrelated to the az vmss extension set fix in this PR (e.g. Homebrew formula sync or RPM build infra issues), please double-check nothing in the diff (setup.py, HISTORY.rst, or packaging config) inadvertently affected them, then note that assessment so a re-run can be requested.


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

@a0x1ab

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: #33752 (review) and push a fix.


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

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Copilot the automated CI and live-test review on this PR found failures. Please look into the requested changes here: #33752 (review) and pu...

Investigated both failures:

  1. Test Homebrew Formula — This runs the installed CLI package tests. The PR only changes custom.py (1 line: type_properties_typetype) and test_custom_vm_commands.py (new unit test). No Homebrew formula, setup.py, HISTORY.rst, or packaging manifest was touched. All 7 unit tests pass locally. This is a transient infrastructure failure unrelated to the PR's diff.

  2. Build Rpm Packages Red Hat Universal Base Image 9 ARM64 — This is an ARM64 RPM build job. Same reasoning applies — no packaging or spec files were modified in this PR.

Both failures are pre-existing infrastructure flakes. A re-run of those two checks should resolve them.

@yonzhan

Copy link
Copy Markdown
Collaborator

VM

@yanzhudd

Copy link
Copy Markdown
Contributor

This issue has been fixed.

@a0x1ab Aditya Pujara (a0x1ab) added X Engineering Agent Reviewed Pull request reviewed by X Engineering Agent and removed azure-client-tools-agent labels Sep 2, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

🔔 Routing this PR to @Azure/act-observability-squad.

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

Labels

act-observability-squad Auto-Assign Auto assign by bot Compute az vm/vmss/image/disk/snapshot X Engineering Agent Reviewed Pull request reviewed by X Engineering Agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'az vmss extension set' does not update an existing extension anymore

4 participants