Skip to content

[Monitor] az monitor trace-association, az monitor account trace-container: Add preview command groups for distributed traces - #34263

Draft
bragi92 wants to merge 2 commits into
Azure:devfrom
bragi92:kadubey/monitor-trace-association
Draft

bragi92 wants to merge 2 commits into
Azure:devfrom
bragi92:kadubey/monitor-trace-association

Conversation

@bragi92

@bragi92 bragi92 commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes Tests
⚠️ None ️✔️ 130/130
⚠️AzureCLI-BreakingChangeTest
⚠️monitor
rule cmd_name rule_message suggest_message
⚠️ 1011 - SubgroupAdd monitor account trace-container sub group monitor account trace-container added
⚠️ 1011 - SubgroupAdd monitor trace-association sub group monitor trace-association added

Related command
az monitor trace-association create/show/list/delete
az monitor account trace-container create/show/update/wait

Description
Adds preview commands for distributed traces in Azure Monitor, on Microsoft.Monitor 2026-09-03-preview.

  • az monitor trace-association create --resource-uri <scope> --azure-monitor-workspace <workspace id> routes the traces of an Application Insights component, a resource group or a subscription to an Azure Monitor workspace. One command covers every scope; --resource-uri picks the API path.
    • If the workspace has no trace container, the command creates it first: 30 days retention and trace metrics Enabled unless --trace-retention-days or --trace-metrics say otherwise. An existing container is never changed, and explicit settings that differ from it fail.
    • Replacing the workspace of a resource group or subscription asks for confirmation (--yes skips it), because everything under that scope stops sending traces to the old workspace unless another association routes them there.
    • After the write, the command reports the workspaces that receive the scope's traces. Associations are additive across a component, its resource group and its subscription.
  • show returns the association at exactly the scope, list adds the inherited ones, and delete removes only the scope's own association. Deleting at a resource group or subscription asks for confirmation; deleting where nothing is configured is a no-op.
  • az monitor account trace-container create/show/update/wait manage the workspace's trace container. create keeps the current value of any setting it is not given, and uses the defaults above for a new container.

Implementation notes:

  • AAZ command models: [monitor] Add trace preview atomic command models aaz#1131. The trace container commands are registered. The per-scope association commands (subscription, resource group, Application Insights component) are generated as unregistered helpers, and the --resource-uri commands dispatch to them.
  • Follows the az monitor sli onboarding: generated packages keep empty __init__.py files for args-guided loading. The trace-container create override lives in the operations/latest tree.

Testing Guide

az monitor account trace-container create -g MyResourceGroup -w MyWorkspace
az monitor trace-association create --resource-uri /subscriptions/{subscriptionID}/resourceGroups/MyResourceGroup --azure-monitor-workspace /subscriptions/{subscriptionID}/resourceGroups/MyResourceGroup/providers/Microsoft.Monitor/accounts/MyWorkspace
az monitor trace-association list --resource-uri /subscriptions/{subscriptionID}/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/components/MyAppInsights
az monitor trace-association delete --resource-uri /subscriptions/{subscriptionID}/resourceGroups/MyResourceGroup --yes
  • test_monitor_trace_scenario.py: two scenario tests, recorded live in eastus2euap. Trace containers and Application Insights trace associations are only created in regions with traces enabled, and canary regions get them first.
  • test_monitor_unittest.py: unit tests for --resource-uri parsing, workspace ID validation and container settings.
  • azdev linter monitor passes. flake8 and pylint are clean on the changed files.

History Notes
[Monitor] az monitor trace-association: Add preview command group to route distributed traces from an Application Insights component, resource group or subscription to an Azure Monitor workspace
[Monitor] az monitor account trace-container: Add preview command group to manage the trace container of an Azure Monitor workspace


This checklist is used to make sure that common guidelines for a pull request are followed.

…ontainer`: Add preview command groups for distributed traces

Route distributed traces from an Application Insights component, resource
group or subscription to an Azure Monitor workspace with one command,
`az monitor trace-association create --resource-uri`. It creates the
workspace's trace container first if it has none and never changes an
existing one. Replacing the workspace of a resource group or subscription,
and deleting its association, ask for confirmation.

The commands use Microsoft.Monitor 2026-09-03-preview through AAZ models
from Azure/aaz#1131. The per-scope association commands are generated as
unregistered helpers that the --resource-uri commands dispatch to.
`trace-container create` keeps the current value of settings it is not given.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3fea4286-bba0-4628-84dc-866644c2595b
@azure-pipelines

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

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@x-engineering-agent

Copy link
Copy Markdown
Contributor

Hi bragi92,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

…and when settings conflict

When explicit --trace-retention-days or --trace-metrics differ from the
workspace's existing trace container, the error now says what the shared
container keeps and recommends the exact `az monitor account
trace-container update` command, or running without the flags. The
container is still never changed by onboarding.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3fea4286-bba0-4628-84dc-866644c2595b
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants