Skip to content

[Log Analytics] Fix #10318: az monitor log-analytics query: Add AzureChinaCloud host template for log-analytics data-plane client - #10319

Open
Aditya Pujara (a0x1ab) wants to merge 5 commits into
Azure:mainfrom
a0x1ab:agent-assist/azure-azure-cli-extensions-issue-10318-d548602a3e3c
Open

[Log Analytics] Fix #10318: az monitor log-analytics query: Add AzureChinaCloud host template for log-analytics data-plane client#10319
Aditya Pujara (a0x1ab) wants to merge 5 commits into
Azure:mainfrom
a0x1ab:agent-assist/azure-azure-cli-extensions-issue-10318-d548602a3e3c

Conversation

@a0x1ab

@a0x1ab Aditya Pujara (a0x1ab) commented Sep 10, 2026

Copy link
Copy Markdown
Member

🤖 PR Validation — ️✔️ All clear

Breaking Changes
️✔️ None

Description

Fixes #10318.

az monitor log-analytics query fails in AzureChinaCloud (and AzureUSGovernment) with CloudEndpointNotSetException because _CLOUD_HOST_TEMPLATES only contained an entry for AzureCloud, causing _build_base_url to return None.

Changes

  • azext_loganalytics/aaz/latest/_clients.py: Add AzureChinaCloud and AzureUSGovernment entries to _CLOUD_HOST_TEMPLATES:
    _CLOUD_HOST_TEMPLATES = {
        CloudNameEnum.AzureCloud: "https://api.loganalytics.io",
        CloudNameEnum.AzureChinaCloud: "https://api.loganalytics.azure.cn",
        CloudNameEnum.AzureUSGovernment: "https://api.loganalytics.us",
    }
  • setup.py: Bump version 1.0.0b11.0.0b2
  • HISTORY.rst: Add changelog entry

Related command

az monitor log-analytics query

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install azdev required)
  • My extension version conforms to the Extension version schema

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

Generation source

Azure/aaz#1085

…d AzureChinaCloud host template for log-analytics data-plane client

* Initial plan

* [Log Analytics] Add AzureChinaCloud and AzureUSGovernment host templates to log-analytics data-plane client

Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com>
@x-engineering-agent x-engineering-agent Bot added the Request X Engineering Agent Request X Engineering Agent testing and review label Sep 10, 2026
@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi Aditya Pujara (@a0x1ab),
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in pyproject.toml (or setup.py, if the extension has not migrated yet) as well.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The sovereign host templates are added, but the client’s cloud endpoint metadata key appears incorrect and the AAD token scope is still hard-coded to the public cloud audience, which will likely break auth in AzureChinaCloud/AzureUSGovernment.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the log-analytics extension’s AAZ data-plane client configuration to support az monitor log-analytics query in sovereign clouds by providing cloud-specific host templates, alongside the required version/changelog bump.

Changes:

  • Add Log Analytics Query API host templates for AzureChinaCloud and AzureUSGovernment in the generated AAZ data-plane client.
  • Bump extension version to 1.0.0b2.
  • Add a changelog entry describing the fix.
File summaries
File Description
src/log-analytics/azext_loganalytics/aaz/latest/_clients.py Adds sovereign cloud host templates for the Log Analytics data-plane client used by az monitor log-analytics query.
src/log-analytics/setup.py Bumps extension version to 1.0.0b2.
src/log-analytics/HISTORY.rst Adds the 1.0.0b2 changelog entry describing the sovereign cloud host template addition.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 16 to 20
_CLOUD_HOST_TEMPLATES = {
CloudNameEnum.AzureCloud: "https://api.loganalytics.io",
CloudNameEnum.AzureChinaCloud: "https://api.loganalytics.azure.cn",
CloudNameEnum.AzureUSGovernment: "https://api.loganalytics.us",
}
CloudNameEnum.AzureChinaCloud: "https://api.loganalytics.azure.cn",
CloudNameEnum.AzureUSGovernment: "https://api.loganalytics.us",
}
_CLOUD_HOST_METADATA_INDEX = "logAnalyticslogAnalyticsResourceId"
Comment on lines 16 to 20
_CLOUD_HOST_TEMPLATES = {
CloudNameEnum.AzureCloud: "https://api.loganalytics.io",
CloudNameEnum.AzureChinaCloud: "https://api.loganalytics.azure.cn",
CloudNameEnum.AzureUSGovernment: "https://api.loganalytics.us",
}
@x-engineering-agent

Copy link
Copy Markdown

Live test skipped

⏭️ Skipping the live test for this revision because no changed test file was found (tests/**/test_*.py).

The live-test pipeline runs only the test files a PR changes, so there is nothing to execute for this commit. A skipped live test is not a passing test result. The Agent review separately checks whether the affected command module includes focused regression tests or updated recordings. If a test file is changed in a later commit, the live test will run automatically.

@yonzhan

Copy link
Copy Markdown
Collaborator

Log Analytics

@x-engineering-agent

Copy link
Copy Markdown

Live test skipped

⏭️ Skipping the live test for this revision because no changed test file was found (tests/**/test_*.py).

The live-test pipeline runs only the test files a PR changes, so there is nothing to execute for this commit. A skipped live test is not a passing test result. The Agent review separately checks whether the affected command module includes focused regression tests or updated recordings. If a test file is changed in a later commit, the live test will run automatically.

@x-engineering-agent x-engineering-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aditya Pujara (@a0x1ab)

Upstream CI

Azure.azure-cli-extensions build (https://dev.azure.com/azclitools/5147fa83-336e-44ef-bbe0-c86b8ae86cbb/_build/results?buildId=347642)

  • Result: failure across all 5 Python versions (3.10, 3.11, 3.12, 3.13, 3.14)
  • Failing test: src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsDataClientTests::test_query
  • Evidence: AssertionError raised from azure/cli/testsdk/base.py:308 while running test_query (recorded-response comparison failure).
  • Classification: PR-related. This PR (Fix #10318) changed src/log-analytics/azext_loganalytics/aaz/latest/_clients.py to add the AzureChinaCloud host template used to build the Log Analytics data-plane client endpoint. test_query exercises exactly this client, so the endpoint/host-template change is the most likely cause of the now-failing recorded test.
  • Next action: Update src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsDataClientTests::test_query (and its recording, if it uses one) so the endpoint construction matches the new host-template logic, or fix the host-template mapping in _clients.py if the endpoint it produces for the test's cloud/region is now wrong. Add regression coverage for the AzureChinaCloud sovereign-cloud endpoint mapping the PR introduces.
  • Verify: Re-run Azure.azure-cli-extensions (Integration Tests, Build Tests Python312) (and the sibling Python-version jobs) and confirm test_query passes.

Test validation

  • Live test: Skipped: PR changes no test files (tests/**/test_*.py)
  • Regression coverage: Not applicable to the changed files (per coverage summary), but note this PR added sovereign-cloud endpoint logic with no accompanying test change — add a regression test for test_query covering the new AzureChinaCloud host template.

Risk assessment

79/100 · Critical · High confidence

The Critical rating is driven by sovereign-cloud behavior, public CLI behavior, dependency or supply chain and 2 additional signal(s).

  • Change scope: 3 changed files, 8 changed lines (+7 / -1), including 2 production files.
  • Affected components: log-analytics
  • Risk drivers: sovereign-cloud behavior (+18); public CLI behavior (+18); dependency or supply chain (+18); generated output (+12); no changed regression test (+10)
  • Regression evidence: No changed regression test was detected for the production changes, increasing risk.
  • Confidence: High because changed-line patches were available for every production file.
  • Required review: Owning-squad review is required for log-analytics before merge.

@x-engineering-agent x-engineering-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aditya Pujara (@a0x1ab)

test review body

@x-engineering-agent x-engineering-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aditya Pujara (@a0x1ab)

test review body retry

@x-engineering-agent x-engineering-agent Bot added X Engineering Agent Reviewed Pull request reviewed by X Engineering Agent and removed Request X Engineering Agent Request X Engineering Agent testing and review labels Sep 10, 2026
@x-engineering-agent

Copy link
Copy Markdown

Correction: the previous review posted by this bot ("test review body retry") was posted in error during automated diagnostics and should be disregarded. The actual CI-failure review follows below.

@x-engineering-agent x-engineering-agent Bot added the Request X Engineering Agent Request X Engineering Agent testing and review label Sep 10, 2026

@x-engineering-agent x-engineering-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aditya Pujara (@a0x1ab)

Upstream CI

Azure.azure-cli-extensions build (https://dev.azure.com/azclitools/5147fa83-336e-44ef-bbe0-c86b8ae86cbb/_build/results?buildId=347642)

  • Result: failure across all 5 Python versions (3.10, 3.11, 3.12, 3.13, 3.14)
  • Failing test: src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsDataClientTests::test_query
  • Evidence: AssertionError raised from azure/cli/testsdk/base.py:308 while running test_query (recorded-response comparison failure).
  • Classification: PR-related. This PR (Fix #10318) changed src/log-analytics/azext_loganalytics/aaz/latest/_clients.py to add the AzureChinaCloud host template used to build the Log Analytics data-plane client endpoint. test_query exercises exactly this client, so the endpoint/host-template change is the most likely cause of the now-failing recorded test.
  • Next action: Update src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsDataClientTests::test_query (and its recording, if it uses one) so the endpoint construction matches the new host-template logic, or fix the host-template mapping in _clients.py if the endpoint it produces for the test's cloud/region is now wrong. Add regression coverage for the AzureChinaCloud sovereign-cloud endpoint mapping the PR introduces.
  • Verify: Re-run Azure.azure-cli-extensions (Integration Tests, Build Tests Python312) (and the sibling Python-version jobs) and confirm test_query passes.

Test validation

  • Live test: Skipped: PR changes no test files (tests/**/test_*.py)
  • Regression coverage: Not applicable to the changed files (per coverage summary), but note this PR added sovereign-cloud endpoint logic with no accompanying test change — add a regression test for test_query covering the new AzureChinaCloud host template.

Risk assessment

79/100 · Critical · High confidence

The Critical rating is driven by sovereign-cloud behavior, public CLI behavior, dependency or supply chain and 2 additional signal(s).

  • Change scope: 3 changed files, 8 changed lines (+7 / -1), including 2 production files.
  • Affected components: log-analytics
  • Risk drivers: sovereign-cloud behavior (+18); public CLI behavior (+18); dependency or supply chain (+18); generated output (+12); no changed regression test (+10)
  • Regression evidence: No changed regression test was detected for the production changes, increasing risk.
  • Confidence: High because changed-line patches were available for every production file.
  • Required review: Owning-squad review is required for log-analytics before merge.

@x-engineering-agent

Copy link
Copy Markdown

Started a Copilot task using claude-sonnet-4.6 for the automated review at #10319 (review): https://github.com/a0x1ab/azure-cli-extensions/tasks/37556fd3-3a50-42cd-972f-a9259d8f6dac

… tests

Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com>
@x-engineering-agent

Copy link
Copy Markdown

Live test results — azdev test --live --series (changed test files only)

PASS

Selectors: test_loganalytics_commands (extension)
PR head ref: agent-assist/azure-azure-cli-extensions-issue-10318-d548602a3e3c
PR head sha: e2a830b649c44e1bd388567a00fb93643717960d
PR base ref: main
New test files in PR: false

Changed test files run
src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py

Workflow run: https://github.com/Azure/issue-sentinel/actions/runs/34444185648

Live-test recordings: 1 regenerated — archived in workflow artifact live-test-pr-10319 (recordings/).

ℹ️ This PR is from a fork, so recordings were not pushed automatically. Download them from the artifact and commit to your branch.

Recording files
src/log-analytics/azext_loganalytics/tests/latest/recordings/test_query.yaml
Last 80 lines of azdev output

=============
| Run Tests |
=============


=====================
| Discovering Tests |
=====================

/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:13887: SyntaxWarning: invalid escape sequence '\]'
  self.cmd('vmss application set -g {rg} -n {vmss} --app-version-ids {vid1} {vid2} --enable-automatic-upgrade True\]', checks=[
/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/identity/tests/latest/test_identity.py:18: SyntaxWarning: invalid escape sequence '\{'
  'resource_restriction_compute': '\{"providers":\["Microsoft.Compute"\]\}',
/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/identity/tests/latest/test_identity.py:19: SyntaxWarning: invalid escape sequence '\{'
  'resource_restriction_empty': '\{"providers":\[\]\}'

test index updated: /home/runner/.azdev/env_config/home/runner/work/issue-sentinel/issue-sentinel/.venv/test_index/latest.json

Test on modules: test_loganalytics_commands

WARNING: RUNNING TESTS LIVE
The tests are set to run against current profile "latest"
============================= test session starts ==============================
platform linux -- Python 3.12.14, pytest-9.1.1, pluggy-1.6.0 -- /home/runner/work/issue-sentinel/issue-sentinel/.venv/bin/python
cachedir: .pytest_cache
rootdir: /home/runner/work/issue-sentinel/issue-sentinel/azure-cli-extensions
configfile: pytest.ini
plugins: forked-1.7.5, xdist-3.8.0
collecting ... collected 5 items

azure-cli-extensions/src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsDataClientTests::test_query PASSED [ 20%]
azure-cli-extensions/src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsClientEndpointMappingTests::test_azure_china_cloud_endpoint PASSED [ 40%]
azure-cli-extensions/src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsClientEndpointMappingTests::test_azure_public_cloud_endpoint PASSED [ 60%]
azure-cli-extensions/src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsClientEndpointMappingTests::test_azure_us_government_cloud_endpoint PASSED [ 80%]
azure-cli-extensions/src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsClientEndpointMappingTests::test_fallback_to_host_templates_when_endpoint_not_set PASSED [100%]

- generated xml file: /home/runner/work/issue-sentinel/issue-sentinel/test-output/results.xml -
============================== 5 passed in 42.34s ==============================

Posted by the Azure Client Tools Agent live-test workflow.

@x-engineering-agent x-engineering-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aditya Pujara (@a0x1ab)

Automated review — changes requested

Upstream CI

The Azure.azure-cli-extensions build failed. One Azure DevOps build (buildId 347677) is failing across all 5 Python versions (3.10-3.14) tested:

Next action: Inspect LogAnalyticsDataClientTests::test_query and the change to src/log-analytics/azext_loganalytics/aaz/latest/_clients.py — the failure is consistent across every Python version, so it is very likely caused by this PR's client/endpoint change rather than environment flakiness. Fix the underlying client behavior or update the test/recording to match the new expected behavior, then verify by re-running the Azure.azure-cli-extensions build.

Test validation

  • Live test (azdev test) passed for the changed test file at the current head SHA.
  • Regression coverage: not applicable (no separate production-module coverage gap detected beyond the failing test itself).

No additional review-skill findings beyond the failing CI test above.

Risk assessment

64/100 · High · High confidence

The High rating is driven by sovereign-cloud behavior, public CLI behavior, dependency or supply chain and 1 additional signal(s).

  • Change scope: 4 changed files, 77 changed lines (+75 / -2), including 2 production files.
  • Affected components: log-analytics
  • Risk drivers: sovereign-cloud behavior (+18); public CLI behavior (+18); dependency or supply chain (+18); generated output (+12)
  • Regression evidence: Changed regression tests are included, reducing risk.
  • Confidence: High because changed-line patches were available for every production file.
  • Required review: Owning-squad review is required for log-analytics before merge.

@x-engineering-agent

Copy link
Copy Markdown

Started a Copilot task using claude-sonnet-4.6 for the automated review at #10319 (review): https://github.com/a0x1ab/azure-cli-extensions/tasks/8d20f8ed-ed84-4f6c-b0f3-6ec607398fb6

Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com>
@x-engineering-agent

Copy link
Copy Markdown

Live test results — azdev test --live --series (changed test files only)

PASS

Selectors: test_loganalytics_commands (extension)
PR head ref: agent-assist/azure-azure-cli-extensions-issue-10318-d548602a3e3c
PR head sha: 5a11d77213700d7123d3e23c78d540c9d8dde052
PR base ref: main
New test files in PR: false

Changed test files run
src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py

Workflow run: https://github.com/Azure/issue-sentinel/actions/runs/34447674722

Live-test recordings: 1 regenerated — archived in workflow artifact live-test-pr-10319 (recordings/).

ℹ️ This PR is from a fork, so recordings were not pushed automatically. Download them from the artifact and commit to your branch.

Recording files
src/log-analytics/azext_loganalytics/tests/latest/recordings/test_query.yaml
Last 80 lines of azdev output

=============
| Run Tests |
=============


=====================
| Discovering Tests |
=====================

/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:13887: SyntaxWarning: invalid escape sequence '\]'
  self.cmd('vmss application set -g {rg} -n {vmss} --app-version-ids {vid1} {vid2} --enable-automatic-upgrade True\]', checks=[
/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/identity/tests/latest/test_identity.py:18: SyntaxWarning: invalid escape sequence '\{'
  'resource_restriction_compute': '\{"providers":\["Microsoft.Compute"\]\}',
/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/identity/tests/latest/test_identity.py:19: SyntaxWarning: invalid escape sequence '\{'
  'resource_restriction_empty': '\{"providers":\[\]\}'

test index updated: /home/runner/.azdev/env_config/home/runner/work/issue-sentinel/issue-sentinel/.venv/test_index/latest.json

Test on modules: test_loganalytics_commands

WARNING: RUNNING TESTS LIVE
The tests are set to run against current profile "latest"
============================= test session starts ==============================
platform linux -- Python 3.12.14, pytest-9.1.1, pluggy-1.6.0 -- /home/runner/work/issue-sentinel/issue-sentinel/.venv/bin/python
cachedir: .pytest_cache
rootdir: /home/runner/work/issue-sentinel/issue-sentinel/azure-cli-extensions
configfile: pytest.ini
plugins: forked-1.7.5, xdist-3.8.0
collecting ... collected 6 items

azure-cli-extensions/src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsDataClientTests::test_query PASSED [ 16%]
azure-cli-extensions/src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsClientEndpointMappingTests::test_azure_china_cloud_endpoint PASSED [ 33%]
azure-cli-extensions/src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsClientEndpointMappingTests::test_azure_public_cloud_endpoint PASSED [ 50%]
azure-cli-extensions/src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsClientEndpointMappingTests::test_azure_public_cloud_endpoint_trailing_slash PASSED [ 66%]
azure-cli-extensions/src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsClientEndpointMappingTests::test_azure_us_government_cloud_endpoint PASSED [ 83%]
azure-cli-extensions/src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsClientEndpointMappingTests::test_fallback_to_host_templates_when_endpoint_not_set PASSED [100%]

- generated xml file: /home/runner/work/issue-sentinel/issue-sentinel/test-output/results.xml -
============================== 6 passed in 40.19s ==============================

Posted by the Azure Client Tools Agent live-test workflow.

@x-engineering-agent x-engineering-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aditya Pujara (@a0x1ab)

CI failure summary

Upstream Azure DevOps validation is failing on this PR. The reported test failure is
consistent across all Python versions (3.10-3.14), which suggests it is caused by this
change rather than being environment flakiness.

Upstream CI

Azure.azure-cli-extensions

  • Result: failure
  • Included checks: Azure.azure-cli-extensions (Integration Tests, Build Tests Python314), Azure.azure-cli-extensions (Integration Tests, Build Tests Python313), Azure.azure-cli-extensions (Integration Tests, Build Tests Python310), Azure.azure-cli-extensions (Integration Tests, Build Tests Python312), Azure.azure-cli-extensions (Integration Tests, Build Tests Python311)
  • Failure details:
  • generated xml file: /home/cloudtest/.azdev/env_config/mnt/vss/_work/1/s/env/test_results.xml -
    =========================== short test summary info ============================
    FAILED src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsDataClientTests::test_query
    ================ 1 failed, 5 passed, 3 subtests passed in 1.93s ================
    Traceback (most recent call last):
    File "/mnt/vss/_work/1/s/scripts/ci/test_source.py", line 133, in
    test_extension()
    • Next action: Address the first actionable diagnostic quoted from the task log; do not infer a source-code cause from the aggregate build status.
    • Verify: Re-run Integration Tests, Build Tests Python314 / Run integration test and build test and confirm the quoted diagnostic is gone.
    • Integration Tests, Build Tests Python311 / Run integration test and build test (Uncertain)
      • Evidence: E None
        ../azure-cli/src/azure-cli-testsdk/azure/cli/testsdk/base.py:308: AssertionError
  • generated xml file: /home/cloudtest/.azdev/env_config/mnt/vss/_work/1/s/env/test_results.xml -
    =========================== short test summary info ============================
    FAILED src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsDataClientTests::test_query
    ================ 1 failed, 5 passed, 3 subtests passed in 1.57s ================
    Traceback (most recent call last):
    File "/mnt/vss/_work/1/s/scripts/ci/test_source.py", line 133, in
    test_extension()
    • Next action: Address the first actionable diagnostic quoted from the task log; do not infer a source-code cause from the aggregate build status.
    • Verify: Re-run Integration Tests, Build Tests Python311 / Run integration test and build test and confirm the quoted diagnostic is gone.
    • Integration Tests, Build Tests Python312 / Run integration test and build test (Uncertain)
      • Evidence: E None
        ../azure-cli/src/azure-cli-testsdk/azure/cli/testsdk/base.py:308: AssertionError
  • generated xml file: /home/cloudtest/.azdev/env_config/mnt/vss/_work/1/s/env/test_results.xml -
    =========================== short test summary info ============================
    FAILED src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsDataClientTests::test_query
    ================ 1 failed, 5 passed, 3 subtests passed in 1.93s ================
    Traceback (most recent call last):
    File "/mnt/vss/_work/1/s/scripts/ci/test_source.py", line 133, in
    test_extension()
    • Next action: Address the first actionable diagnostic quoted from the task log; do not infer a source-code cause from the aggregate build status.
    • Verify: Re-run Integration Tests, Build Tests Python312 / Run integration test and build test and confirm the quoted diagnostic is gone.
    • Integration Tests, Build Tests Python310 / Run integration test and build test (Uncertain)
      • Evidence: E None
        ../azure-cli/src/azure-cli-testsdk/azure/cli/testsdk/base.py:308: AssertionError
  • generated xml file: /home/cloudtest/.azdev/env_config/mnt/vss/_work/1/s/env/test_results.xml -
    =========================== short test summary info ============================
    FAILED src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsDataClientTests::test_query
    ================ 1 failed, 5 passed, 3 subtests passed in 1.56s ================
    Traceback (most recent call last):
    File "/mnt/vss/_work/1/s/scripts/ci/test_source.py", line 133, in
    test_extension()
    • Next action: Address the first actionable diagnostic quoted from the task log; do not infer a source-code cause from the aggregate build status.
    • Verify: Re-run Integration Tests, Build Tests Python310 / Run integration test and build test and confirm the quoted diagnostic is gone.
    • Integration Tests, Build Tests Python313 / Run integration test and build test (Uncertain)
      • Evidence: E None
        ../azure-cli/src/azure-cli-testsdk/azure/cli/testsdk/base.py:308: AssertionError
  • generated xml file: /home/cloudtest/.azdev/env_config/mnt/vss/_work/1/s/env/test_results.xml -
    =========================== short test summary info ============================
    FAILED src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsDataClientTests::test_query
    ================ 1 failed, 5 passed, 3 subtests passed in 1.78s ================
    Traceback (most recent call last):
    File "/mnt/vss/_work/1/s/scripts/ci/test_source.py", line 133, in
    test_extension()
    • Next action: Address the first actionable diagnostic quoted from the task log; do not infer a source-code cause from the aggregate build status.
    • Verify: Re-run Integration Tests, Build Tests Python313 / Run integration test and build test and confirm the quoted diagnostic is gone.

Test validation

  • Live test: Passed.
  • Regression coverage: Not applicable to the changed files.

The recurring failure is:
FAILED src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsDataClientTests::test_query

Please investigate why test_query now fails after the AzureChinaCloud host template
change in _clients.py. Confirm the sovereign-cloud endpoint/host template change does
not alter behavior for the default (non-sovereign) cloud used by this recorded test, and
update the test recording/mocked client configuration if needed. Re-run the failing
integration test locally (azdev test log-analytics) before pushing again.

Risk assessment

64/100 · High · High confidence

The High rating is driven by sovereign-cloud behavior, public CLI behavior, dependency or supply chain and 1 additional signal(s).

  • Change scope: 4 changed files, 84 changed lines (+81 / -3), including 2 production files.
  • Affected components: log-analytics
  • Risk drivers: sovereign-cloud behavior (+18); public CLI behavior (+18); dependency or supply chain (+18); generated output (+12)
  • Regression evidence: Changed regression tests are included, reducing risk.
  • Confidence: High because changed-line patches were available for every production file.
  • Required review: Owning-squad review is required for log-analytics before merge.

@x-engineering-agent

Copy link
Copy Markdown

Started a Copilot task using claude-sonnet-4.6 for the automated review at #10319 (review): https://github.com/a0x1ab/azure-cli-extensions/tasks/60c0f2b1-4c75-452b-9d92-b50ceb570d0f

Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com>
@x-engineering-agent

Copy link
Copy Markdown

Live test results — azdev test --live --series (changed test files only)

FAIL (exit 1)

Selectors: test_loganalytics_commands (extension)
PR head ref: agent-assist/azure-azure-cli-extensions-issue-10318-d548602a3e3c
PR head sha: 3806f9507fc45fcd5f80ec67e2c38b7f460d855e
PR base ref: main
New test files in PR: false

Changed test files run
src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py

Workflow run: https://github.com/Azure/issue-sentinel/actions/runs/34455663780

Live-test recordings: 1 regenerated — archived in workflow artifact live-test-pr-10319 (recordings/).

ℹ️ This PR is from a fork, so recordings were not pushed automatically. Download them from the artifact and commit to your branch.

Recording files
src/log-analytics/azext_loganalytics/tests/latest/recordings/test_query.yaml
Last 80 lines of azdev output
    def _handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception ResourceNotFoundError during execution and fails the command.

azure-cli/src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <azext_loganalytics.tests.latest.test_loganalytics_commands.LogAnalyticsDataClientTests testMethod=test_query>

    def test_query(self):
        """Tests data plane query capabilities for Log Analytics."""
        self.kwargs.update({
            'workspace_customerId': '062c153f-f7b2-4a8b-b57d-05b9f5cadfdc',
        })
    
>       self.cmd(
            'az monitor log-analytics query -w {workspace_customerId} '
            '--analytics-query "Heartbeat | getschema"',
            checks=[
                self.check("length(@)", 31),
                self.check("@[0]", {'ColumnName': 'TenantId', 'ColumnOrdinal': '0', 'ColumnType': 'string',
                                    'DataType': 'System.String', 'TableName': 'getschema'})
            ]
        )

azure-cli-extensions/src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py:22: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
azure-cli/src/azure-cli-testsdk/azure/cli/testsdk/base.py:177: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
azure-cli/src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in __init__
    self._in_process_execute(cli_ctx, command, expect_failure=expect_failure)
azure-cli/src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in _in_process_execute
    raise ex.exception
.venv/lib/python3.12/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
azure-cli/src/azure-cli-core/azure/cli/core/commands/__init__.py:677: in execute
    raise ex
azure-cli/src/azure-cli-core/azure/cli/core/commands/__init__.py:820: in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
azure-cli/src/azure-cli-core/azure/cli/core/commands/__init__.py:789: in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
azure-cli/src/azure-cli-core/azure/cli/core/aaz/_command.py:154: in __call__
    return self._handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
azure-cli-extensions/src/log-analytics/azext_loganalytics/aaz/latest/monitor/log_analytics/_query.py:36: in _handler
    self._execute_operations()
azure-cli-extensions/src/log-analytics/azext_loganalytics/aaz/latest/monitor/log_analytics/_query.py:75: in _execute_operations
    self.QueryExecute(ctx=self.ctx)()
azure-cli-extensions/src/log-analytics/azext_loganalytics/aaz/latest/monitor/log_analytics/_query.py:99: in __call__
    return self.on_error(session.http_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <azext_loganalytics.aaz.latest.monitor.log_analytics._query.Query.QueryExecute object at 0x7f0160832c60>
response = <RequestsTransportResponse: 404 Not Found, Content-Type: application/json; charset=utf-8>

    def on_error(self, response):
        """ handle errors in response
        """
        # raise common http errors
        error_type = self.error_map.get(response.status_code)
        if error_type:
>           raise error_type(response=response)
E           azure.core.exceptions.ResourceNotFoundError: (WorkspaceNotFoundError) The workspace could not be found
E           Code: WorkspaceNotFoundError
E           Message: The workspace could not be found

azure-cli/src/azure-cli-core/azure/cli/core/aaz/_operation.py:324: ResourceNotFoundError
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
============================== 1 failed in 4.37s ===============================

Posted by the Azure Client Tools Agent live-test workflow.

@x-engineering-agent x-engineering-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aditya Pujara (@a0x1ab)

Handoff summary

This PR is still failing after 3 automated Copilot attempts and is being left for human review.

Test validation

  • Live test: Failed with conclusion failure. Workflow run
  • Regression coverage: Not applicable to the changed files (no production module test-coverage gap detected).

Outstanding failure

  • azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsDataClientTests::test_query fails during live playback with:
    azure.core.exceptions.ResourceNotFoundError: (WorkspaceNotFoundError) The workspace could not be found
    Code: WorkspaceNotFoundError
    
    raised from azure-cli-core/azure/cli/core/aaz/_operation.py:324, surfaced as
    CliExecutionError: The CLI throws exception ResourceNotFoundError during execution and fails the command.
  • Relevance: This test directly exercises the command touched by this PR (az monitor log-analytics query) against the
    recorded cassette in azext_loganalytics/tests/latest/recordings/test_query.yaml. The PR adds an AzureChinaCloud host
    template to azext_loganalytics/aaz/latest/_clients.py; the recorded cassette's workspace/host no longer matches what the
    updated client resolves to, so playback returns WorkspaceNotFoundError instead of the expected recorded response.
  • Practical next step: Re-record test_query.yaml (or add a targeted assertion/mocked host resolution) against a live or
    correctly-scoped workspace so the cassette matches the new host-template resolution logic, then rerun
    azdev test log-analytics --live scoped to test_loganalytics_commands.py::LogAnalyticsDataClientTests::test_query.

Review-skill guidance (not confirmed as findings, but requiring reviewer attention given High risk)

  • Release artifact validator: Confirm the HISTORY.rst entry is under the correct upcoming-release header and describes
    customer-visible behavior.
  • Generated code ownership: Confirm _clients.py is reproducible from a durable Azure/aaz source and was not hand-edited.
  • Test semantic-strength: Confirm test_loganalytics_commands.py assertions can fail when the implementation is wrong,
    including the AzureChinaCloud host-resolution path itself, not just the currently-broken assertion.
  • Scope-consistency: Confirm the changed files match the stated log-analytics AzureChinaCloud scope with no unrelated
    drift.

CI checks passed (23/23 completed, no CI failures), but the live test is the blocking failure above.

Risk assessment

65/100 · High · High confidence

The High rating is driven by sovereign-cloud behavior, public CLI behavior, dependency or supply chain and 1 additional signal(s).

  • Change scope: 5 changed files, 212 changed lines (+84 / -128), including 2 production files.
  • Affected components: log-analytics
  • Risk drivers: sovereign-cloud behavior (+18); public CLI behavior (+18); dependency or supply chain (+18); generated output (+12)
  • Regression evidence: Changed regression tests are included, reducing risk.
  • Confidence: High because changed-line patches were available for every production file.
  • Required review: Owning-squad review is required for log-analytics before merge.

@x-engineering-agent x-engineering-agent Bot removed the Request X Engineering Agent Request X Engineering Agent testing and review label Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-observability-squad Auto-Assign Auto assign by bot Monitor X Engineering Agent Reviewed Pull request reviewed by X Engineering Agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[log-analytics] az monitor log-analytics query fails in AzureChinaCloud with CloudEndpointNotSetException

5 participants