Skip to content
Merged
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
10 changes: 5 additions & 5 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5977,15 +5977,15 @@ def _set_data_source_for_workspace(cmd, os_type, resource_group_name, workspace_

def execute_query_for_vm(cmd, client, resource_group_name, vm_name, analytics_query, timespan=None):
"""Executes a query against the Log Analytics workspace linked with a vm."""
vm = get_vm(cmd, resource_group_name, vm_name)
vm = get_vm_by_aaz(cmd, resource_group_name, vm_name)
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 (mgmt SDK) to get_vm_by_aaz changes the underlying REST api-version used for the VM GET request (AAZ vm show targets 2025-04-01). This will likely break VCR playback for existing vm monitor log show test recordings captured with an older api-version, so the recordings should be re-generated/updated.

Suggested change
vm = get_vm_by_aaz(cmd, resource_group_name, vm_name)
vm = get_vm(cmd, resource_group_name, vm_name)

Copilot uses AI. Check for mistakes.
workspace = None
extension_resources = vm.resources or []
extension_resources = vm.get('resources', [])
for resource in extension_resources:
if resource.name == "MicrosoftMonitoringAgent" or resource.name == "OmsAgentForLinux":
workspace = resource.settings.get('workspaceId', None)
if resource.get('name') in (_WINDOWS_OMS_AGENT_EXT, _LINUX_OMS_AGENT_EXT):
workspace = resource.get('settings', {}).get('workspaceId', None)
if workspace is None:
raise CLIError('Cannot find the corresponding log analytics workspace. '
'Please check the status of log analytics workpsace.')
'Please check the status of log analytics workspace.')
return client.query_workspace(workspace, analytics_query, timespan=timespan)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6927,7 +6927,7 @@ interactions:
User-Agent:
- AZURECLI/2.71.0 azsdk-python-core/1.31.0 Python/3.10.11 (Windows-10-10.0.26100-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_create_with_monitor000001/providers/Microsoft.Compute/virtualMachines/monitorvm?api-version=2024-11-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_create_with_monitor000001/providers/Microsoft.Compute/virtualMachines/monitorvm?api-version=2025-04-01
response:
body:
string: "{\r\n \"name\": \"monitorvm\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vm_create_with_monitor000001/providers/Microsoft.Compute/virtualMachines/monitorvm\",\r\n
Expand Down