Skip to content

Conversation

@eamonoreilly
Copy link
Contributor

@eamonoreilly eamonoreilly commented Jan 27, 2026

Add console log streaming commands and options for hosted agents:

  • Add new az cognitiveservices agent logs show command to stream console output (stdout/stderr) or system events from agent containers
  • Add --show-logs flag to az cognitiveservices agent create to stream logs during deployment for troubleshooting
  • Add --show-logs and --timeout flags to az cognitiveservices agent start to stream logs during startup

Implementation details:

  • Implement _stream_agent_logs() using HTTP streaming with Bearer auth
  • Create _BackgroundLogStreamer context manager for reusable log streaming
  • Add retry logic to handle container startup delays
  • Extract helper functions for auth and URL building
  • Add unit tests for new functionality

Related command
az cognitiveservices agent logs show
az cognitiveservices agent create
az cognitiveservices agent start

Description
Add console log streaming support for hosted agents in AI Foundry. This enables users to troubleshoot agent startup issues and monitor agent behavior by streaming container logs in real-time.

Key features:

  • New az cognitiveservices agent logs show command to stream console output (stdout/stderr) or system events from agent containers
  • --show-logs flag on az cognitiveservices agent create to stream logs during deployment
  • --show-logs and --timeout flags on az cognitiveservices agent start to stream logs during startup

Testing Guide

# Stream logs from a running agent
az cognitiveservices agent logs show -a myAccount -p myProject -n myAgent --agent-version 1

# Stream logs in real-time
az cognitiveservices agent logs show -a myAccount -p myProject -n myAgent --agent-version 1 --follow

# View system events
az cognitiveservices agent logs show -a myAccount -p myProject -n myAgent --agent-version 1 --type system

# Create agent from source with log streaming
az cognitiveservices agent create -a myAccount -p myProject -n myAgent --source ./my-agent --registry myregistry --show-logs

# Or create agent from existing image with log streaming
az cognitiveservices agent create -a myAccount -p myProject -n myAgent --image myregistry.azurecr.io/myagent:v1 --show-logs

# Start agent with log streaming
az cognitiveservices agent start -a myAccount -p myProject -n myAgent --agent-version 1 --show-logs

History Notes
[Cognitive Services] az cognitiveservices agent logs show: Add console log streaming for hosted agents
[Cognitive Services] az cognitiveservices agent create: Add --show-logs flag for deployment troubleshooting
[Cognitive Services] az cognitiveservices agent start: Add --show-logs and --timeout flags

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

…agent logs show`

Add console log streaming commands and options for hosted agents:

- Add new `az cognitiveservices agent logs show` command to stream
  console output (stdout/stderr) or system events from agent containers
- Add --show-logs flag to `az cognitiveservices agent create` to stream
  logs during deployment for troubleshooting
- Add --show-logs and --timeout flags to `az cognitiveservices agent start`
  to stream logs during startup

Implementation details:
- Implement _stream_agent_logs() using HTTP streaming with Bearer auth
- Create _BackgroundLogStreamer context manager for reusable log streaming
- Add retry logic to handle container startup delays
- Extract helper functions for auth and URL building
- Add unit tests for new functionality
Copilot AI review requested due to automatic review settings January 27, 2026 00:02
@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Jan 27, 2026

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Jan 27, 2026

⚠️AzureCLI-BreakingChangeTest
⚠️cognitiveservices
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd cognitiveservices agent create cmd cognitiveservices agent create added parameter show_logs
⚠️ 1011 - SubgroupAdd cognitiveservices agent logs sub group cognitiveservices agent logs added
⚠️ 1006 - ParaAdd cognitiveservices agent start cmd cognitiveservices agent start added parameter show_logs
⚠️ 1006 - ParaAdd cognitiveservices agent start cmd cognitiveservices agent start added parameter timeout

@yonzhan
Copy link
Collaborator

yonzhan commented Jan 27, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds console log streaming capabilities for hosted Cognitive Services agents in Azure CLI, enabling users to stream container logs for troubleshooting during deployment and startup, and via a dedicated logs command.

Changes:

  • Introduces _stream_agent_logs and _BackgroundLogStreamer to implement HTTP log streaming with retry logic, plus a new agent_logs_show custom command and cognitiveservices agent logs command group.
  • Extends agent_create and agent_start with --show-logs and --timeout options, wiring them into _deploy_agent_version and background log streaming for richer troubleshooting during deployment/startup.
  • Adds CLI argument wiring, help text, and both unit and live scenario tests to cover new signatures, options, and end-to-end log streaming behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/azure-cli/azure/cli/command_modules/cognitiveservices/custom.py Implements log streaming helpers, background log streamer context manager, integrates streaming into agent_create deployment path and agent_start, and adds the agent_logs_show handler.
src/azure-cli/azure/cli/command_modules/cognitiveservices/tests/latest/test_agent.py Adds unit tests for new function signatures and live scenario tests for agent logs show and agent start --show-logs.
src/azure-cli/azure/cli/command_modules/cognitiveservices/commands.py Registers the new cognitiveservices agent logs show custom command on the cf_ai_projects client.
src/azure-cli/azure/cli/command_modules/cognitiveservices/_params.py Wires new --show-logs, --timeout, and log-streaming-specific arguments (--type, --tail, --follow) into the corresponding commands.
src/azure-cli/azure/cli/command_modules/cognitiveservices/_help.py Updates help text and examples for agent create, agent start, and adds help for the new agent logs group and agent logs show command.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Distinguish transient errors (ConnectionError, Timeout) from unexpected errors
- Track last error and show warning to user after all retries exhausted
- Provides actionable feedback when --show-logs cannot establish connection
@yonzhan yonzhan requested a review from necusjz January 27, 2026 01:21
@necusjz necusjz changed the title [Cognitiveservices] Add console log streaming: az cognitiveservices agent logs show [Cognitive Services] az cognitiveservices agent logs show: Support console log streaming Jan 27, 2026
@kairu-ms kairu-ms merged commit a0e5cf8 into Azure:dev Jan 27, 2026
48 checks passed
@necusjz necusjz changed the title [Cognitive Services] az cognitiveservices agent logs show: Support console log streaming {Cognitive Services} az cognitiveservices agent logs show: Support console log streaming Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto-Assign Auto assign by bot Cognitive Services az cognitiveservices

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants