Skip to content

az network private-dns zone list fails with wrong error message #29154

@SorenHN

Description

@SorenHN

Describe the bug

When calling az network private-dns zone list --subscription <SUBSCRIPTION_NAME> with a subscription which exists but does not contain a private dns zone, I get any error message indicating the subscription does not exist.
This is incorrect, the error message should instead indicate that no dns zones was found in the given subscription.

You could also argue that no error message should be displayed, but instead an empty list should be returned as the result.

Related command

az network private-dns zone list

Errors

(BadRequest) The specified subscription <GUID> does not exist
Code: BadRequest
Message: The specified subscription <GUID> does not exist

Issue script & Debug output

cli.knack.cli: Command arguments: ['network', 'private-dns', 'zone', 'list', '-g', '<RESOURCE_GROUP>', '--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 0x0000012FFE2F45E0>, <function OutputProducer.on_global_arguments at 0x0000012FFE4919E0>, <function CLIQuery.on_global_arguments at 0x0000012FFE4C3560>]
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.285       115       453
cli.azure.cli.core: privatedns                0.016        14        63
cli.azure.cli.core: Total (2)                 0.301       129       516
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, 516 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : network private-dns zone list
cli.azure.cli.core: Command table: network private-dns zone list
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x0000012F813E9EE0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\<USER_NAME>\.azure\commands\2024-06-12.11-27-41.network_private-dns_zone_list.25092.log'.
az_command_data_logger: command args: network private-dns zone list -g {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x0000012F8144C2C0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x0000012F8144C360>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x0000012F8144C4A0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x0000012FFE491A80>, <function CLIQuery.handle_query_parameter at 0x0000012FFE4C3600>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x0000012F8144C400>]
cli.azure.cli.core.auth.persistence: build_persistence: location='C:\\Users\\<USER_NAME>\\.azure\\msal_token_cache.bin', encrypt=True
cli.azure.cli.core.auth.binary_cache: load: C:\Users\<USER_NAME>\.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/3edc1f09-0806-41b0-af0b-50944799113a/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/3edc1f09-0806-41b0-af0b-50944799113a/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/3edc1f09-0806-41b0-af0b-50944799113a/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/3edc1f09-0806-41b0-af0b-50944799113a/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/3edc1f09-0806-41b0-af0b-50944799113a/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/3edc1f09-0806-41b0-af0b-50944799113a/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/3edc1f09-0806-41b0-af0b-50944799113a/kerberos', 'tenant_region_scope': 'EU', '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: e100001e-ca36-432d-8d6b-d3f0c79dc2e0
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.Network/privateDnsZones?api-version=2018-09-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': '041b03d4-289e-11ef-9a9c-fc5cee2537b0'
cli.azure.cli.core.sdk.policies:     'CommandName': 'network private-dns zone list'
cli.azure.cli.core.sdk.policies:     'ParameterSetName': '-g --debug'
cli.azure.cli.core.sdk.policies:     'User-Agent': 'AZURECLI/2.56.0 (MSI) (AAZ) azsdk-python-core/1.28.0 Python/3.11.5 (Windows-10-10.0.22631-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/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.Network/privateDnsZones?api-version=2018-09-01 HTTP/1.1" 400 112
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': '112'
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': '041b03d4-289e-11ef-9a9c-fc5cee2537b0'
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-resource-requests': '499'
cli.azure.cli.core.sdk.policies:     'x-ms-ratelimit-remaining-subscription-resource-entities-read': '60000'
cli.azure.cli.core.sdk.policies:     'x-ms-correlation-request-id': '0be25245-3f8f-4a95-8f3f-cea8f5282c79'
cli.azure.cli.core.sdk.policies:     'x-ms-routing-request-id': 'GERMANYWESTCENTRAL:20240612T092742Z:0be25245-3f8f-4a95-8f3f-cea8f5282c79'
cli.azure.cli.core.sdk.policies:     'X-Cache': 'CONFIG_NOCACHE'
cli.azure.cli.core.sdk.policies:     'X-MSEdge-Ref': 'Ref A: C7A7BBCDA4BB467FA8184D332162E2DD Ref B: HEL01EDGE1506 Ref C: 2024-06-12T09:27:41Z'
cli.azure.cli.core.sdk.policies:     'Date': 'Wed, 12 Jun 2024 09:27:41 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"code":"BadRequest","message":"The specified subscription <SUBSCRIPTION_ID> does not exist"}
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 710, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_paging.py", line 87, in __next__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_paging.py", line 43, in __next__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_command.py", line 250, in executor_wrapper
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/privatedns/aaz/latest/network/private_dns/zone/_list.py", line 57, in _execute_operations
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/privatedns/aaz/latest/network/private_dns/zone/_list.py", line 84, 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 specified subscription <SUBSCRIPTION_ID> does not exist
Code: BadRequest
Message: The specified subscription <SUBSCRIPTION_ID> does not exist

cli.azure.cli.core.azclierror: (BadRequest) The specified subscription <SUBSCRIPTION_ID> does not exist
Code: BadRequest
Message: The specified subscription <SUBSCRIPTION_ID> does not exist
az_command_data_logger: (BadRequest) The specified subscription <SUBSCRIPTION_ID> does not exist
Code: BadRequest
Message: The specified subscription <SUBSCRIPTION_ID> does not exist
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x0000012F813EA160>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 1.295 seconds (init: 0.230, invoke: 1.065)
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 3605 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\<USER_NAME>\.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.

Expected behavior

An empty list is returned instead of an error message.

Environment Summary

azure-cli 2.56.0 *

core 2.56.0 *
telemetry 1.1.0

Extensions:
account 0.2.5

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\SørenHerskindNielsen.azure\cliextensions'

Python (Windows) 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)]

Additional context

No response

Metadata

Metadata

Assignees

Labels

Auto-AssignAuto assign by botAuto-ResolveAuto resolve by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamNetworkaz network vnet/lb/nic/dns/etc...act-quality-productivity-squadcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions