[Log Analytics] Fix #10318: az monitor log-analytics query: Add AzureChinaCloud host template for log-analytics data-plane client - #10319
Conversation
…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>
|
Hi Aditya Pujara (@a0x1ab), |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟡 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
AzureChinaCloudandAzureUSGovernmentin 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.
| _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" |
| _CLOUD_HOST_TEMPLATES = { | ||
| CloudNameEnum.AzureCloud: "https://api.loganalytics.io", | ||
| CloudNameEnum.AzureChinaCloud: "https://api.loganalytics.azure.cn", | ||
| CloudNameEnum.AzureUSGovernment: "https://api.loganalytics.us", | ||
| } |
Live test skipped⏭️ Skipping the live test for this revision because no changed test file was found ( 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. |
|
Log Analytics |
…e-10318-d548602a3e3c
Live test skipped⏭️ Skipping the live test for this revision because no changed test file was found ( 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. |
There was a problem hiding this comment.
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:
AssertionErrorraised fromazure/cli/testsdk/base.py:308while runningtest_query(recorded-response comparison failure). - Classification: PR-related. This PR (
Fix #10318) changedsrc/log-analytics/azext_loganalytics/aaz/latest/_clients.pyto add the AzureChinaCloud host template used to build the Log Analytics data-plane client endpoint.test_queryexercises 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.pyif 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 confirmtest_querypasses.
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_querycovering 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-analyticsbefore merge.
|
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. |
There was a problem hiding this comment.
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:
AssertionErrorraised fromazure/cli/testsdk/base.py:308while runningtest_query(recorded-response comparison failure). - Classification: PR-related. This PR (
Fix #10318) changedsrc/log-analytics/azext_loganalytics/aaz/latest/_clients.pyto add the AzureChinaCloud host template used to build the Log Analytics data-plane client endpoint.test_queryexercises 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.pyif 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 confirmtest_querypasses.
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_querycovering 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-analyticsbefore merge.
|
Started a Copilot task using |
… tests Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com>
Live test results —
|
There was a problem hiding this comment.
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:
- Failing test:
src/log-analytics/azext_loganalytics/tests/latest/test_loganalytics_commands.py::LogAnalyticsDataClientTests::test_query - Result:
1 failed, 4 passed, 3 subtests passedin each job, consistent across Python 3.10, 3.11, 3.12, 3.13, and 3.14. - Details: https://dev.azure.com/azclitools/5147fa83-336e-44ef-bbe0-c86b8ae86cbb/_build/results?buildId=347677
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-analyticsbefore merge.
|
Started a Copilot task using |
Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com>
Live test results —
|
There was a problem hiding this comment.
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:
- Integration Tests, Build Tests Python314 / Run integration test and build test (Uncertain)
- Evidence: E None
../azure-cli/src/azure-cli-testsdk/azure/cli/testsdk/base.py:308: AssertionError
- Evidence: E None
- Integration Tests, Build Tests Python314 / Run integration test and build test (Uncertain)
- 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 testand 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
- Evidence: E None
- 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 testand 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
- Evidence: E None
- 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 testand 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
- Evidence: E None
- 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 testand 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
- Evidence: E None
- 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 testand 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-analyticsbefore merge.
|
Started a Copilot task using |
Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com>
Live test results —
|
There was a problem hiding this comment.
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_queryfails during live playback with:raised fromazure.core.exceptions.ResourceNotFoundError: (WorkspaceNotFoundError) The workspace could not be found Code: WorkspaceNotFoundErrorazure-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 inazext_loganalytics/tests/latest/recordings/test_query.yaml. The PR adds an AzureChinaCloud host
template toazext_loganalytics/aaz/latest/_clients.py; the recorded cassette's workspace/host no longer matches what the
updated client resolves to, so playback returnsWorkspaceNotFoundErrorinstead 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 --livescoped totest_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.rstentry is under the correct upcoming-release header and describes
customer-visible behavior. - Generated code ownership: Confirm
_clients.pyis reproducible from a durable Azure/aaz source and was not hand-edited. - Test semantic-strength: Confirm
test_loganalytics_commands.pyassertions 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-analyticsAzureChinaCloud 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-analyticsbefore merge.
🤖 PR Validation — ️✔️ All clear
Description
Fixes #10318.
az monitor log-analytics queryfails in AzureChinaCloud (and AzureUSGovernment) withCloudEndpointNotSetExceptionbecause_CLOUD_HOST_TEMPLATESonly contained an entry forAzureCloud, causing_build_base_urlto returnNone.Changes
azext_loganalytics/aaz/latest/_clients.py: AddAzureChinaCloudandAzureUSGovernmententries to_CLOUD_HOST_TEMPLATES:setup.py: Bump version1.0.0b1→1.0.0b2HISTORY.rst: Add changelog entryRelated command
az monitor log-analytics queryGeneral Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install azdevrequired)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.jsonautomatically.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