Azure / azure-cli

Azure Command-Line Interface
MIT License
4.02k stars 2.99k forks source link

`az network traffic-manager endpoint update` does not work with `--ids` parameter #27659

Open laurynasr opened 1 year ago

laurynasr commented 1 year ago

Describe the bug

az network traffic-manager endpoint update does not work with --ids parameter, mistakenly replaces the externalEndpoints segment with endpoint name and returns an error:

(BadRequest) The endpoint type '{trafficManagerEndpoint}' is not a valid endpoint type. Valid types are: 'azureEndpoints', 'externalEndpoints', 'nestedEndpoints'.
Code: BadRequest
Message: The endpoint type '{trafficManagerEndpoint}' is not a valid endpoint type. Valid types are: 'azureEndpoints', 'externalEndpoints', 'nestedEndpoints'.

Related command

az network traffic-manager endpoint update --ids /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Network/trafficmanagerprofiles/{trafficManagerProfile}/ExternalEndpoints/{trafficManagerEndpoint} --endpoint-status Disabled

The request is issued to URL https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Network/trafficmanagerprofiles/{trafficManagerProfile}/{trafficManagerEndpoint}/{trafficManagerEndpoint}?api-version=2022-04-01

Errors

(BadRequest) The endpoint type '{trafficManagerEndpoint}' is not a valid endpoint type. Valid types are: 'azureEndpoints', 'externalEndpoints', 'nestedEndpoints'. Code: BadRequest Message: The endpoint type '{trafficManagerEndpoint}' is not a valid endpoint type. Valid types are: 'azureEndpoints', 'externalEndpoints', 'nestedEndpoints'.

Issue script & Debug output

az network traffic-manager endpoint update --ids /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Network/trafficmanagerprofiles/{trafficManagerProfile}/ExternalEndpoints/{trafficManagerEndpoint}  --endpoint-status Disabled --debug
cli.knack.cli: Command arguments: ['network', 'traffic-manager', 'endpoint', 'update', '--ids', '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Network/trafficmanagerprofiles/{trafficManagerProfile}/ExternalEndpoints/{trafficManagerEndpoint}', '--endpoint-status', 'Disabled', '--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 0x000001F4CBF45240>, <function OutputProducer.on_global_arguments at 0x000001F4CC08FEB0>, <function CLIQuery.on_global_arguments at 0x000001F4CC2DD240>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'network': ['azure.cli.command_modules.network', 'azure.cli.command_modules.privatedns']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: network                   0.333       115       457
cli.azure.cli.core: privatedns                0.016        14        60
cli.azure.cli.core: Total (2)                 0.348       129       517
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name                  Load Time    Groups  Commands  Directory
cli.azure.cli.core: Total (0)                 0.000         0         0
cli.azure.cli.core: Loaded 128 groups, 517 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : network traffic-manager endpoint update
cli.azure.cli.core: Command table: network traffic-manager endpoint update
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x000001F4CE9A03A0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\laurynasr\.azure\commands\2023-10-23.13-41-23.network_traffic-manager_endpoint_update.38184.log'.
az_command_data_logger: command args: network traffic-manager endpoint update --ids {} --endpoint-status {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x000001F4CE9A3010>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x000001F4CEA11000>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x000001F4CEA11120>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x000001F4CC08FF40>, <function CLIQuery.handle_query_parameter at 0x000001F4CC2DD2D0>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x000001F4CEA11090>]
cli.azure.cli.core.auth.persistence: build_persistence: location='C:\\Users\\laurynasr\\.azure\\msal_token_cache.bin', encrypt=True
cli.azure.cli.core.auth.binary_cache: load: C:\Users\laurynasr\.azure\msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: openid_config = {'token_endpoint': 'https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/{tenantId}/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': 'https://login.microsoftonline.com/{tenantId}/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/{tenantId}/kerberos', 'tenant_region_scope': 'NA', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'}
msal.application: Broker enabled? False
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
cli.azure.cli.core.auth.msal_authentication: UserCredential.get_token: scopes=('https://management.core.windows.net//.default',), claims=None, kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: 8471176a-4a1e-4aff-a8f0-9148e44fdc22
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Network/trafficmanagerprofiles/{trafficManagerProfile}/{trafficManagerEndpoint}/{trafficManagerEndpoint}?api-version=2022-04-01'
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': 'b5d1b27c-7190-11ee-a99e-ac198e439837'
cli.azure.cli.core.sdk.policies:     'CommandName': 'network traffic-manager endpoint update'
cli.azure.cli.core.sdk.policies:     'ParameterSetName': '--ids --endpoint-status --debug'
cli.azure.cli.core.sdk.policies:     'User-Agent': 'AZURECLI/2.53.0 (MSI) (AAZ) azsdk-python-core/1.26.0 Python/3.10.10 (Windows-10-10.0.22621-SP0)'
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/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Network/trafficmanagerprofiles/{trafficManagerProfile}/{trafficManagerEndpoint}/{trafficManagerEndpoint}?api-version=2022-04-01 HTTP/1.1" 400 220
cli.azure.cli.core.sdk.policies: Response status: 400
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies:     'Cache-Control': 'private'
cli.azure.cli.core.sdk.policies:     'Content-Length': '220'
cli.azure.cli.core.sdk.policies:     'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies:     'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies:     'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies:     'x-ms-request-id': 'b5d1b27c-7190-11ee-a99e-ac198e439837'
cli.azure.cli.core.sdk.policies:     'Server': 'Microsoft-IIS/10.0'
cli.azure.cli.core.sdk.policies:     'X-AspNet-Version': '4.0.30319'
cli.azure.cli.core.sdk.policies:     'X-Powered-By': 'ASP.NET'
cli.azure.cli.core.sdk.policies:     'x-ms-ratelimit-remaining-subscription-reads': '11999'
cli.azure.cli.core.sdk.policies:     'x-ms-correlation-request-id': '626e8fc4-f33f-4e5d-be31-eddda58d7c76'
cli.azure.cli.core.sdk.policies:     'x-ms-routing-request-id': 'CANADACENTRAL:20231023T104124Z:626e8fc4-f33f-4e5d-be31-eddda58d7c76'
cli.azure.cli.core.sdk.policies:     'Date': 'Mon, 23 Oct 2023 10:41:23 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"error":{"code":"BadRequest","message":"The endpoint type '{trafficManagerEndpoint}' is not a valid endpoint type. Valid types are: 'azureEndpoints', 'externalEndpoints', 'nestedEndpoints'."}}
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 663, in execute
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 697, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 333, in __call__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/network/custom.py", line 5425, in update_traffic_manager_endpoint
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_command.py", line 155, in __call__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\lib\site-packages\azure\cli\command_modules\network\aaz_compact\latest\network\traffic_manager\endpoint\__cmds.py", line 969, in _handler
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\lib\site-packages\azure\cli\command_modules\network\aaz_compact\latest\network\traffic_manager\endpoint\__cmds.py", line 1145, in _execute_operations
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\lib\site-packages\azure\cli\command_modules\network\aaz_compact\latest\network\traffic_manager\endpoint\__cmds.py", line 1182, in __call__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_operation.py", line 332, in on_error
azure.core.exceptions.HttpResponseError: (BadRequest) The endpoint type '{trafficManagerEndpoint}' is not a valid endpoint type. Valid types are: 'azureEndpoints', 'externalEndpoints', 'nestedEndpoints'.
Code: BadRequest
Message: The endpoint type '{trafficManagerEndpoint}' is not a valid endpoint type. Valid types are: 'azureEndpoints', 'externalEndpoints', 'nestedEndpoints'.

cli.azure.cli.core.azclierror: (BadRequest) The endpoint type '{trafficManagerEndpoint}' is not a valid endpoint type. Valid types are: 'azureEndpoints', 'externalEndpoints', 'nestedEndpoints'.
Code: BadRequest
Message: The endpoint type '{trafficManagerEndpoint}' is not a valid endpoint type. Valid types are: 'azureEndpoints', 'externalEndpoints', 'nestedEndpoints'.
az_command_data_logger: (BadRequest) The endpoint type '{trafficManagerEndpoint}' is not a valid endpoint type. Valid types are: 'azureEndpoints', 'externalEndpoints', 'nestedEndpoints'.
Code: BadRequest
Message: The endpoint type '{trafficManagerEndpoint}' is not a valid endpoint type. Valid types are: 'azureEndpoints', 'externalEndpoints', 'nestedEndpoints'.
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x000001F4CE9A05E0>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 1.522 seconds (init: 0.292, invoke: 1.230)
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 3835 in cache
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\telemetry\__init__.pyc C:\Users\laurynasr\.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.

Expected behavior

The command should succeed and update the traffic manager endpoint

Environment Summary

azure-cli 2.53.0

core 2.53.0 telemetry 1.1.0

Extensions: authV2 0.1.2

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

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe' Extensions directory 'C:\Users\laurynasr.azure\cliextensions'

Python (Windows) 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)]

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.