Welcome to Generative AI for Beginners .NET, the hands-on course for .NET developers diving into the world of Generative AI!
This isnβt your typical βhereβs some theory, good luckβ course. This repository is all about real-world applications and live coding to empower .NET developers to take full advantage of Generative AI.
This is hands-on, practical, and designed to be fun!
Don't forget to star (π) this repo to find it easier later.
β‘οΈGet your own copy by Forking this repo and find it next in your own repositories.
We're constantly improving this course with the latest AI tools, models, and practical samples:
-
π― Decision-powered Hosted Agent: new sample (November 2026)
Route synthetic support tickets with a custom Microsoft Agent Framework
AIAgentand the native Microsoft-Decision-1 endpoint. The sample returns a typed decision through Foundry's Responses protocol, without adding a chat model, and includes offline tests plus a C# caller for a deployed Hosted Agent. -
π€ GitHub Copilot SDK with BYOK β new sample (October 2026)
Use the GitHub Copilot SDK from .NET with your own model deployment hosted in Microsoft Foundry or Azure OpenAI. The sample shows the minimal BYOK (Bring Your Own Key) setup: routing inference through a
ProviderConfig, authenticating withAzureCliCredentialor an API key, and sending a single model request with tools and skills disabled. -
π₯οΈ Local AI with Foundry Local β 10 samples (August 2026)
Run Generative AI models locally from .NET using Microsoft Foundry Local. Ten production-ready samples demonstrate chat, streaming, practical scenarios, audio transcription, agent tools, and live speech-to-textβincluding multilingual transcription with automatic language detection and explicit locale selectionβall with zero cloud costs and full offline capability.
-
π Microsoft Agent Framework v1.0 GA (April 2026)
All 28 MAF samples upgraded from preview to stable v1.0 packages. This includes a breaking change:
Microsoft.Agents.AI.AzureAIrenamed toMicrosoft.Agents.AI.Foundry.2 new Hosted Agent scenarios β deploy containerized agents to Azure Foundry Agent Service:
- MAF-HostedAgent-01-TimeZone β Basic hosted agent with timezone tool
- MAF-HostedAgent-02-MultiAgent β Multi-agent Research Assistant workflow
Multi-agent workflows, streaming, persistence, and MCP all production-ready.
-
π Microsoft Agent Framework Reaches Release Candidate!
Microsoft Agent Framework has reached Release Candidate (
1.0.0-rc1) β a framework for building agents and multi-agent systems in .NET. Our samples are being migrated to the RC APIs. In the meantime, explore 25+ Agent Framework samples covering console apps, web chat, multi-agent workflows, and Foundry integration. -
π§ͺ Optional provider-specific samples
Additional provider-specific samples remain available in the repo, including Claude-via-Foundry integrations and legacy video-generation experiments. They are useful reference material, but they are not part of the current recommended beginner-to-advanced learning path.
π Browse the MAF samples and CoreSamples
View all previous updates in our What's New archive
Generative AI is transforming software development, and .NET is no exception. This course aims to simplify the journey by offering:
- Short videos for core concepts, alongside current written walkthroughs.
- Fully functional .NET code samples you can run and explore.
- Integration with tools, including GitHub Codespaces for seamless setup and fast time-to-code. You can use Azure OpenAI Services / Microsoft Foundry or Ollama for local model hosting.
You'll learn how to implement Generative AI into .NET projects, from basic text generation to building full-fledged solutions using Azure OpenAI Services and local models with Ollama.
- Videos where available: Recorded overviews complement the written lessons. Unavailable video shortcuts are marked rather than presented as working recordings.
- Complete Code Samples: Fully functional and ready to run.
- Step-by-Step Guidance: Simple instructions to help you learn and implement the concepts.
- Deep Dive References: This course focuses on the practical implementation of GenAI, to get deeper into the theoretical we also provide links to explanations in Generative AI for Beginners - A Course when needed.
| # | Lesson Link | Description |
|---|---|---|
| 01 | Introduction to Generative AI |
|
| 02 | Generative AI Techniques |
|
| 03 | AI Patterns and Applications |
|
| 04 | AI Agents with Microsoft Agent Framework |
|
| 05 | Responsible AI |
|
| Language | Code | Link to Translated README | Last Updated |
|---|---|---|---|
| Chinese (Simplified) | zh | Chinese Translation | 2025-06-24 |
| Chinese (Traditional) | tw | Chinese Translation | 2025-06-24 |
| French | fr | French Translation | 2025-06-24 |
| Japanese | ja | Japanese Translation | 2025-06-24 |
| Korean | ko | Korean Translation | 2025-06-24 |
| Portuguese | pt | Portuguese Translation | 2025-06-24 |
| Spanish | es | Spanish Translation | 2025-06-24 |
| German | de | German Translation | 2025-06-24 |
Note: All translations were updated to match the original content on 2025-06-24. See PR #161 for details.
To get started, you'll need:
- The .NET 10 SDK or later and a basic understanding of .NET.
- A local clone of this repository. A GitHub account is needed only for forking, contributing, or using Codespaces.
- One AI provider: Ollama on your machine, or Azure OpenAI / Microsoft Foundry.
Ollama learners do not need an Azure account, Azure CLI, API keys, or Codespaces. The core local route covers chat, history, streaming, structured output, tools, caching, semantic search, RAG, and agents.
For the Azure route, you also need an Azure account and the tools described in the Azure setup guide. Azure Developer CLI (azd) is needed for automated resource provisioning. Cloud-specific services are optional branches, not local prerequisites.
Install and start Ollama, then run these commands from the repository root:
ollama pull phi4-mini
dotnet run .\samples\CoreSamples\BasicChat-03Ollama\app.csExpect a sentiment analysis of four product reviews. First run restores NuGet packages; models and packages must be downloaded before offline use.
Continue with the local setup and troubleshooting guide, then follow the Ollama-only learning path through all five lessons. That path lists exact commands, models, expected results, and optional network dependencies.
For first-time Azure users, we provide an automated setup script that deploys all necessary resources:
# Navigate to the repository root
cd Generative-AI-for-beginners-dotnet
# Run the setup script
./setup.ps1This will:
- β Deploy Azure OpenAI resources (gpt-5-mini, text-embedding-3-small)
- β Create necessary storage and support services
- β Configure .NET User Secrets automatically
- β Display your Azure OpenAI endpoint and credentials
For detailed instructions, see Azure Resource Setup Guide.
If you already have an Azure OpenAI account and the models deployed, configure secrets directly:
# Set shared secrets (used by all samples)
dotnet user-secrets set --id genai-beginners-dotnet "AzureOpenAI:Endpoint" "https://<your-region>.openai.azure.com/"
dotnet user-secrets set --id genai-beginners-dotnet "AzureOpenAI:Deployment" "gpt-5-mini"
dotnet user-secrets set --id genai-beginners-dotnet "AzureOpenAI:EmbeddingDeployment" "text-embedding-3-small"Then navigate to any sample and run:
cd samples/CoreSamples/BasicChat-01MEAI
dotnet run app.csNote: Azure OpenAI samples use
az loginfor authentication. Runaz loginbefore running any Azure sample.
For detailed manual setup options, see Azure Resource Setup Guide.
When you're done with the course, clean up Azure resources to avoid ongoing charges:
./cleanup.ps1This will:
- Delete all Azure resources
- Clear local configuration
- Remove User Secrets
Learn more in Azure Resource Setup Guide - Cleanup.
Samples pin NuGet versions for reproducible builds. The dependency refresh targets current stable releases; preview-only integrations and samples that already require newer preview APIs retain explicit preview versions. Keeping packages current reduces exposure to known dependency issues, but is not a security guarantee.
To check direct and transitive dependencies for a solution without calling an AI service:
dotnet restore .\samples\CoreSamples\CoreGenerativeAITechniques.sln -p:EnableWindowsTargeting=true -p:NuGetAuditMode=all -warnaserror:NU1901,NU1902,NU1903,NU1904
dotnet list .\samples\CoreSamples\CoreGenerativeAITechniques.sln package --vulnerable --include-transitiveRepeat for each affected solution. Build CI treats known NuGet vulnerability advisories as errors, and Dependabot monitors the current samples directories. For local inference and documentation checks, follow the Ollama validation instructions. Cloud services, microphones, cameras, and other model runtimes require their own configured environments; a successful build does not verify those runtime integrations.
Contributions are welcome! Here's how you can help:
-
Report issues or bugs in the repo.
-
Improve existing code samples or add new ones, fork this repo and propose some changes!
-
Suggest additional lessons or enhancements.
-
Do you have suggestions or found spelling or code errors?, create a pull request
Check the CONTRIBUTING.MD file for details on how to get involved.
This project is licensed under the MIT License - see the LICENSE file for details.
We have a lot of other content to help your learning journey. Check out:
If you get stuck or have any questions about building AI apps, join:
If you have product feedback or errors while building visit:
