Build Long-Running AI Agents on Azure App Service with Microsoft Agent Framework
jordanselig delivers a comprehensive guide on developing robust, intelligent AI agents using Microsoft Agent Framework and Azure App Service, addressing long-running workflow scenarios with modern async architectures.
Build Long-Running AI Agents on Azure App Service with Microsoft Agent Framework
The AI landscape is evolving rapidly. With the introduction of Microsoft Agent Framework, developers now have a platform for building sophisticated AI agents capable of handling complex, multi-step workflows and persisting conversation context—far beyond simple LLM chat completions.
The Challenge: Long-Running Agent Flows
Production AI applications often require workflows such as:
- Multi-turn reasoning and iterative LLM calls
- Tool/function integration and external real-time data queries
- Multi-phase business logic (e.g., itinerary building, budgeting)
- Conversation and state persistence
These often exceed the time limits of synchronous HTTP requests, leading to problems like timeouts, client disconnects, and scalability bottlenecks.
The Solution: Async Pattern with Azure App Service
The recommended implementation leverages Azure App Service for both the API and background workers using an async request-reply approach:
- API immediately responds (202 Accepted) with a task ID
- Background worker processes the Agent Framework task
- Client polls status endpoints, receiving progress updates
- Cosmos DB stores durable state and results
Key Azure Services:
- App Service (P0v4 Premium) for hosting REST API & workers in one deployment
- Service Bus for decoupling API from long-running agent orchestration
- Cosmos DB for status, task results, and cleanup
- AI Foundry for agent execution, thread management, and LLM integration
Sample Reference: AI Travel Planner App
The article features a practical travel planner app where an AI agent:
- Researches attractions & activities
- Optimizes schedules
- Calculates budgets
- Delivers personalized travel tips
App Service runs both the API and background worker for simplicity. Service Bus and Cosmos DB manage reliability and persistence. Foundation models like GPT-4o provide intelligence.
Key Advantages of Azure App Service
- Simple deployments, no containers or orchestrations required
- Combined API and worker reduce complexity and operational overhead
- Enterprise readiness: managed identity, private endpoints, built-in monitoring
- Cost-effectiveness: single instance covers both workloads
- Familiar tools: CI/CD, Application Insights, deployment slots
- Flexible scaling and rapid updates as Agent Framework evolves
Comparison with Other Azure Architectures
Summarizes trade-offs of Durable Functions, background jobs, and Container Apps, advocating App Service for rapid, manageable, and cost-efficient deployment.
Architecture Visibility: Inspecting Agents and Conversation Threads
Azure AI Foundry lets you inspect and debug agent runs and conversation histories directly within the Azure portal, offering transparency for advanced workflows.
Get Started
Deploy the reference app via GitHub: https://github.com/Azure-Samples/app-service-agent-framework-travel-agent-dotnet
- .NET 9 source code
- Bicep IaC templates
- Web UI
- Full setup/deployment documentation
Extend and Innovate
The guide highlights how to build upon this foundation:
- Add tool-calling for live APIs (weather, pricing, availability)
- Multi-agent systems for collaboration
- Retrieval-augmented generation (RAG)
- Real-time interactivity and multi-language expansion
Learn More
Have you built similar AI agents? Share your experience or ask questions below!
This post appeared first on “Microsoft Tech Community”. Read the entire article here