Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/azure-cli/azure/cli/command_modules/sqlvm/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,10 @@ def create_ama_and_dcra(cmd, curr_subscription, resource_group_name,
dcra_url = f"{base_url}{dcra_name}{api_version}"
if not does_name_exist(cmd, dcra_url):
break
from azure.cli.command_modules.vm.custom import get_vm
from azure.cli.command_modules.vm.custom import get_vm_by_aaz

vm = get_vm(
cmd,
resource_group_name,
sql_virtual_machine_name,
'instanceView')
amainstall = build_ama_install_resource(
sql_virtual_machine_name, vm.location)
vm = get_vm_by_aaz(cmd, resource_group_name, sql_virtual_machine_name, 'instanceView')
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

Switching from get_vm (management SDK) to get_vm_by_aaz changes the underlying VM GET to AAZ’s API version (currently 2025-04-01). The existing sqlvm scenario test recording test_sqlvm_mgmt_assessment.yaml includes a VM GET at api-version=2024-11-01, so playback is likely to break unless recordings are re-generated (or the call is adjusted to keep the previous api-version).

Copilot uses AI. Check for mistakes.
amainstall = build_ama_install_resource(sql_virtual_machine_name, vm.get('location'))
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

get_vm_by_aaz returns a deserialized dict; using vm.get('location') will silently pass None into the ARM template if the key is missing (leading to a later deployment error that’s harder to diagnose). Prefer failing fast with vm['location'] or explicitly validating and raising a clear error. This matches existing usage patterns in azure/cli/command_modules/vm/custom.py where callers do vm['location'] after get_vm_by_aaz (e.g., around vm/custom.py:1292-1307).

Suggested change
amainstall = build_ama_install_resource(sql_virtual_machine_name, vm.get('location'))
amainstall = build_ama_install_resource(sql_virtual_machine_name, vm['location'])

Copilot uses AI. Check for mistakes.

master_template.add_resource(amainstall)

Expand Down
Loading