Repository: Azure/azure-cli

Issue:
az vmss get-instance-view returns model view when specifying all VMs
If you run the following to get the instance view for all VMs in a scale set:
```
az vmss get-instance-view -g rgname -n vmssname --instance-id \*
```
CLI does:
```
requests.packages.urllib3.connectionpool : https://management.azure.com:443 "GET /subscriptions/<subid>/resourceGroups/rgname/providers/Microsoft.Compute/virtualMachineScaleSets/vmssname/virtualMachines?api-version=2016-04-30-preview”
```
which returns the model view for all VMs.

It should be doing:
```
requests.packages.urllib3.connectionpool : https://management.azure.com:443 "GET /subscriptions/<subid>/resourceGroups/rgname/providers/Microsoft.Compute/virtualMachineScaleSets/vmssname/virtualMachines?$expand=instanceView&$select=instanceView&api-version=2016-04-30-preview”
```
The instance-view command works fine if you just query one VM.


Discussion:
codecov-io: # [Codecov](https://codecov.io/gh/Azure/azure-cli/pull/2467?src=pr&el=h1) Report
> Merging [#2467](https://codecov.io/gh/Azure/azure-cli/pull/2467?src=pr&el=desc) into [master](https://codecov.io/gh/Azure/azure-cli/commit/d79710730933432d2c8ccd722d31fbbf75845ce0?src=pr&el=desc) will **increase** coverage by `0.01%`.
> The diff coverage is `n/a`.


```diff
@@            Coverage Diff             @@
##           master    #2467      +/-   ##
==========================================
+ Coverage   72.44%   72.45%   +0.01%     
==========================================
  Files         362      362              
  Lines       19547    19547              
  Branches     2865     2865              
==========================================
+ Hits        14160    14162       +2     
+ Misses       4475     4472       -3     
- Partials      912      913       +1
```


| [Impacted Files](https://codecov.io/gh/Azure/azure-cli/pull/2467?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [...zure-cli-vm/azure/cli/command_modules/vm/custom.py](https://codecov.io/gh/Azure/azure-cli/compare/d79710730933432d2c8ccd722d31fbbf75845ce0...47b28ad2c4278b0ec927820cf60d22de1d63b596?src=pr&el=tree#diff-c3JjL2NvbW1hbmRfbW9kdWxlcy9henVyZS1jbGktdm0vYXp1cmUvY2xpL2NvbW1hbmRfbW9kdWxlcy92bS9jdXN0b20ucHk=) | `74.5% <ø> (+0.22%)` | :white_check_mark: |
| [...dback/azure/cli/command_modules/feedback/custom.py](https://codecov.io/gh/Azure/azure-cli/compare/d79710730933432d2c8ccd722d31fbbf75845ce0...47b28ad2c4278b0ec927820cf60d22de1d63b596?src=pr&el=tree#diff-c3JjL2NvbW1hbmRfbW9kdWxlcy9henVyZS1jbGktZmVlZGJhY2svYXp1cmUvY2xpL2NvbW1hbmRfbW9kdWxlcy9mZWVkYmFjay9jdXN0b20ucHk=) | `34.69% <0%> (ø)` | :white_check_mark: |
| [src/azure-cli-core/azure/cli/core/_util.py](https://codecov.io/gh/Azure/azure-cli/compare/d79710730933432d2c8ccd722d31fbbf75845ce0...47b28ad2c4278b0ec927820cf60d22de1d63b596?src=pr&el=tree#diff-c3JjL2F6dXJlLWNsaS1jb3JlL2F6dXJlL2NsaS9jb3JlL191dGlsLnB5) | `66.66% <0%> (ø)` | :white_check_mark: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Azure/azure-cli/pull/2467?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Azure/azure-cli/pull/2467?src=pr&el=footer). Last update [d797107...47b28ad](https://codecov.io/gh/Azure/azure-cli/compare/d79710730933432d2c8ccd722d31fbbf75845ce0...47b28ad2c4278b0ec927820cf60d22de1d63b596?src=pr&el=footer&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Patch:
diff --git a/src/command_modules/azure-cli-resource/azure/cli/command_modules/resource/_help.py b/src/command_modules/azure-cli-resource/azure/cli/command_modules/resource/_help.py
index 3df308105..bcff81d87 100644
--- a/src/command_modules/azure-cli-resource/azure/cli/command_modules/resource/_help.py
+++ b/src/command_modules/azure-cli-resource/azure/cli/command_modules/resource/_help.py
@@ -160,7 +160,7 @@ helps['feature'] = """
 
 helps['group'] = """
     type: group
-    short-summary: Manage resource groups.
+    short-summary: Manage resource groups and template deployments.
 """
 
 helps['group exists'] = """
diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/custom.py b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/custom.py
index da2c20927..22e31d7a2 100644
--- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/custom.py
+++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/custom.py
@@ -1291,7 +1291,9 @@ def get_vmss_instance_view(resource_group_name, vm_scale_set_name, instance_id=N
     if instance_id:
         if instance_id == '*':
             return client.virtual_machine_scale_set_vms.list(resource_group_name,
-                                                             vm_scale_set_name)
+                                                             vm_scale_set_name,
+                                                             select='instanceView',
+                                                             expand='instanceView')
         else:
             return client.virtual_machine_scale_set_vms.get_instance_view(resource_group_name,
                                                                           vm_scale_set_name,


Test patch:
diff --git a/src/command_modules/azure-cli-vm/tests/test_custom_vm_commands.py b/src/command_modules/azure-cli-vm/tests/test_custom_vm_commands.py
index 54809d1d5..b6ff5ac31 100644
--- a/src/command_modules/azure-cli-vm/tests/test_custom_vm_commands.py
+++ b/src/command_modules/azure-cli-vm/tests/test_custom_vm_commands.py
@@ -14,7 +14,7 @@ from azure.cli.command_modules.vm.custom import (_get_access_extension_upgrade_i
                                                  _LINUX_ACCESS_EXT,
                                                  _WINDOWS_ACCESS_EXT)
 from azure.cli.command_modules.vm.custom import \
-    (attach_unmanaged_data_disk, detach_data_disk)
+    (attach_unmanaged_data_disk, detach_data_disk, get_vmss_instance_view)
 from azure.cli.command_modules.vm.disk_encryption import enable, disable
 from azure.mgmt.compute.models import (NetworkProfile, StorageProfile, DataDisk, OSDisk,
                                        OperatingSystemTypes, InstanceViewStatus,
@@ -196,6 +196,17 @@ class Test_Vm_Custom(unittest.TestCase):
         mock_vm_set.assert_called_once_with(vm)
         self.assertEqual(len(vm.storage_profile.data_disks), 0)
 
+    @mock.patch('azure.cli.command_modules.vm.custom._compute_client_factory')
+    def test_show_vmss_instance_view(self, factory_mock):
+        vm_client = mock.MagicMock()
+        factory_mock.return_value = vm_client
+
+        # execute
+        get_vmss_instance_view('rg1', 'vmss1', '*')
+        # assert
+        vm_client.virtual_machine_scale_set_vms.list.assert_called_once_with('rg1', 'vmss1', expand='instanceView',
+                                                                             select='instanceView')
+
     # pylint: disable=line-too-long
     @mock.patch('azure.cli.command_modules.vm.disk_encryption._compute_client_factory', autospec=True)
     @mock.patch('azure.cli.command_modules.vm.disk_encryption._get_keyvault_key_url', autospec=True)