Skip to content

az monitor log-analytics query fails in AzureChinaCloud with CloudEndpointNotSetException #32631

@GraceZhangUp

Description

@GraceZhangUp

Describe the bug

When running az monitor log-analytics query in Azure China (AzureChinaCloud), the command consistently fails with:

azure.cli.core.cloud.CloudEndpointNotSetException
The exception is thrown during client initialization, before any HTTP request is sent to the Log Analytics service.

This issue occurs across:

Different workspaces
Different KQL queries (e.g. Usage, AzureDiagnostics, StorageBlobLogs)

To Reproduce
Set Azure CLI cloud to Azure China:

az cloud set --name AzureChinaCloud
Login:

az login
Run any Log Analytics query:

az monitor log-analytics query \
--workspace \
--analytics-query "Usage"

Expected behavior
The command should successfully execute the Log Analytics query and return results, the same way it does in Azure Public Cloud.

Actual behavior
The command fails immediately with:

azure.cli.core.cloud.CloudEndpointNotSetException
No HTTP request is sent to the Log Analytics service.

Debug output
Relevant part of the stack trace:

File ".../azext_loganalytics/aaz/latest/monitor/log_analytics/_query.py", line 75
self.QueryExecute(ctx=self.ctx)()

File ".../azure/cli/core/aaz/_operation.py", line 37, in init
self.client = ctx.get_http_client(self.CLIENT_TYPE)

File ".../azure/cli/core/aaz/_client.py", line 75, in init
raise CloudEndpointNotSetException()

azure.cli.core.cloud.CloudEndpointNotSetException

Analysis / Root Cause
Based on the Azure CLI Core implementation in:

azure/cli/core/_profile.py
Azure CLI resolves service endpoints from the current cloud profile:

endpoint = cloud.endpoints.get(endpoint_name)
if not endpoint:
raise CloudEndpointNotSetException()
In AzureChinaCloud, the cloud profile does not appear to define the required endpoint for Log Analytics Query used by the log-analytics extension (AAZ-based).

As a result:

Client initialization fails
CloudEndpointNotSetException is raised
The query is never executed
This suggests a missing or incomplete Log Analytics endpoint definition for AzureChinaCloud, rather than a user configuration or query issue.

Environment
Azure CLI version:

az version

2.78.0

Extension:

log-analytics 1.0.0b1
OS:Windows 11

Cloud: AzureChinaCloud

Other Log Analytics access methods (e.g. REST API / PowerShell) work in Azure China
This appears to be a gap in Sovereign Cloud support for the new AAZ-based log-analytics extension
**Ask
Please confirm whether this is a known issue and advise:

Whether a missing endpoint definition for AzureChinaCloud needs to be added
Or if there is a recommended workaround until full support is available**

Related command

az monitor log-analytics query --workspace XXXXX --analytics-query 'kusto query' --debug

Errors

PS C:\Users<USER>\AppData\Roaming\Code\User> az monitor log-analytics query --workspace <WORKSPACE_ID> --analytics-query <KQL_QUERY> --debug

cli.knack.cli: Command arguments:
['monitor', 'log-analytics', 'query',
'--workspace', '<WORKSPACE_ID>',
'--analytics-query', '<KQL_QUERY>',
'--debug']

cli.knack.cli: init debug log: Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [...]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []

cli.azure.cli.core: Modules found from index for 'monitor':
['azure.cli.command_modules.monitor', 'azext_loganalytics']

cli.azure.cli.core: Loading command modules:
Name Load Time Groups Commands
monitor 1.729 23 70

cli.azure.cli.core: Loading extensions:
Name Load Time Groups Commands Directory
log-analytics 0.018 2 1 C:\Users<USER>.azure\cliextensions\log-analytics

cli.azure.cli.core: Loaded 23 groups, 71 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : monitor log-analytics query
cli.azure.cli.core: Command table: monitor log-analytics query

cli.azure.cli.core.azlogging:
metadata file logging enabled - writing logs to:
C:\Users<USER>.azure\commands<TIMESTAMP>.monitor_log-analytics_query.log

az_command_data_logger:
command args: monitor log-analytics query --workspace {} --analytics-query {} --debug

az_command_data_logger:
extension name: log-analytics
extension version: 1.0.0b

Issue script & Debug output

PS C:\Users<USER>\AppData\Roaming\Code\User> az monitor log-analytics query --workspace <WORKSPACE_ID> --analytics-query <KQL_QUERY> --debug

cli.knack.cli: Command arguments:
['monitor', 'log-analytics', 'query',
'--workspace', '<WORKSPACE_ID>',
'--analytics-query', '<KQL_QUERY>',
'--debug']

cli.knack.cli: init debug log: Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [...]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []

cli.azure.cli.core: Modules found from index for 'monitor':
['azure.cli.command_modules.monitor', 'azext_loganalytics']

cli.azure.cli.core: Loading command modules:
Name Load Time Groups Commands
monitor 1.729 23 70

cli.azure.cli.core: Loading extensions:
Name Load Time Groups Commands Directory
log-analytics 0.018 2 1 C:\Users<USER>.azure\cliextensions\log-analytics

cli.azure.cli.core: Loaded 23 groups, 71 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : monitor log-analytics query
cli.azure.cli.core: Command table: monitor log-analytics query

cli.azure.cli.core.azlogging:
metadata file logging enabled - writing logs to:
C:\Users<USER>.azure\commands<TIMESTAMP>.monitor_log-analytics_query.log

az_command_data_logger:
command args: monitor log-analytics query --workspace {} --analytics-query {} --debug

az_command_data_logger:
extension name: log-analytics
extension version: 1.0.0b

Expected behavior

The command should successfully execute the Log Analytics query and return results, the same way it does in Azure Public Cloud.

Environment Summary

Cloud:
AzureChinaCloud

OS:
Windows (PowerShell)

Azure CLI:
2.78.0

Extension:
log-analytics 1.0.0b1

Additional context

No response

Metadata

Metadata

Labels

Accountaz login/accountAuto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamMonitoraz monitorcustomer-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