Python: Add an azure function streaming example#3173
Python: Add an azure function streaming example#3173lordlinus wants to merge 12 commits intomicrosoft:mainfrom
Conversation
…l-time streaming of agent responses using Azure SignalR Service. Include a sample frontend as well
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
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
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
|
@lordlinus this needs a bit of work, should be moved into the 05-end-to-end folder in the samples and adhere to the latest guidelines (it's probably close) and make sure it is fully up to date with the latest, closing is also fine if you don't have the time to fix. |
|
noted @eavanvalkenburg will update and re-submit |
- Implemented a travel planning agent using Azure OpenAI and Azure SignalR Service. - Created HTML interface for user interaction with the agent. - Developed Python backend to handle SignalR connections and agent responses. - Added mock tools for weather forecasts and local events. - Configured Azure Functions with necessary settings and dependencies. - Included local settings template for development.
…n string from local settings template
|
@eavanvalkenburg please let me know if this look ok |
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