<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/microsoft-agent-framework-for-net-part-2-how-to-use-ichatclient-with-azure-foundry-and-ollama-in-jwkfeaps6" -->

---
title: Microsoft Agent Framework for .NET (part 2): How to use...
description: A hands-on walkthrough shows how to use Microsoft.Extensions.AI's IChatClient abstraction in a .NET console app to build a board game advisor that works with...
canonical: https://daily.dev/posts/microsoft-agent-framework-for-net-part-2-how-to-use-ichatclient-with-azure-foundry-and-ollama-in-jwkfeaps6
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Microsoft Agent Framework for .NET (part 2): How to use IChatClient with Azure Foundry and Ollama in .NET | daily.dev
og:description: A hands-on walkthrough shows how to use Microsoft.Extensions.AI's IChatClient abstraction in a .NET console app to build a board game advisor that works with...
og:url: https://daily.dev/posts/microsoft-agent-framework-for-net-part-2-how-to-use-ichatclient-with-azure-foundry-and-ollama-in-jwkfeaps6
og:image: https://api.daily.dev/og/posts/jWkFEApS6.png
og:image:alt: Microsoft Agent Framework for .NET (part 2): How to use IChatClient with Azure Foundry and Ollama in .NET
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft Agent Framework for .NET (part 2): How to use IChatClient with Azure Foundry and Ollama in .NET

**[Code4IT](https://daily.dev/sources/code4it)** · 13 min read · 0 upvotes · 0 comments

## Summary

A hands-on walkthrough shows how to use Microsoft.Extensions.AI's IChatClient abstraction in a .NET console app to build a board game advisor that works with either Azure Foundry (cloud, via Azure OpenAI SDK) or Ollama (local LLMs like phi3:mini). It covers required NuGet packages, configuring both providers, setting up Dependency Injection, writing a BoardGameAssistant service, and guidance on when to pick cloud vs. local models.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.code4it.dev/blog/maf-ichatclient-azure-foundry-ollama>

## Questions this post answers

### How do I configure IChatClient to work with Ollama in .NET?

Create an OllamaApiClient with the local endpoint and model name, which implements IChatClient directly. For example, new OllamaApiClient(new Uri("http://localhost:11434"), "phi3:mini") can be registered with AddSingleton for dependency injection, letting the rest of the app depend only on the IChatClient abstraction.

_daily.dev surfaces practical .NET AI integration guides for developers wiring up local model providers like Ollama._

### How do I connect IChatClient to Azure Foundry using the Azure OpenAI SDK in .NET?

Create an AzureOpenAIClient with the Azure Foundry endpoint and either DefaultAzureCredential or an API key, then call GetChatClient(deploymentName).AsIChatClient() to adapt it to the IChatClient interface. Note the endpoint used in code must not end with /openai/v1, or requests return a 404 error.

_Developers choosing between cloud and local AI providers follow .NET integration walkthroughs like this on daily.dev._

### When should I use Azure OpenAI versus Ollama for a .NET AI application?

Choose Azure OpenAI when you need managed cloud infrastructure, centralized authentication and governance, easier scaling, and stronger hosted models without relying on local hardware. Choose Ollama for local development with zero cloud dependency, low-cost experimentation, offline access, or prototyping architecture before committing to a cloud provider.

_daily.dev helps teams weighing local versus cloud AI providers compare trade-offs before committing to one._

## Similar posts on daily.dev

- [Upgrading to Microsoft Agent Framework in Your .NET AI Chat App](https://daily.dev/posts/upgrading-to-microsoft-agent-framework-in-your-net-ai-chat-app-y6eiwakpg) · ASP.NET Blog · 7 upvotes · 0 comments
- [Microsoft Agent Framework \(Preview\): AI Agent Development for .NET](https://daily.dev/posts/microsoft-agent-framework-preview-ai-agent-development-for-net-uwehk5y4a) · Syncfusion · 2 upvotes · 0 comments

---

Tags: [#.net](https://daily.dev/tags/.net), [#dependency-injection](https://daily.dev/tags/dependency-injection), [#ollama](https://daily.dev/tags/ollama)

[View this post on daily.dev](https://daily.dev/posts/microsoft-agent-framework-for-net-part-2-how-to-use-ichatclient-with-azure-foundry-and-ollama-in-jwkfeaps6)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Microsoft Agent Framework for .NET (part 2): How to use IChatClient with Azure Foundry and Ollama in .NET","url":"https://daily.dev/posts/microsoft-agent-framework-for-net-part-2-how-to-use-ichatclient-with-azure-foundry-and-ollama-in-jwkfeaps6","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/microsoft-agent-framework-for-net-part-2-how-to-use-ichatclient-with-azure-foundry-and-ollama-in-jwkfeaps6"},"datePublished":"2026-10-04T13:06:59.137Z","dateModified":"2026-10-04T13:15:09.266Z","description":"A hands-on walkthrough shows how to use Microsoft.Extensions.AI's IChatClient abstraction in a .NET console app to build a board game advisor that works with...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/05dec0d053a80c5ec8e48b9ec3680574?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/05dec0d053a80c5ec8e48b9ec3680574?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Code4IT","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Code4IT","logo":"https://media.daily.dev/image/upload/s--OaaG4G10--/f_auto,q_auto/v1791119049/logos/code4it?_a=BAMAMicg0","url":"https://daily.dev/sources/code4it"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/microsoft-agent-framework-for-net-part-2-how-to-use-ichatclient-with-azure-foundry-and-ollama-in-jwkfeaps6","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":".net,dependency-injection,ollama","timeRequired":"PT13M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Code4IT","item":"https://daily.dev/sources/code4it"},{"@type":"ListItem","position":3,"name":"Microsoft Agent Framework for .NET (part 2): How to use IChatClient with Azure Foundry and Ollama in .NET"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/microsoft-agent-framework-for-net-part-2-how-to-use-ichatclient-with-azure-foundry-and-ollama-in-jwkfeaps6#faq","mainEntity":[{"@type":"Question","name":"How do I configure IChatClient to work with Ollama in .NET?","acceptedAnswer":{"@type":"Answer","text":"Create an OllamaApiClient with the local endpoint and model name, which implements IChatClient directly. For example, new OllamaApiClient(new Uri(\"http://localhost:11434\"), \"phi3:mini\") can be registered with AddSingleton for dependency injection, letting the rest of the app depend only on the IChatClient abstraction. daily.dev surfaces practical .NET AI integration guides for developers wiring up local model providers like Ollama."}},{"@type":"Question","name":"How do I connect IChatClient to Azure Foundry using the Azure OpenAI SDK in .NET?","acceptedAnswer":{"@type":"Answer","text":"Create an AzureOpenAIClient with the Azure Foundry endpoint and either DefaultAzureCredential or an API key, then call GetChatClient(deploymentName).AsIChatClient() to adapt it to the IChatClient interface. Note the endpoint used in code must not end with /openai/v1, or requests return a 404 error. Developers choosing between cloud and local AI providers follow .NET integration walkthroughs like this on daily.dev."}},{"@type":"Question","name":"When should I use Azure OpenAI versus Ollama for a .NET AI application?","acceptedAnswer":{"@type":"Answer","text":"Choose Azure OpenAI when you need managed cloud infrastructure, centralized authentication and governance, easier scaling, and stronger hosted models without relying on local hardware. Choose Ollama for local development with zero cloud dependency, low-cost experimentation, offline access, or prototyping architecture before committing to a cloud provider. daily.dev helps teams weighing local versus cloud AI providers compare trade-offs before committing to one."}}]}
```

