Skip to content

kshyju/AgentWorkflowsOnAzureFunctions

Repository files navigation

Durable AI Agent Workflows on Azure Functions

Sample projects demonstrating how to host Microsoft Agent Framework workflows on Azure Functions. Each sample is a standalone Azure Functions app you can run locally.

Samples

Sample Description
SequentialWorkflow A simple three-step pipeline: look up an order, cancel it, and send a confirmation email.
FanInFanout Parallel execution — a physics expert and chemistry expert answer the same question concurrently, then an aggregator combines their responses. Requires Azure OpenAI.
HumanInTheLoop Expense reimbursement with three approval gates — manager approval followed by parallel budget and compliance approvals using RequestPort.
AgentsAndWorkflows Combines AI agents and workflows — reuses the same executor across multiple workflows, uses an AI agent as a workflow step, and registers everything via ConfigureDurableOptions. Requires Azure OpenAI.
WorkflowMcpTool Expose durable workflows as MCP tools — two workflows (Translate and OrderLookup) are callable via the MCP Inspector or any MCP-compatible client.

Prerequisites

Setting Up the Durable Task Scheduler Emulator

The samples use the Durable Task Scheduler for durable workflow state. For local development, run the emulator using Docker:

docker run -d --name dts-emulator -p 8080:8080 -p 8082:8082 mcr.microsoft.com/dts/dts-emulator:latest

This starts the emulator on port 8080 (gRPC) and 8082 (dashboard). The samples are preconfigured to connect to this emulator via the DURABLE_TASK_SCHEDULER_CONNECTION_STRING setting in each local.settings.json:

Endpoint=http://localhost:8080;TaskHub=default;Authentication=None

You also need Azurite running for Azure Storage emulation (required by the Azure Functions runtime). See the section below.

Setting Up Azurite (Azure Storage Emulator)

Azurite is an open-source Azure Storage emulator required by the Azure Functions host. The samples reference it via "AzureWebJobsStorage": "UseDevelopmentStorage=true" in local.settings.json.

Option 1: Docker (recommended)

docker run -d --name azurite -p 10000:10000 -p 10001:10001 -p 10002:10002 mcr.microsoft.com/azure-storage/azurite

This starts Blob (10000), Queue (10001), and Table (10002) services.

Option 2: npm

npm install -g azurite
azurite --silent

Option 3: VS Code Extension

Install the Azurite extension and start it from the command palette (Azurite: Start).

Running Locally

  1. Start the Durable Task Scheduler emulator and Azurite.

  2. Navigate to a sample folder and run:

    cd SequentialWorkflow
    func start
  3. Invoke the workflow:

    curl -X POST http://localhost:7071/api/workflows/CancelOrder/run \
      -H "Content-Type: text/plain" \
      -d "12345"

For the FanInFanout sample, update local.settings.json with your Azure OpenAI endpoint, deployment name, and optionally an API key before running.

For the HumanInTheLoop sample, the workflow pauses at approval gates. Use the status and respond endpoints to interact:

# Check status
curl http://localhost:7071/api/workflows/ExpenseReimbursement/status/{runId}

# Submit approval
curl -X POST http://localhost:7071/api/workflows/ExpenseReimbursement/respond/{runId} \
  -H "Content-Type: application/json" \
  -d '{"eventName": "ManagerApproval", "response": {"approved": true, "comments": "Looks good"}}'

Blog Post

These samples accompany the blog post: Durable AI Agent Workflows on Azure Functions

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages