Skip to content

Commit c8a6fdc

Browse files
Add Host IP Check for Deployment (#202)
* Add Host ip check for deployment * feat: Add E2E Status check job to match CI orchestrator pattern
1 parent ed93b0b commit c8a6fdc

4 files changed

Lines changed: 57 additions & 22 deletions

File tree

β€Ž.github/workflows/e2e-orchestrator.ymlβ€Ž

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,34 @@ jobs:
7878

7979
# ===========================================================================
8080
# Summary - Posts test results to PR
81+
# This is the ONLY check you need to mark as "Required" in branch protection
8182
# ===========================================================================
82-
summary:
83-
name: Test Summary
83+
e2e-status:
84+
name: E2E Status
8485
runs-on: ubuntu-latest
8586
needs: [python-openai, nodejs-openai, nodejs-langchain, dotnet-sk, dotnet-af]
8687
if: always()
8788

8889
steps:
90+
- name: Check E2E Status
91+
run: |
92+
echo "Checking E2E test results..."
93+
94+
# Get all job results (skipped jobs are fine, failed jobs are not)
95+
results="${{ needs.python-openai.result }} ${{ needs.nodejs-openai.result }} ${{ needs.nodejs-langchain.result }} ${{ needs.dotnet-sk.result }} ${{ needs.dotnet-af.result }}"
96+
97+
echo "Job results: $results"
98+
99+
# Check if any job failed or was cancelled
100+
if echo "$results" | grep -qE "failure|cancelled"; then
101+
echo "❌ One or more E2E tests failed or were cancelled"
102+
exit 1
103+
fi
104+
105+
echo "βœ… All E2E tests passed (or were skipped)"
106+
89107
- name: Generate Summary
108+
if: always()
90109
id: summary
91110
run: |
92111
# Determine overall status

β€Žpython/openai/sample-agent/.env.templateβ€Ž

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ AGENT_ID=
2525
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTID=
2626
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTSECRET=
2727
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__TENANTID=
28-
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__ALT_BLUEPRINT_NAME=AGENTBLUEPRINT
29-
30-
CONNECTIONS__AGENTBLUEPRINT__SETTINGS__CLIENTID=
31-
CONNECTIONS__AGENTBLUEPRINT__SETTINGS__CLIENTSECRET=
32-
CONNECTIONS__AGENTBLUEPRINT__SETTINGS__TENANTID=
3328

3429
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__TYPE=AgenticUserAuthorization
3530
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__ALT_BLUEPRINT_NAME=AGENTBLUEPRINT

β€Žpython/openai/sample-agent/agent.pyβ€Ž

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from token_cache import get_cached_agentic_token
2525

2626
# Load environment variables
27-
load_dotenv()
27+
load_dotenv(override=True)
2828

2929
# Configure logging
3030
logging.basicConfig(level=logging.INFO)
@@ -239,25 +239,41 @@ async def setup_mcp_servers(self, auth: Authorization, auth_handler_name: str, c
239239
"""Set up MCP server connections based on authentication configuration.
240240
241241
Authentication priority:
242-
1. Bearer token from config (BEARER_TOKEN) - for local development/testing
243-
2. Auth handler (auth_handler_name) - for production agentic auth
242+
1. Agentic auth (USE_AGENTIC_AUTH=true) - for production/Teams authentication
243+
2. Bearer token from config (BEARER_TOKEN) - for local development/testing
244244
3. No auth - gracefully skip MCP and run in bare LLM mode
245245
246246
If MCP connection fails for any reason, the agent will gracefully fall back
247247
to bare LLM mode without MCP tools.
248248
"""
249249
try:
250-
# Priority 1: Bearer token provided in config (for local dev/testing)
251-
if self.auth_options.bearer_token:
252-
logger.info("πŸ”‘ Using bearer token from config for MCP servers")
250+
# Check if agentic auth is enabled
251+
use_agentic_auth = os.getenv("USE_AGENTIC_AUTH", "false").lower() == "true"
252+
253+
# Priority 1: Agentic auth enabled (production/Teams authentication)
254+
# When USE_AGENTIC_AUTH=true, always use agentic auth - never fall back to bearer token
255+
if use_agentic_auth:
256+
if auth_handler_name:
257+
logger.info(f"πŸ”’ Using agentic auth handler '{auth_handler_name}' for MCP servers (USE_AGENTIC_AUTH=true)")
258+
else:
259+
logger.info("πŸ”’ Using agentic auth for MCP servers (USE_AGENTIC_AUTH=true, no explicit handler)")
260+
self.agent = await self.tool_service.add_tool_servers_to_agent(
261+
agent=self.agent,
262+
auth=auth,
263+
auth_handler_name=auth_handler_name,
264+
context=context,
265+
)
266+
# Priority 2: Bearer token provided in config (for local dev/testing when agentic auth is disabled)
267+
elif self.auth_options.bearer_token:
268+
logger.info("πŸ”‘ Using bearer token from config for MCP servers (USE_AGENTIC_AUTH=false)")
253269
self.agent = await self.tool_service.add_tool_servers_to_agent(
254270
agent=self.agent,
255271
auth=auth,
256272
auth_handler_name=auth_handler_name,
257273
context=context,
258274
auth_token=self.auth_options.bearer_token,
259275
)
260-
# Priority 2: Auth handler configured (production agentic auth)
276+
# Priority 3: Auth handler configured without USE_AGENTIC_AUTH flag
261277
elif auth_handler_name:
262278
logger.info(f"πŸ”’ Using auth handler '{auth_handler_name}' for MCP servers")
263279
self.agent = await self.tool_service.add_tool_servers_to_agent(
@@ -266,10 +282,10 @@ async def setup_mcp_servers(self, auth: Authorization, auth_handler_name: str, c
266282
auth_handler_name=auth_handler_name,
267283
context=context,
268284
)
269-
# Priority 3: No auth configured - skip MCP and run bare LLM
285+
# Priority 4: No auth configured - skip MCP and run bare LLM
270286
else:
271287
logger.warning("⚠️ No authentication configured - running in bare LLM mode without MCP tools")
272-
logger.info("πŸ’‘ To enable MCP: provide BEARER_TOKEN or configure AUTH_HANDLER_NAME")
288+
logger.info("πŸ’‘ To enable MCP: set USE_AGENTIC_AUTH=true, provide BEARER_TOKEN, or configure AUTH_HANDLER_NAME")
273289
# Agent already initialized without MCP tools
274290

275291
except Exception as e:

β€Žpython/openai/sample-agent/host_agent_server.pyβ€Ž

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
logger = logging.getLogger(__name__)
4949

5050
# Load configuration
51-
load_dotenv()
51+
load_dotenv(override=True)
5252
agents_sdk_config = load_configuration_from_env(environ)
5353

5454

@@ -196,6 +196,7 @@ async def initialize_agent(self):
196196

197197
def create_auth_configuration(self) -> AgentAuthConfiguration | None:
198198
"""Create authentication configuration based on available environment variables."""
199+
# Check for direct CLIENT_ID/TENANT_ID/CLIENT_SECRET env vars first
199200
client_id = environ.get("CLIENT_ID")
200201
tenant_id = environ.get("TENANT_ID")
201202
client_secret = environ.get("CLIENT_SECRET")
@@ -250,7 +251,7 @@ async def health(_req: Request) -> Response:
250251
if auth_configuration:
251252
middlewares.append(jwt_authorization_middleware)
252253

253-
# Anonymous claims middleware
254+
# Anonymous claims middleware - provides claims for unauthenticated requests
254255
@web_middleware
255256
async def anonymous_claims(request, handler):
256257
if not auth_configuration:
@@ -298,6 +299,10 @@ async def anonymous_claims(request, handler):
298299
)
299300
port = desired_port + 1
300301

302+
# For Azure App Service, bind to 0.0.0.0 to accept external connections
303+
host = environ.get("WEBSITE_HOSTNAME", None)
304+
bind_host = "0.0.0.0" if host else "localhost"
305+
301306
print("=" * 80)
302307
print(f"🏒 Generic Agent Host - {self.agent_class.__name__}")
303308
print("=" * 80)
@@ -306,13 +311,13 @@ async def anonymous_claims(request, handler):
306311
print("🎯 Compatible with Agents Playground")
307312
if port != desired_port:
308313
print(f"⚠️ Requested port {desired_port} busy; using fallback {port}")
309-
print(f"\nπŸš€ Starting server on localhost:{port}")
310-
print(f"πŸ“š Bot Framework endpoint: http://localhost:{port}/api/messages")
311-
print(f"❀️ Health: http://localhost:{port}/api/health")
314+
print(f"\nπŸš€ Starting server on {bind_host}:{port}")
315+
print(f"πŸ“š Bot Framework endpoint: http://{bind_host}:{port}/api/messages")
316+
print(f"❀️ Health: http://{bind_host}:{port}/api/health")
312317
print("🎯 Ready for testing!\n")
313318

314319
try:
315-
run_app(app, host="localhost", port=port)
320+
run_app(app, host=bind_host, port=port)
316321
except KeyboardInterrupt:
317322
print("\nπŸ‘‹ Server stopped")
318323
except Exception as error:

0 commit comments

Comments
Β (0)