Skip to content

Commit 4cff9fe

Browse files
{Compute} az vmss application: Migrate command group to aaz-based implementation (#32783)
1 parent 5cc0fee commit 4cff9fe

8 files changed

+169
-196
lines changed

src/azure-cli/azure/cli/command_modules/vm/commands.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,13 @@ def load_command_table(self, _):
402402
g.custom_command('identity assign', 'assign_vmss_identity', validator=process_assign_identity_namespace)
403403
g.custom_command('identity remove', 'remove_vmss_identity', validator=process_remove_identity_namespace, is_preview=True)
404404
g.custom_show_command('identity show', 'show_vmss_identity')
405-
406405
g.custom_command('deallocate', 'deallocate_vmss', supports_no_wait=True)
407406

407+
with self.command_group('vmss application', operation_group='virtual_machine_scale_sets') as g:
408+
g.custom_command('set', 'set_vmss_applications', validator=process_set_applications_namespace)
409+
g.custom_command('list', 'list_vmss_applications')
410+
408411
with self.command_group('vmss', compute_vmss_sdk, operation_group='virtual_machine_scale_sets') as g:
409-
g.custom_command('application set', 'set_vmss_applications', validator=process_set_applications_namespace, min_api='2021-07-01')
410-
g.custom_command('application list', 'list_vmss_applications', min_api='2021-07-01')
411412
g.custom_command('create', 'create_vmss', transform=DeploymentOutputLongRunningOperation(self.cli_ctx, 'Starting vmss create'), supports_no_wait=True, table_transformer=deployment_validate_table_format, validator=process_vmss_create_namespace, exception_handler=handle_template_based_exception)
412413
g.custom_command('get-instance-view', 'get_vmss_instance_view', table_transformer='{ProvisioningState:statuses[0].displayStatus, PowerState:statuses[1].displayStatus}')
413414
g.custom_command('list-instance-connection-info', 'list_vmss_instance_connection_info')

src/azure-cli/azure/cli/command_modules/vm/custom.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6343,12 +6343,16 @@ def _output(self, *args, **kwargs):
63436343

63446344

63456345
def list_vmss_applications(cmd, vmss_name, resource_group_name):
6346-
client = _compute_client_factory(cmd.cli_ctx)
6346+
from .operations.vmss import VMSSShow
63476347
try:
6348-
vmss = client.virtual_machine_scale_sets.get(resource_group_name, vmss_name)
6348+
command_args = {
6349+
'resource_group': resource_group_name,
6350+
'vm_scale_set_name': vmss_name
6351+
}
6352+
vmss = VMSSShow(cli_ctx=cmd.cli_ctx)(command_args=command_args)
63496353
except ResourceNotFoundError:
63506354
raise ResourceNotFoundError('Could not find vmss {}.'.format(vmss_name))
6351-
return vmss.virtual_machine_profile.application_profile
6355+
return vmss.get('virtualMachineProfile', {}).get('applicationProfile', {})
63526356

63536357

63546358
# region Restore point collection

src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_vmss_application_enable_automatic_upgrade.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6942,7 +6942,7 @@ interactions:
69426942
User-Agent:
69436943
- AZURECLI/2.79.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26200-SP0)
69446944
method: GET
6945-
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_test_vm_vmss_application_enable_automatic_upgrade000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss000005?api-version=2024-11-01
6945+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_test_vm_vmss_application_enable_automatic_upgrade000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss000005?api-version=2025-04-01
69466946
response:
69476947
body:
69486948
string: "{\r\n \"name\": \"vmss000005\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_test_vm_vmss_application_enable_automatic_upgrade000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss000005\",\r\n

src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vmss_add_application.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ interactions:
995995
User-Agent:
996996
- AZURECLI/2.79.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26200-SP0)
997997
method: GET
998-
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss1?api-version=2024-11-01
998+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss1?api-version=2025-04-01
999999
response:
10001000
body:
10011001
string: "{\r\n \"name\": \"vmss1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss1\",\r\n

src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vmss_add_application_empty_version_ids.yaml

Lines changed: 153 additions & 185 deletions
Large diffs are not rendered by default.

src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vmss_add_application_with_config_override.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ interactions:
13321332
User-Agent:
13331333
- AZURECLI/2.79.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26200-SP0)
13341334
method: GET
1335-
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss1?api-version=2024-11-01
1335+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss1?api-version=2025-04-01
13361336
response:
13371337
body:
13381338
string: "{\r\n \"name\": \"vmss1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss1\",\r\n

src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vmss_add_application_with_order_application.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ interactions:
949949
User-Agent:
950950
- AZURECLI/2.79.0 azsdk-python-core/1.35.0 Python/3.10.11 (Windows-10-10.0.26200-SP0)
951951
method: GET
952-
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss1?api-version=2024-11-01
952+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss1?api-version=2025-04-01
953953
response:
954954
body:
955955
string: "{\r\n \"name\": \"vmss1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss1\",\r\n

src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13123,7 +13123,7 @@ def test_vmss_add_application_empty_version_ids(self, resource_group):
1312313123
})
1312413124

1312513125
# Prepare VMSS
13126-
self.cmd('vmss create -l eastus -g {rg} -n {vmss} --authentication-type password --admin-username admin123 '
13126+
self.cmd('vmss create -l westus -g {rg} -n {vmss} --authentication-type password --admin-username admin123 '
1312713127
'--admin-password PasswordPassword1! --image Win2022Datacenter --orchestration-mode Flexible --vm-sku Standard_D2s_v3')
1312813128

1312913129
self.cmd('vmss application set -g {rg} -n {vmss} --app-version-ids')

0 commit comments

Comments
 (0)