Azure / azure-cli

Azure Command-Line Interface
MIT License
4.03k stars 3k forks source link

[CLI + Go SDK] az vmss nic list is not working #27341

Open diyor-uptycs opened 1 year ago

diyor-uptycs commented 1 year ago

Describe the bug

Cannot get network interfaces of a virtual machine scale set using both CLI and Azure SDK for Go.

CLI command

az vmss nic list --resource-group {resource_group} --virtual-machine-scale-set-name {vmss_name} Getting the following response:

cli.azure.cli.core.azclierror: (NotFound) Resource /subscriptions/.../resourceGroups/.../providers/Microsoft.Compute/virtualMachineScaleSets/csm11645 not found.
Code: NotFound
Message: Resource /subscriptions/.../resourceGroups/.../providers/Microsoft.Compute/virtualMachineScaleSets/csm11645 not found.
az_command_data_logger: (NotFound) Resource /subscriptions/.../resourceGroups/.../providers/Microsoft.Compute/virtualMachineScaleSets/csm11645 not found.
Code: NotFound
Message: Resource /subscriptions/.../resourceGroups/.../providers/Microsoft.Compute/virtualMachineScaleSets/csm11645 not found.

The same error in SDK response.

Related command

az vmss nic list --resource-group {resource_group} --virtual-machine-scale-set-name {vmss_name}

Errors

time=2023-09-07T13:12:42Z level=error msg=ListVirtualMachineScaleSetVMNetworkInterfaces errString=GET https://management.azure.com/subscriptions/.../resourceGroups/.../providers/microsoft.Compute/virtualMachineScaleSets/csm4321/virtualMachines/csm4321_3d4d6c0f/networkInterfaces
--------------------------------------------------------------------------------
RESPONSE 404: 404 Not Found
ERROR CODE: NotFound
--------------------------------------------------------------------------------
{
  "error": {
    "code": "NotFound",
    "message": "Resource /subscriptions/.../resourceGroups/.../providers/Microsoft.Compute/virtualMachineScaleSets/csm4321 not found.",
    "details": []
  }
}

Issue script & Debug output

cli.knack.cli: Command arguments: ['vmss', 'nic', 'list', '--resource-group', '...', '--vmss-name', 'csm11645', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7ff408ea31f0>, <function OutputProducer.on_global_arguments at 0x7ff408dbdd30>, <function CLIQuery.on_global_arguments at 0x7ff408d55310>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'vmss': ['azure.cli.command_modules.vm']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: vm                        0.162        59       239
cli.azure.cli.core: Total (1)                 0.162        59       239
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name                  Load Time    Groups  Commands  Directory
cli.azure.cli.core: ai-examples               0.069         1         1  /usr/lib/python3.9/site-packages/azure-cli-extensions/ai-examples
cli.azure.cli.core: Total (1)                 0.069         1         1  
cli.azure.cli.core: Loaded 60 groups, 240 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : vmss nic list
cli.azure.cli.core: Command table: vmss nic list
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7ff4081f8430>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/diyor/.azure/commands/2023-09-07.14-01-10.vmss_nic_list.195.log'.
az_command_data_logger: command args: vmss nic list --resource-group {} --vmss-name {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7ff4081a3040>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7ff4081d30d0>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x7ff40815dee0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7ff408dbddc0>, <function CLIQuery.handle_query_parameter at 0x7ff408d553a0>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7ff40815de50>]
urllib3.connectionpool: Starting new HTTP connection (1): localhost:50342
urllib3.connectionpool: http://localhost:50342 "POST /oauth2/token HTTP/1.1" 200 2154
msrestazure.azure_active_directory: MSI: Retrieving a token from http://localhost:50342/oauth2/token, with payload {'resource': 'https://management.core.windows.net/'}
cli.azure.cli.core.auth.adal_authentication: MSIAuthenticationWrapper.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
urllib3.connectionpool: Starting new HTTP connection (1): localhost:50342
urllib3.connectionpool: http://localhost:50342 "POST /oauth2/token HTTP/1.1" 200 2154
msrestazure.azure_active_directory: MSI: Retrieving a token from http://localhost:50342/oauth2/token, with payload {'resource': 'https://management.core.windows.net/'}
cli.azure.cli.core.auth.adal_authentication: Normalize expires_on: '1694098522' -> 1694098522
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/.../resourceGroups/.../providers/microsoft.Compute/virtualMachineScaleSets/csm11645/networkInterfaces?api-version=2016-03-30'
cli.azure.cli.core.sdk.policies: Request method: 'GET'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies:     'Accept': 'application/json'
cli.azure.cli.core.sdk.policies:     'x-ms-client-request-id': 'ff6c7b18-4d86-11ee-b7f8-a660af0483d1'
cli.azure.cli.core.sdk.policies:     'CommandName': 'vmss nic list'
cli.azure.cli.core.sdk.policies:     'ParameterSetName': '--resource-group --vmss-name --debug'
cli.azure.cli.core.sdk.policies:     'User-Agent': 'AZURECLI/2.52.0 (RPM) (AAZ) azsdk-python-core/1.26.0 Python/3.9.14 (Linux-5.4.0-1109-azure-x86_64-with-glibc2.35) cloud-shell/1.0'
cli.azure.cli.core.sdk.policies:     'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions/.../resourceGroups/.../providers/microsoft.Compute/virtualMachineScaleSets/csm11645/networkInterfaces?api-version=2016-03-30 HTTP/1.1" 404 259
cli.azure.cli.core.sdk.policies: Response status: 404
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies:     'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies:     'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies:     'Content-Length': '259'
cli.azure.cli.core.sdk.policies:     'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies:     'Expires': '-1'
cli.azure.cli.core.sdk.policies:     'x-ms-request-id': '2dc11371-59fd-4c9e-ba0b-e32930f92268'
cli.azure.cli.core.sdk.policies:     'x-ms-correlation-request-id': '289755ed-3a82-4c65-a1be-c53a44fccc71'
cli.azure.cli.core.sdk.policies:     'x-ms-arm-service-request-id': '562a0a60-22ec-456a-99e3-1dc6e254ffb6'
cli.azure.cli.core.sdk.policies:     'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies:     'Server': 'Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0'
cli.azure.cli.core.sdk.policies:     'x-ms-ratelimit-remaining-subscription-reads': '11997'
cli.azure.cli.core.sdk.policies:     'x-ms-routing-request-id': 'SOUTHEASTASIA:20230907T140111Z:289755ed-3a82-4c65-a1be-c53a44fccc71'
cli.azure.cli.core.sdk.policies:     'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies:     'Date': 'Thu, 07 Sep 2023 14:01:10 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {
  "error": {
    "code": "NotFound",
    "message": "Resource /subscriptions/.../resourceGroups/.../providers/Microsoft.Compute/virtualMachineScaleSets/csm11645 not found.",
    "details": []
  }
}
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/usr/lib64/az/lib/python3.9/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 710, in _run_job
    result = list(result)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/aaz/_paging.py", line 87, in __next__
    return next(self._page_iterator)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/aaz/_paging.py", line 43, in __next__
    self._executor(self._next_link)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/aaz/_command.py", line 250, in executor_wrapper
    executor()
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/vm/aaz/latest/vmss/nic/_list.py", line 56, in _execute_operations
    self.NetworkInterfacesListVirtualMachineScaleSetNetworkInterfaces(ctx=self.ctx)()
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/vm/aaz/latest/vmss/nic/_list.py", line 81, in __call__
    return self.on_error(session.http_response)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/aaz/_operation.py", line 329, in on_error
    raise error_type(response=response)
azure.core.exceptions.ResourceNotFoundError: (NotFound) Resource /subscriptions/.../resourceGroups/.../providers/Microsoft.Compute/virtualMachineScaleSets/csm11645 not found.
Code: NotFound
Message: Resource /subscriptions/.../resourceGroups/.../providers/Microsoft.Compute/virtualMachineScaleSets/csm11645 not found.

cli.azure.cli.core.azclierror: (NotFound) Resource /subscriptions/.../resourceGroups/.../providers/Microsoft.Compute/virtualMachineScaleSets/csm11645 not found.
Code: NotFound
Message: Resource /subscriptions/.../resourceGroups/.../providers/Microsoft.Compute/virtualMachineScaleSets/csm11645 not found.
az_command_data_logger: (NotFound) Resource /subscriptions/.../resourceGroups/.../providers/Microsoft.Compute/virtualMachineScaleSets/csm11645 not found.
Code: NotFound
Message: Resource /subscriptions/.../resourceGroups/.../providers/Microsoft.Compute/virtualMachineScaleSets/csm11645 not found.
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7ff4081f8670>]
az_command_data_logger: exit code: 3
cli.__main__: Command ran in 1.186 seconds (init: 0.115, invoke: 1.071)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3874 in cache
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/usr/bin/python3.9 /usr/lib/az/lib/python3.9/site-packages/azure/cli/telemetry/__init__.py /home/diyor/.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.

Expected behavior

A list of network interfaces

Environment Summary

azure-cli 2.52.0

core 2.52.0 telemetry 1.1.0

Extensions: ai-examples 0.2.5 guestconfig 0.1.1 ml 2.19.1 ssh 2.0.1

Dependencies: msal 1.24.0b1 azure-mgmt-resource 23.1.0b2

Python location '/usr/bin/python3.9' Extensions directory '/home/diyor/.azure/cliextensions' Extensions system directory '/usr/lib/python3.9/site-packages/azure-cli-extensions'

Python (Linux) 3.9.14 (main, Feb 8 2023, 03:39:52) [GCC 11.2.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

yonzhan commented 1 year ago

Thank you for opening this issue, we will look into it.