From e5163229180359d6ba769429c59374b9cf2f7e54 Mon Sep 17 00:00:00 2001 From: Laveesh Rohra Date: Thu, 13 Nov 2025 17:15:16 -0800 Subject: [PATCH] Python: Fix Readme and samples for AzureFunctions (#2197) * Fix REadme and samples * Update instanceId placeholder in demo.http * Update python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../function_app.py | 7 +++---- .../function_app.py | 7 +++---- .../06_multi_agent_orchestration_conditionals/README.md | 4 ++-- .../function_app.py | 7 +++---- .../07_single_agent_orchestration_hitl/function_app.py | 9 ++++----- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/python/samples/getting_started/azure_functions/04_single_agent_orchestration_chaining/function_app.py b/python/samples/getting_started/azure_functions/04_single_agent_orchestration_chaining/function_app.py index 15a95327b9..377af2763a 100644 --- a/python/samples/getting_started/azure_functions/04_single_agent_orchestration_chaining/function_app.py +++ b/python/samples/getting_started/azure_functions/04_single_agent_orchestration_chaining/function_app.py @@ -12,10 +12,9 @@ import json import logging from typing import Any -import azure.durable_functions as df import azure.functions as func from agent_framework.azure import AgentFunctionApp, AzureOpenAIChatClient -from azure.durable_functions import DurableOrchestrationContext +from azure.durable_functions import DurableOrchestrationClient, DurableOrchestrationContext from azure.identity import AzureCliCredential logger = logging.getLogger(__name__) @@ -74,7 +73,7 @@ def single_agent_orchestration(context: DurableOrchestrationContext): @app.durable_client_input(client_name="client") async def start_single_agent_orchestration( req: func.HttpRequest, - client: df.DurableOrchestrationClient, + client: DurableOrchestrationClient, ) -> func.HttpResponse: """Start the orchestration and return status metadata.""" @@ -104,7 +103,7 @@ async def start_single_agent_orchestration( @app.durable_client_input(client_name="client") async def get_orchestration_status( req: func.HttpRequest, - client: df.DurableOrchestrationClient, + client: DurableOrchestrationClient, ) -> func.HttpResponse: """Return orchestration runtime status.""" diff --git a/python/samples/getting_started/azure_functions/05_multi_agent_orchestration_concurrency/function_app.py b/python/samples/getting_started/azure_functions/05_multi_agent_orchestration_concurrency/function_app.py index 6d0fd17eca..59f59a4f40 100644 --- a/python/samples/getting_started/azure_functions/05_multi_agent_orchestration_concurrency/function_app.py +++ b/python/samples/getting_started/azure_functions/05_multi_agent_orchestration_concurrency/function_app.py @@ -12,10 +12,9 @@ import json import logging from typing import Any -import azure.durable_functions as df import azure.functions as func from agent_framework.azure import AgentFunctionApp, AzureOpenAIChatClient -from azure.durable_functions import DurableOrchestrationContext +from azure.durable_functions import DurableOrchestrationClient, DurableOrchestrationContext from azure.identity import AzureCliCredential logger = logging.getLogger(__name__) @@ -80,7 +79,7 @@ def multi_agent_concurrent_orchestration(context: DurableOrchestrationContext): @app.durable_client_input(client_name="client") async def start_multi_agent_concurrent_orchestration( req: func.HttpRequest, - client: df.DurableOrchestrationClient, + client: DurableOrchestrationClient, ) -> func.HttpResponse: """Kick off the orchestration with a plain text prompt.""" @@ -121,7 +120,7 @@ async def start_multi_agent_concurrent_orchestration( @app.durable_client_input(client_name="client") async def get_orchestration_status( req: func.HttpRequest, - client: df.DurableOrchestrationClient, + client: DurableOrchestrationClient, ) -> func.HttpResponse: instance_id = req.route_params.get("instanceId") if not instance_id: diff --git a/python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/README.md b/python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/README.md index 3271f88744..da38bf0dd6 100644 --- a/python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/README.md +++ b/python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/README.md @@ -16,9 +16,9 @@ Set up the shared prerequisites outlined in `../README.md`, including the virtua Submit an email payload: ```bash -curl -X POST http://localhost:7071/api/spamdetection/run \ +curl -X POST "http://localhost:7071/api/spamdetection/run" \ -H "Content-Type: application/json" \ - -d '{"subject": "Sale now on", "body": "Limited time offer"}' + -d '{"email_id": "email-001", "email_content": "URGENT! You'\''ve won $1,000,000! Click here now to claim your prize! Limited time offer! Don'\''t miss out!"}' ``` Poll the returned `statusQueryGetUri` or call the status route directly: diff --git a/python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/function_app.py b/python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/function_app.py index a5991e76f5..84d114b3b5 100644 --- a/python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/function_app.py +++ b/python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/function_app.py @@ -14,10 +14,9 @@ import logging from collections.abc import Mapping from typing import Any, cast -import azure.durable_functions as df import azure.functions as func from agent_framework.azure import AgentFunctionApp, AzureOpenAIChatClient -from azure.durable_functions import DurableOrchestrationContext +from azure.durable_functions import DurableOrchestrationClient, DurableOrchestrationContext from azure.identity import AzureCliCredential from pydantic import BaseModel, ValidationError @@ -134,7 +133,7 @@ def spam_detection_orchestration(context: DurableOrchestrationContext): @app.durable_client_input(client_name="client") async def start_spam_detection_orchestration( req: func.HttpRequest, - client: df.DurableOrchestrationClient, + client: DurableOrchestrationClient, ) -> func.HttpResponse: try: body = req.get_json() @@ -185,7 +184,7 @@ async def start_spam_detection_orchestration( @app.durable_client_input(client_name="client") async def get_orchestration_status( req: func.HttpRequest, - client: df.DurableOrchestrationClient, + client: DurableOrchestrationClient, ) -> func.HttpResponse: instance_id = req.route_params.get("instanceId") if not instance_id: diff --git a/python/samples/getting_started/azure_functions/07_single_agent_orchestration_hitl/function_app.py b/python/samples/getting_started/azure_functions/07_single_agent_orchestration_hitl/function_app.py index aac7d092f1..7257ff7831 100644 --- a/python/samples/getting_started/azure_functions/07_single_agent_orchestration_hitl/function_app.py +++ b/python/samples/getting_started/azure_functions/07_single_agent_orchestration_hitl/function_app.py @@ -14,10 +14,9 @@ from collections.abc import Mapping from datetime import timedelta from typing import Any -import azure.durable_functions as df import azure.functions as func from agent_framework.azure import AgentFunctionApp, AzureOpenAIChatClient -from azure.durable_functions import DurableOrchestrationContext +from azure.durable_functions import DurableOrchestrationClient, DurableOrchestrationContext from azure.identity import AzureCliCredential from pydantic import BaseModel, ValidationError @@ -160,7 +159,7 @@ def content_generation_hitl_orchestration(context: DurableOrchestrationContext): @app.durable_client_input(client_name="client") async def start_content_generation( req: func.HttpRequest, - client: df.DurableOrchestrationClient, + client: DurableOrchestrationClient, ) -> func.HttpResponse: try: body = req.get_json() @@ -209,7 +208,7 @@ async def start_content_generation( @app.durable_client_input(client_name="client") async def send_human_approval( req: func.HttpRequest, - client: df.DurableOrchestrationClient, + client: DurableOrchestrationClient, ) -> func.HttpResponse: instance_id = req.route_params.get("instanceId") if not instance_id: @@ -260,7 +259,7 @@ async def send_human_approval( @app.durable_client_input(client_name="client") async def get_orchestration_status( req: func.HttpRequest, - client: df.DurableOrchestrationClient, + client: DurableOrchestrationClient, ) -> func.HttpResponse: instance_id = req.route_params.get("instanceId") if not instance_id: