How azure-samples/app-service-agentic-semantic-kernel-ai-foundry-agent works
1. This repo is a single .NET web application with three user-facing concerns: a CRUD task list, a chat UI backed by Microsoft Agent Framework, and a chat UI backed by Microsoft Foundry Agent Service. The app is organized as a Blazor-style component app, not as separate frontend/backend services.
2. Program.cs is the composition root. It wires the UI, registers application services, configures the task persistence layer, and connects the app to the two agent providers. This is the main boundary where framework setup, dependency injection, and environment-specific configuration come together.
3. The presentation layer lives under Components/. App.razor, Routes.razor, MainLayout.razor, and NavMenu.razor define the shell, navigation, and routing. The pages in Components/Pages/ map to the three main experiences: task management, Agent Framework chat, and Foundry chat, plus a shared error page.
4. The task management subsystem is centered on Models/TaskItem.cs, Models/TasksDbContext.cs, and Services/TaskService.cs. TaskService is the application-facing CRUD boundary, while TasksDbContext represents the persistence boundary through Entity Framework-style data access.
5. The task page (Components/Pages/TaskList.razor) talks to TaskService, not directly to the database. That keeps the UI isolated from storage details and makes the task domain reusable by other callers.
6. Tools/TaskCrudTool.cs is the integration boundary for external agents. It exposes task CRUD capabilities in a tool/OpenAPI-friendly form so an agent can call into the task domain without going through the human UI.
7. The agent subsystem is split into two provider abstractions under Services/: AgentFrameworkProvider.cs and FoundryAgentProvider.cs. These isolate the app from the specifics of each AI platform and let the two chat pages use different backends with a consistent internal shape.
8. Components/Pages/AgentFrameworkAgent.razor is the interactive front end for the Microsoft Agent Framework path. Components/Pages/FoundryAgent.razor is the corresponding front end for Foundry Agent Service. In both cases, the browser sends chat input to the app, the page delegates to its provider, and the provider handles the external agent call.
9. The repo’s external dependencies are primarily cloud services: the agent backend(s) and the persisted data store behind the DbContext. The app itself remains a single deployable unit, but it orchestrates calls across those external boundaries.
10. Deployment and environment setup are first-class parts of the architecture. azure.yaml and infra/main.bicep define Azure deployment infrastructure, while appsettings*.json and .devcontainer/launchSettings.json support local and cloud-specific configuration. wwwroot holds static assets for the app shell and styling.
Main entry points: Program.cs Program.cs · Routes.razor Routes · TaskService.cs Task service · App.razor App shell
Components 19
Presentation
Blazor-style UI shell and pages
- App shell · Top-level component and route entry point
Components/App.razor - Routes · Maps URLs to pages
Components/Routes.razor - Main layout · Shared page chrome and content frame
Components/Layout/MainLayout.razor - Nav menu · Primary navigation between app experiences
Components/Layout/NavMenu.razor - Task list · CRUD UI for tasks
Components/Pages/TaskList.razor - Agent Framework chat · Chat UI for Microsoft Agent Framework
Components/Pages/AgentFrameworkAgent.razor - Foundry chat · Chat UI for Microsoft Foundry Agent Service
Components/Pages/FoundryAgent.razor - Error page · Shared application error view
Components/Pages/Error.razor
Task Domain
Task CRUD model, persistence, and application service
- Task item · Task domain entity
Models/TaskItem.cs - Tasks DbContext · Entity Framework-style data boundary for tasks
Models/TasksDbContext.cs - Task service · CRUD boundary used by the UI and other callers
Services/TaskService.cs
Agent Integrations
Chat backends and agent-facing task tool
- Task CRUD tool · Agent-facing task operations in tool/OpenAPI-friendly form
Tools/TaskCrudTool.cs - AF provider · Adapter for Microsoft Agent Framework
Services/AgentFrameworkProvider.cs - Foundry provider · Adapter for Microsoft Foundry Agent Service
Services/FoundryAgentProvider.cs
Deployment
Azure and local environment setup
- azure.yaml · Azure app deployment descriptor
azure.yaml - main.bicep · Azure infrastructure definition
infra/main.bicep - App settings · Application and environment configuration
appsettings.json - Dev container · Containerized local development setup
.devcontainer/devcontainer.json
Other components
- Program.cs · Wires UI, services, persistence, and agent providers
Program.cs
Connections 25
- Program.cs → App shell: registers · Configures the component app shell
- Program.cs → Task service: adds · Registers the task application service
- Program.cs → Tasks DbContext: configures · Sets up persistence for task data
- Program.cs → AF provider: wires · Connects the Agent Framework backend
- Program.cs → Foundry provider: wires · Connects the Foundry backend
- App shell → Routes: uses · Delegates page resolution to routing
- App shell → Main layout: hosts · Uses the shared page layout
- Main layout → Nav menu: contains · Renders primary navigation
- Routes → Task list: maps to · Task management experience
- Routes → Agent Framework chat: maps to · Agent Framework chat experience
- Routes → Foundry chat: maps to · Foundry chat experience
- Routes → Error page: maps to · Shared error view
- Task list → Task service: calls · Uses the application CRUD boundary
- Task service → Tasks DbContext: persists via · Reads and writes through the DbContext
- Tasks DbContext → Task item: stores · Materializes task entities
- Task list → Task item: renders · Displays task data in the UI
- Task CRUD tool → Task service: invokes · Exposes task CRUD to external agents
- Agent Framework chat → AF provider: delegates to · Sends chat requests to the Agent Framework adapter
- Foundry chat → Foundry provider: delegates to · Sends chat requests to the Foundry adapter
- AF provider → Task CRUD tool: may use · Can reach task operations through the tool boundary
- Foundry provider → Task CRUD tool: may use · Can reach task operations through the tool boundary
- Program.cs → azure.yaml: deploys with · Azure deployment descriptor participates in app delivery
- Program.cs → main.bicep: infra by · Infrastructure is defined separately from the app
- Program.cs → App settings: configures · Reads environment and app settings
- Program.cs → Dev container: supports · Local development environment setup