Skip to main content

Overview

The Microsoft Agent Framework integrates seamlessly with Azure Functions to host agents as serverless HTTP services. The AgentFunctionApp (Python) and ConfigureDurableAgents (C#) provide automatic endpoint generation, session management, and multi-agent hosting capabilities.

Key Features

  • Auto-generated HTTP endpoints per agent (/api/agents/{name}/run)
  • Session management for multi-turn conversations
  • Multi-agent hosting in a single Functions app
  • Health checks for monitoring
  • Durable orchestrations for complex workflows
  • Reliable streaming with response callbacks

Quick Start

Python Setup

1

Install Azure Functions Core Tools

Install Azure Functions Core Tools v4.x:
2

Install Package

3

Create Function App

Create function_app.py:
4

Configure Settings

Create local.settings.json:
5

Create host.json

6

Start Function Host

C# Setup

1

Create Function Project

2

Add Package Reference

3

Create Program.cs

4

Configure Settings

Create local.settings.json:
5

Start Function Host

Single Agent Hosting

Host a single agent with automatic HTTP endpoint generation:

Testing the Agent

Response Format

Synchronous (default):
Asynchronous (with wait_for_response: false):

Multi-Agent Hosting

Host multiple specialized agents in a single Functions app:

Testing Multiple Agents

Agent Orchestrations

Create complex workflows by orchestrating multiple agent calls:

Testing Orchestrations

Configuration

host.json

Configure the Functions runtime:

local.settings.json

Advanced Features

Session Management

Maintain conversation context across requests:

Health Checks

Monitor agent availability:

Time-to-Live (TTL)

Configure agent session expiration:

Reliable Streaming

Implement resumable streaming with Redis:

Deployment to Azure

1

Create Function App

2

Configure App Settings

3

Deploy Code

4

Test Production Endpoint

Best Practices

Avoid API keys in production. Configure managed identity for Azure OpenAI access:
Monitor performance and errors:
Set appropriate session expiration based on use case:
  • Short-lived (30 min - 1 hour): Customer support chats
  • Medium-lived (2-4 hours): Development assistants
  • Long-lived (24+ hours): Personal assistants
For production, use Azure Storage instead of emulator:
Protect against abuse with Azure API Management or custom middleware.

Troubleshooting

Error: Cannot connect to Durable Task SchedulerSolution: Ensure DTS emulator is running:
Error: Azure OpenAI authentication failedSolution: Verify authentication:
Error: Agent name not found in registered agentsSolution: Verify agent registration and exact name match:

Next Steps

DurableTask Integration

Build long-running orchestrations

A2A Protocol

Connect distributed agents