AI Automation & Agents  

Building an AI Task Management Agent using Microsoft Agentic AI Framework

Learn how to build a smart task management assistant using Microsoft's Agentic AI Framework, Azure OpenAI, and Clean Architecture principles.

What is Agentic AI?

Traditional chatbots just respond to what you say. Agentic AI goes further—it thinks, plans, and acts autonomously. Instead of you telling it exactly what to do, you simply describe what you want, and the agent figures out the best way to help you.

The Microsoft Agentic AI Framework makes this easy by letting AI agents:

  • Choose their own tools: The agent decides which functions to call

  • Remember context: Maintains conversation history for natural interactions

  • Act autonomously: Executes multi-step tasks without hand-holding

  • Integrate seamlessly: Works natively with Azure OpenAI

Why This Matters

In this guide, we built a Task Agent that helps you manage your to-do list through natural conversation. You can say things like:

  • "Create a task to review the project proposal with high priority".

  • "Show me all my pending tasks".

  • "Mark task 3 as completed".

The agent understands your intent, calls the right functions, and presents results beautifully with tables and smart suggestions.

What You'll Learn

  1. How to set up Azure OpenAI and deploy a model

  2. How to create function tools that agents can call automatically

  3. How to design effective agent instructions for better UX

  4. How to integrate agents into a Clean Architecture web application

  5. Best practices for presentation and contextual suggestions

Azure OpenAI Setup

Creating an Azure OpenAI Resource

Azure OpenAI provides enterprise-grade hosting for OpenAI's powerful language models with enhanced security, compliance, and regional availability.

Step 1. Access Azure Portal

  1. Navigate to Azure Portal

  2. Sign in with your Azure account

Step 2. Create the Resource

  1. Click "Create a resource" or use the search bar to find "Azure OpenAI"

  2. Select Azure OpenAI from Microsoft

  3. Click Create

Step 3. Configure Basic Settings

Fill in the required fields:

  • Subscription: Select your Azure subscription

  • Resource Group: Create new or use existing (e.g., rg-ai-agents )

  • Region: Choose a region that supports GPT-4o-mini (e.g., East US, West Europe)

  • Name: Unique name for your resource (e.g., openai-weather-agent )

  • Pricing Tier: Standard S0

1

Step 4. Review and Create

  1. Review your settings (leave the other tabs with the default)

  2. Click Create

  3. Click Go to resource when finished

2

Deploying a Model

After creating your Azure OpenAI resource, you need to deploy a model to use it.

Step 1. Navigate to Azure AI Foundry

In your Azure OpenAI resource, click Go to Azure AI Foundry portal.

3

Step 2. Create a Deployment

Select Deployments from the left menu.

4

Click + Create new deployment.

5

Configure the deployment:

  • Model: Select gpt-4o-mini (recommended for cost/performance)

6
  • Deployment name: gpt-4o-mini (or your preference)

  • Model version: Use the latest available

  • Deployment type: Standard

  • Tokens per minute rate limit: 10K (adjust based on needs)

7

Click Create.

Getting Your Credentials

Step 1. Access Keys and Endpoint

  1. Return to Azure Portal

  2. Navigate to your Azure OpenAI resource

  3. Click Keys and Endpoint in the left menu

8

Step 2. Copy Required Values

You'll need three values:

  • Endpoint: URL like https://your-resource.openai.azure.com/

  • Key 1 or Key 2: Your API key

  • Deployment Name: The name you chose (e.g., gpt-4o-mini)

Once you have created and deployed the OpenAI model, you can use the API Keys in the .NET project. Clone it here.

Understanding the Framework

How It Works

When you send a message to the agent:

  1. Agent receives your message + conversation history

  2. LLM analyzes what you want and which tools it needs

  3. Framework calls the selected functions automatically

  4. Results go back to the LLM

  5. Agent responds with natural language and formatted output

You don't write routing logic—the agent decides everything.

Key Concepts

AI Agent: The brain of your application

AIAgent agent = chatClient.CreateAIAgent(
    instructions: "You are Task Agent, a task management assistant.",
    tools: [createTaskTool, listTasksTool, updateTaskTool]);

Function Tools: C# methods the agent can call

[Description("Create a new task")]
public async Task<string> CreateTask(
    [Description("Task title")] string title,
    [Description("Priority: Low, Medium, High")] string priority = "Medium")
{
    // Your business logic here
}

Threads: Conversation sessions with memory

var thread = agent.GetNewThread();
await agent.RunAsync("Create a task", thread);
await agent.RunAsync("Show me all tasks", thread); // Remembers context

Building the Task Agent

The Architecture

We use Clean Architecture with 4 layers:

Domain (Core Business Logic)
   ↑
Application (Use Cases & Interfaces)
   ↑
Infrastructure (Data Access)
   ↑
Presentation (Web UI & Controllers

This keeps the AI agent separate from the database, making it easy to test and maintain.

Creating Function Tools

Our Task Agent has 6 tools that cover full CRUD operations:

  1. CreateTask - Creates new tasks

  2. ListTasks - Shows all tasks (with optional filters)

  3. GetTaskDetails - Gets info about a specific task

  4. UpdateTask - Changes task status or priority

  5. DeleteTask - Removes tasks

  6. GetTaskSummary - Shows statistics

Key Points

  • Each method has a clear [Description] so the LLM knows when to use it

  • Parameters also have descriptions to help with understanding

  • Return strings that the agent can present naturally

  • Let the agent handle formatting based on instructions

Designing Agent Instructions

This is where the magic happens. Good instructions make the difference between an OK agent and a great one.

What We Tell Our Agent:

  1. Who you are: "You are Task Agent, a professional task management assistant"

  2. What you can do: List all capabilities clearly

  3. How to behave

    • Act immediately when users give clear instructions

    • Don't ask for confirmation unnecessarily

    • Be direct and action-oriented

  4. How to present information:

    • Always use Markdown tables for listing 2+ tasks

    • Use emojis for status (⏳ Pending, 🔄 InProgress, âś… Completed)

    • Use emojis for priority (🟢 Low, 🟡 Medium, đź”´ High)

  5. Provide contextual suggestions:

    • After creating a task: "đź’ˇ Suggestions: • View all tasks • Create a follow-up"

    • After listing: "đź’ˇ Suggestions: • Filter by priority • Update oldest task"

    • After completing: "đź’ˇ Suggestions: • View remaining tasks • Get summary"

Example Interaction

Below are some screenshots demonstrating the usage of the Task Agent.

9101112

As you saw, you can practice the CRUD operations with the AI Agent.

Best Practices

Agent Design

  • Be specific in instructions: Don't just say "help with tasks"—explain exactly how

  • Use examples: Show good vs bad behavior in the instructions

  • Format by default: Tell the agent to use tables unless asked otherwise

  • Provide suggestions: Help users discover features through contextual hints

  • Use emojis strategically: Visual clarity without going overboard

Function Tools

  • Single responsibility: Each function does one thing wellClear descriptions: Both method and parameters need good descriptions

  • Sensible defaults: Make common use cases easy

  • Fast execution: Agents may call multiple functions per request

  • Error handling: Return user-friendly error messages

Security

  • Never expose API keys: Use environment variables or Azure Key Vault

  • Sanitize output: Always use DOMPurify before rendering HTML

  • Validate input: Check user input before passing to functions

  • Rate limiting: Protect your Azure OpenAI quota

  • Authentication: Add user authentication for production

Performance

  • Use scoped services: Better for request isolation in web apps

  • Cache when possible: Don't re-query unchanged data

  • Set token limits: Control costs with appropriate rate limits

  • Monitor usage: Track API calls and costs in Azure Portal

What's Next?

Now that you have a working Task Agent, you can:

  1. Add more features: Due dates, categories, attachments, search

  2. Improve intelligence: Analyze patterns, suggest priorities, detect blockers

  3. Integrate services: Connect to calendar, email, project management tools

  4. Deploy to Azure: Host on Azure App Service with CI/CD

  5. Add authentication: Integrate Azure AD or other identity providers

The beauty of Agentic AI is that adding new capabilities is easy—just create new function tools and update the instructions. The agent handles the rest!

Final Thoughts

The Microsoft Agentic AI Framework represents a significant leap forward in building intelligent applications. By abstracting the complexity of function calling, context management, and LLM integration, it enables developers to focus on business logic and user experience.