From 0f13e0d7c7dd3f925644a7c1ce0eeacfbe290a3d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Jan 2026 01:46:27 +0000 Subject: [PATCH 1/2] Initial plan From 40f95b2fa72312f755bbb0c89602d07b28b0deaf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Jan 2026 01:49:11 +0000 Subject: [PATCH 2/2] Fix host binding for Azure deployment in Python samples Co-authored-by: joratz <43622754+joratz@users.noreply.github.com> --- python/agent-framework/sample-agent/host_agent_server.py | 8 ++++++-- python/claude/sample-agent/host_agent_server.py | 8 ++++++-- python/crewai/sample_agent/host_agent_server.py | 8 ++++++-- python/openai/sample-agent/host_agent_server.py | 8 ++++++-- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/python/agent-framework/sample-agent/host_agent_server.py b/python/agent-framework/sample-agent/host_agent_server.py index b6f4353c..1925ac94 100644 --- a/python/agent-framework/sample-agent/host_agent_server.py +++ b/python/agent-framework/sample-agent/host_agent_server.py @@ -306,16 +306,20 @@ async def anonymous_claims(request, handler): if s.connect_ex(("127.0.0.1", desired_port)) == 0: port = desired_port + 1 + # Detect production environment (Azure App Service sets WEBSITE_SITE_NAME) + is_production = os.getenv("WEBSITE_SITE_NAME") is not None + host = "0.0.0.0" if is_production else "localhost" + print("=" * 80) print(f"šŸ¢ {self.agent_class.__name__}") print("=" * 80) print(f"šŸ”’ Auth: {'Enabled' if auth_configuration else 'Anonymous'}") - print(f"šŸš€ Server: localhost:{port}") + print(f"šŸš€ Server: {host}:{port}") print(f"šŸ“š Endpoint: http://localhost:{port}/api/messages") print(f"ā¤ļø Health: http://localhost:{port}/api/health\n") try: - run_app(app, host="localhost", port=port, handle_signals=True) + run_app(app, host=host, port=port, handle_signals=True) except KeyboardInterrupt: print("\nšŸ‘‹ Server stopped") diff --git a/python/claude/sample-agent/host_agent_server.py b/python/claude/sample-agent/host_agent_server.py index fb7b4a06..7eb5fd67 100644 --- a/python/claude/sample-agent/host_agent_server.py +++ b/python/claude/sample-agent/host_agent_server.py @@ -434,6 +434,10 @@ async def anonymous_claims(request, handler): ) port = desired_port + 1 + # Detect production environment (Azure App Service sets WEBSITE_SITE_NAME) + is_production = os.getenv("WEBSITE_SITE_NAME") is not None + host = "0.0.0.0" if is_production else "localhost" + print("=" * 80) print(f"šŸ¢ Generic Agent Host - {self.agent_class.__name__}") print("=" * 80) @@ -442,13 +446,13 @@ async def anonymous_claims(request, handler): print("šŸŽÆ Compatible with Agents Playground") if port != desired_port: print(f"āš ļø Requested port {desired_port} busy; using fallback {port}") - print(f"\nšŸš€ Starting server on localhost:{port}") + print(f"\nšŸš€ Starting server on {host}:{port}") print(f"šŸ“š Bot Framework endpoint: http://localhost:{port}/api/messages") print(f"ā¤ļø Health: http://localhost:{port}/api/health") print("šŸŽÆ Ready for testing!\n") try: - run_app(app, host="localhost", port=port) + run_app(app, host=host, port=port) except KeyboardInterrupt: print("\nšŸ‘‹ Server stopped") except Exception as error: diff --git a/python/crewai/sample_agent/host_agent_server.py b/python/crewai/sample_agent/host_agent_server.py index 2b26b4d5..4d4393da 100644 --- a/python/crewai/sample_agent/host_agent_server.py +++ b/python/crewai/sample_agent/host_agent_server.py @@ -316,6 +316,10 @@ async def anonymous_claims(request, handler): ) port = desired_port + 1 + # Detect production environment (Azure App Service sets WEBSITE_SITE_NAME) + is_production = os.getenv("WEBSITE_SITE_NAME") is not None + host = "0.0.0.0" if is_production else "localhost" + print("=" * 80) print(f"Generic Agent Host - {self.agent_class.__name__}") print("=" * 80) @@ -323,13 +327,13 @@ async def anonymous_claims(request, handler): print("Using Microsoft Agents SDK patterns") if port != desired_port: print(f"Requested port {desired_port} busy; using fallback {port}") - print(f"\nStarting server on localhost:{port}") + print(f"\nStarting server on {host}:{port}") print(f"Bot Framework endpoint: http://localhost:{port}/api/messages") print(f"Health: http://localhost:{port}/api/health") print("Ready for testing!\n") try: - run_app(app, host="localhost", port=port) + run_app(app, host=host, port=port) except KeyboardInterrupt: print("\nServer stopped") except Exception as error: diff --git a/python/openai/sample-agent/host_agent_server.py b/python/openai/sample-agent/host_agent_server.py index 4df50db0..f3cce0ee 100644 --- a/python/openai/sample-agent/host_agent_server.py +++ b/python/openai/sample-agent/host_agent_server.py @@ -298,6 +298,10 @@ async def anonymous_claims(request, handler): ) port = desired_port + 1 + # Detect production environment (Azure App Service sets WEBSITE_SITE_NAME) + is_production = os.getenv("WEBSITE_SITE_NAME") is not None + host = "0.0.0.0" if is_production else "localhost" + print("=" * 80) print(f"šŸ¢ Generic Agent Host - {self.agent_class.__name__}") print("=" * 80) @@ -306,13 +310,13 @@ async def anonymous_claims(request, handler): print("šŸŽÆ Compatible with Agents Playground") if port != desired_port: print(f"āš ļø Requested port {desired_port} busy; using fallback {port}") - print(f"\nšŸš€ Starting server on localhost:{port}") + print(f"\nšŸš€ Starting server on {host}:{port}") print(f"šŸ“š Bot Framework endpoint: http://localhost:{port}/api/messages") print(f"ā¤ļø Health: http://localhost:{port}/api/health") print("šŸŽÆ Ready for testing!\n") try: - run_app(app, host="localhost", port=port) + run_app(app, host=host, port=port) except KeyboardInterrupt: print("\nšŸ‘‹ Server stopped") except Exception as error: