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
4 changes: 4 additions & 0 deletions src/ssh/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Release History
===============
2.1.0
-----
* Migrate code from Azure SDK to AAZ based commands for compute operations (VM)
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

Release note wording: consider hyphenating "AAZ-based" (compound modifier) for readability/consistency.

Suggested change
* Migrate code from Azure SDK to AAZ based commands for compute operations (VM)
* Migrate code from Azure SDK to AAZ-based commands for compute operations (VM)

Copilot uses AI. Check for mistakes.

2.0.6
-----
* Remove msrestazure dependency
Expand Down
15 changes: 8 additions & 7 deletions src/ssh/azext_ssh/ip_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure.cli.core.commands import client_factory
from azure.cli.core import profiles
from azure.mgmt.core.tools import parse_resource_id

from knack import log
Expand All @@ -13,17 +11,20 @@


def get_ssh_ip(cmd, resource_group, vm_name, use_private_ip):
compute_client = client_factory.get_mgmt_service_client(cmd.cli_ctx, profiles.ResourceType.MGMT_COMPUTE)
vm_client = compute_client.virtual_machines
from .aaz.latest.network.public_ip import Show as PublicIpShow
from .aaz.latest.network.nic import Show as InterfaceShow
from azure.cli.command_modules.vm.aaz.latest.vm import Show as VMShow

vm = vm_client.get(resource_group, vm_name)
command_args = {
'resource_group': resource_group,
'vm_name': vm_name
}
vm = VMShow(cli_ctx=cmd.cli_ctx)(command_args=command_args)

private_ips = []

for nic_ref in vm.network_profile.network_interfaces:
parsed_id = parse_resource_id(nic_ref.id)
for nic_ref in vm.get('networkProfile', {}).get('networkInterfaces', []):
parsed_id = parse_resource_id(nic_ref.get('id'))
get_args = {
'name': parsed_id['name'],
'resource_group': parsed_id['resource_group']
Expand Down
15 changes: 8 additions & 7 deletions src/ssh/azext_ssh/target_os_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,20 @@ def handle_target_os_type(cmd, op_info):


def _get_azure_vm_os(cmd, resource_group_name, vm_name):
from azure.cli.core.commands import client_factory
from azure.cli.core import profiles
vm = None
from azure.cli.command_modules.vm.aaz.latest.vm import Show as VMShow
os_type = None
# pylint: disable=broad-except
try:
compute_client = client_factory.get_mgmt_service_client(cmd.cli_ctx, profiles.ResourceType.MGMT_COMPUTE)
vm = compute_client.virtual_machines.get(resource_group_name, vm_name)
command_args = {
'resource_group': resource_group_name,
'vm_name': vm_name
}
vm = VMShow(cli_ctx=cmd.cli_ctx)(command_args=command_args)
except Exception:
return None

if vm and vm.storage_profile and vm.storage_profile.os_disk and vm.storage_profile.os_disk.os_type:
os_type = vm.storage_profile.os_disk.os_type
if vm and vm.get('storageProfile', {}).get('osDisk', {}).get('osType'):
os_type = vm['storageProfile']['osDisk']['osType']
Comment on lines +66 to +67
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

Add/update unit tests for _get_azure_vm_os to cover the new AAZ-based VM retrieval (successful OS type extraction and the exception path). test_target_os_utils.py currently covers Arc/VMware but not Azure VM, so this change can regress silently if the AAZ output shape or invocation changes.

Suggested change
if vm and vm.get('storageProfile', {}).get('osDisk', {}).get('osType'):
os_type = vm['storageProfile']['osDisk']['osType']
if vm:
os_type = vm.get('storageProfile', {}).get('osDisk', {}).get('osType')

Copilot uses AI. Check for mistakes.

return os_type

Expand Down
2 changes: 1 addition & 1 deletion src/ssh/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from setuptools import setup, find_packages

VERSION = "2.0.6"
VERSION = "2.1.0"

CLASSIFIERS = [
'Development Status :: 4 - Beta',
Expand Down
Loading