Python: Add an azure function streaming example#3173
Open
lordlinus wants to merge 9 commits intomicrosoft:mainfrom
Open
Python: Add an azure function streaming example#3173lordlinus wants to merge 9 commits intomicrosoft:mainfrom
lordlinus wants to merge 9 commits intomicrosoft:mainfrom
Conversation
…l-time streaming of agent responses using Azure SignalR Service. Include a sample frontend as well
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a comprehensive sample demonstrating real-time streaming of agent responses using Azure SignalR Service with the Agent Framework. The sample shows how to implement user isolation through SignalR groups, enabling multiple concurrent users to chat with agents without interference.
Changes:
- Added a new Azure Functions sample (09_agent_streaming_signalr) implementing SignalR-based streaming
- Created a custom SignalRServiceClient for REST API communication with Azure SignalR Service
- Implemented SignalRCallback using AgentResponseCallbackProtocol for streaming updates
- Included a web-based frontend with HTML/CSS/JavaScript for real-time chat interface
- Added comprehensive documentation explaining the architecture and user isolation patterns
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| function_app.py | Main Azure Functions application with SignalR client, callback implementation, and HTTP endpoints for negotiation, group management, and thread creation |
| tools.py | Mock travel planning tools (weather forecast and local events) for agent demonstrations |
| requirements.txt | Python dependencies including azure-functions, agent-framework-azurefunctions, azure-identity, and aiohttp |
| host.json | Azure Functions host configuration with Durable Task settings |
| local.settings.json.template | Configuration template for local development with Azure OpenAI and SignalR connection strings |
| content/index.html | Complete web interface with SignalR JavaScript client, real-time message streaming, and conversation management |
| README.md | Comprehensive documentation covering architecture, API endpoints, user isolation patterns, and setup instructions |
...ples/getting_started/azure_functions/09_agent_streaming_signalr/local.settings.json.template
Outdated
Show resolved
Hide resolved
python/samples/getting_started/azure_functions/09_agent_streaming_signalr/README.md
Outdated
Show resolved
Hide resolved
python/samples/getting_started/azure_functions/09_agent_streaming_signalr/function_app.py
Show resolved
Hide resolved
python/samples/getting_started/azure_functions/09_agent_streaming_signalr/README.md
Outdated
Show resolved
Hide resolved
python/samples/getting_started/azure_functions/09_agent_streaming_signalr/function_app.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/azure_functions/09_agent_streaming_signalr/function_app.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/azure_functions/09_agent_streaming_signalr/function_app.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/azure_functions/09_agent_streaming_signalr/function_app.py
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Real-Time Streaming Agents with Azure SignalR
Why is this change required?
Traditional agent implementations either:
What problem does it solve?
Streaming Response Problem: Users see responses appear in real-time as the agent generates them, instead of waiting for the entire response to complete.
User Isolation Problem: Multiple concurrent users can chat without seeing each other's conversations. Messages are delivered only to the specific conversation group, not broadcast to all connected clients.
Architecture Problem: Shows how to integrate Azure SignalR Service REST API with the Agent Framework's AgentResponseCallbackProtocol for production-grade real-time communication.
What scenario does it contribute to?
This sample enables several real-world use cases:
Contribution Checklist