[Compute] Fix #33556: az vm boot-diagnostics get-boot-log: Fix TypeError with azure-mgmt-storage 25.0.0 - #33872
Conversation
… TypeError with azure-mgmt-storage 25.0.0 StorageAccountListKeysResult in azure-mgmt-storage 25.0.0 now inherits from MutableMapping, so `.keys` resolves to the built-in dict.keys method instead of the renamed `keys_property` list. This crashed get_boot_log when a VM uses a custom (non-managed) storage account for boot diagnostics. Also fixes the same pattern in the unused _get_private_config helper, and adds a unit test covering the keys_property credential path and the full download flow. Co-Authored-By: Claude Sonnet 5
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Thank you for your contribution Pavel Dostál (@pdostal)! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
Pull request overview
Fixes a regression in az vm boot-diagnostics get-boot-log caused by azure-mgmt-storage==25.0.0 changing StorageAccountListKeysResult so that .keys resolves to the mapping method instead of the key list, leading to TypeError: 'method' object is not subscriptable for VMs using a custom boot diagnostics storage account.
Changes:
- Update VM boot log retrieval to use
keys_propertyinstead ofkeyswhen reading storage account keys. - Apply the same fix in the
_get_private_confighelper. - Add a unit test asserting
keys_propertyis used to construct theBlobClientcredential.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/vm/custom.py | Switch storage key access from .keys to .keys_property for list_keys results to avoid the MutableMapping .keys() collision. |
| src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py | Add regression unit test validating the boot log path uses keys_property when building the blob client credential. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Hello Teresa Ritorto (@teresaritorto), can you please advice me if this fix makes sense and who should help me to review it? I'm willing to work on it but I can also drop it in favor of #33727. |
Related command
az vm boot-diagnostics get-boot-logDescription
Fixes #33556.
StorageAccountListKeysResultinazure-mgmt-storage25.0.0 now inherits fromMutableMapping, so.keysresolves to the built-indict.keysmethod instead of the renamedkeys_propertylist. This crashedget_boot_logwithTypeError: 'method' object is not subscriptablewhen a VM uses a custom (non-managed) storage account for boot diagnostics. Also fixes the same pattern in the unused_get_private_confighelper.Related to #33727, which addresses the same root cause but additionally adds a
keys_property/keysfallback for olderazure-mgmt-storageversions and touchesbatchai/custom.py. Since this repo pinsazure-mgmt-storage==25.0.0exactly (seesrc/azure-cli/setup.py), that fallback isn't functionally required here, so this PR keeps the fix minimal and scoped to the actual regression.Testing Guide
History Notes
[Compute]
az vm boot-diagnostics get-boot-log: FixTypeError: 'method' object is not subscriptablewhen VM uses a custom storage account for boot diagnostics (regression with azure-mgmt-storage 25.0.0)