Python: Move azurefunctions to azure for import (#2141)

* Move import to Azure

* fix mypy

* Update python/packages/azurefunctions/README.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add missing types

* Address comments

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Laveesh Rohra
2025-11-12 12:13:25 -08:00
committed by GitHub
Unverified
parent 601b75a418
commit f3bf488735
20 changed files with 156 additions and 126 deletions
@@ -8,8 +8,7 @@ Prerequisites: set `AZURE_OPENAI_ENDPOINT` and `AZURE_OPENAI_CHAT_DEPLOYMENT_NAM
from typing import Any
from agent_framework.azure import AzureOpenAIChatClient
from agent_framework.azurefunctions import AgentFunctionApp
from agent_framework.azure import AgentFunctionApp, AzureOpenAIChatClient
from azure.identity import AzureCliCredential
# 1. Instantiate the agent with the chosen deployment and instructions.
def _create_agent() -> Any:
@@ -11,8 +11,7 @@ Prerequisites: set `AZURE_OPENAI_ENDPOINT` and `AZURE_OPENAI_CHAT_DEPLOYMENT_NAM
import logging
from typing import Any
from agent_framework.azure import AzureOpenAIChatClient
from agent_framework.azurefunctions import AgentFunctionApp
from agent_framework.azure import AgentFunctionApp, AzureOpenAIChatClient
from azure.identity import AzureCliCredential
logger = logging.getLogger(__name__)
@@ -16,11 +16,14 @@ from typing import Any, DefaultDict
import azure.functions as func
from agent_framework import AgentRunResponseUpdate
from agent_framework.azure import AzureOpenAIChatClient
from agent_framework.azure import (
AgentCallbackContext,
AgentFunctionApp,
AgentResponseCallbackProtocol,
AzureOpenAIChatClient,
)
from azure.identity import AzureCliCredential
from agent_framework.azurefunctions import AgentFunctionApp, AgentCallbackContext, AgentResponseCallbackProtocol
logger = logging.getLogger(__name__)
@@ -14,10 +14,9 @@ from typing import Any
import azure.durable_functions as df
import azure.functions as func
from agent_framework.azure import AzureOpenAIChatClient
from agent_framework.azure import AgentFunctionApp, AzureOpenAIChatClient
from azure.durable_functions import DurableOrchestrationContext
from azure.identity import AzureCliCredential
from agent_framework.azurefunctions import AgentFunctionApp, get_agent
logger = logging.getLogger(__name__)
@@ -49,7 +48,7 @@ app = AgentFunctionApp(agents=[_create_writer_agent()], enable_health_check=True
def single_agent_orchestration(context: DurableOrchestrationContext):
"""Run the writer agent twice on the same thread to mirror chaining behaviour."""
writer = get_agent(context, WRITER_AGENT_NAME)
writer = app.get_agent(context, WRITER_AGENT_NAME)
writer_thread = writer.get_new_thread()
initial = yield writer.run(
@@ -14,10 +14,9 @@ from typing import Any
import azure.durable_functions as df
import azure.functions as func
from agent_framework.azure import AzureOpenAIChatClient
from agent_framework.azure import AgentFunctionApp, AzureOpenAIChatClient
from azure.durable_functions import DurableOrchestrationContext
from azure.identity import AzureCliCredential
from agent_framework.azurefunctions import AgentFunctionApp, get_agent
logger = logging.getLogger(__name__)
@@ -59,8 +58,8 @@ def multi_agent_concurrent_orchestration(context: DurableOrchestrationContext):
if not prompt or not str(prompt).strip():
raise ValueError("Prompt is required")
physicist = get_agent(context, PHYSICIST_AGENT_NAME)
chemist = get_agent(context, CHEMIST_AGENT_NAME)
physicist = app.get_agent(context, PHYSICIST_AGENT_NAME)
chemist = app.get_agent(context, CHEMIST_AGENT_NAME)
physicist_thread = physicist.get_new_thread()
chemist_thread = chemist.get_new_thread()
@@ -11,15 +11,14 @@ Functions host."""
import json
import logging
from typing import Any, cast
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 AzureOpenAIChatClient
from agent_framework.azure import AgentFunctionApp, AzureOpenAIChatClient
from azure.durable_functions import DurableOrchestrationContext
from azure.identity import AzureCliCredential
from agent_framework.azurefunctions import AgentFunctionApp, get_agent
from pydantic import BaseModel, ValidationError
logger = logging.getLogger(__name__)
@@ -85,8 +84,8 @@ def spam_detection_orchestration(context: DurableOrchestrationContext):
except ValidationError as exc:
raise ValueError(f"Invalid email payload: {exc}") from exc
spam_agent = get_agent(context, SPAM_AGENT_NAME)
email_agent = get_agent(context, EMAIL_AGENT_NAME)
spam_agent = app.get_agent(context, SPAM_AGENT_NAME)
email_agent = app.get_agent(context, EMAIL_AGENT_NAME)
spam_thread = spam_agent.get_new_thread()
@@ -10,16 +10,15 @@ either `AZURE_OPENAI_API_KEY` or sign in with Azure CLI before running `func sta
import json
import logging
from collections.abc import Mapping
from datetime import timedelta
from typing import Any
from collections.abc import Mapping
import azure.durable_functions as df
import azure.functions as func
from agent_framework.azure import AzureOpenAIChatClient
from agent_framework.azure import AgentFunctionApp, AzureOpenAIChatClient
from azure.durable_functions import DurableOrchestrationContext
from azure.identity import AzureCliCredential
from agent_framework.azurefunctions import AgentFunctionApp, get_agent
from pydantic import BaseModel, ValidationError
logger = logging.getLogger(__name__)
@@ -92,7 +91,7 @@ def content_generation_hitl_orchestration(context: DurableOrchestrationContext):
except ValidationError as exc:
raise ValueError(f"Invalid content generation input: {exc}") from exc
writer = get_agent(context, WRITER_AGENT_NAME)
writer = app.get_agent(context, WRITER_AGENT_NAME)
writer_thread = writer.get_new_thread()
context.set_custom_status(f"Starting content generation for topic: {payload.topic}")