← Open Source
microsoft

Generative-AI-for-beginners-dotnet

Five lessons, learn how to really apply AI to your .NET Applications

TutorialsGetting startedC#
Open on GitHub
Momentum
+0stars in 24 hours0.0%
3.11k
Stars
2.19k
Forks
—
This week
33
Contributors
Created 2025-01-10 · Updated 2026-10-04 · #6611 today
Top developers
README

Generative AI for Beginners .NET - A Course

Practical lessons teaching you how to build Generative AI applications in .NET

GitHub license GitHub contributors GitHub issues GitHub pull-requests PRs Welcome

GitHub watchers GitHub forks GitHub stars

Azure AI Community Discord

Microsoft Foundry GitHub Discussions

Generative AI for Beginners .NET logo

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.

✨ What's New

We're constantly improving this course with the latest AI tools, models, and practical samples:

  • 🤖 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 with AzureCliCredential or an API key, and sending a single model request with tools and skills disabled.

    👉 Explore the Copilot SDK BYOK sample

  • 🖥️ 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.

    👉 Explore the Foundry Local Samples

  • 🚀 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.AzureAI renamed to Microsoft.Agents.AI.Foundry.

    2 new Hosted Agent scenarios — deploy containerized agents to Azure Foundry Agent Service:

    Multi-agent workflows, streaming, persistence, and MCP all production-ready.

    👉 Official GA Release | Foundry Agent Service GA

  • 🚀 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.

    👉 Explore the Agent Framework Samples

  • 🧪 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

🚀 Introduction

Generative AI is transforming software development, and .NET is no exception. This course aims to simplify the journey by offering:

  • Short 5-10 minute videos for each lesson.
  • 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.

📦 Each Lesson Includes

  • Short Video: A quick overview of the lesson (5-10 minutes).
  • 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.

🗃️ Lessons

# Lesson Link Description
01 Introduction to Generative AI What generative AI is and how it differs from traditional programmingWhy .NET is a first-class citizen for AI developmentThe Microsoft AI stack and where each piece fitsHow to run samples in GitHub Codespaces or configure local development
02 Generative AI Techniques How to create chat conversations with context and memoryHow text embeddings work and why they matterHow to process different content types including images and documentsHow to call AI models using Microsoft.Extensions.AI abstractions
03 AI Patterns and Applications How to build semantic search that understands meaningHow to implement retrieval augmented generation (RAG)How to create applications that process and understand documentsWhen to use each pattern and how to combine them
04 AI Agents with Microsoft Agent Framework What makes an agent different from a chatbotHow to build agents that use tools and take actionsHow to orchestrate multiple agents working togetherHow to integrate with Model Context Protocol (MCP)
05 Responsible AI How to identify and mitigate bias in AI applicationsHow to implement content safety and guardrailsHow to build transparency and explainability into your systemsEthical considerations specific to agentic systems

🌐 Multi-Language Support

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.

🛠️ What You Need

To get started, you'll need:

  1. A GitHub account (free is fine!) to fork this entire repo to your own GitHub account.

  2. GitHub Codespaces enabled for instant coding environments. You can enable GitHub Codespaces in your repository settings. Learn more about GitHub Codespaces here.

  3. Create your copy by Forking this repo, or use the Fork button at the top of this page.

  4. A basic understanding of .NET development. Learn more about .NET here.

  5. Azure Developer CLI (azd) — Install here (required for automated Azure setup)

  6. An Azure account — Create a free account here (a free account works!)

And that's it.

We've designed this course to be as low-friction as possible. We make use of the following to help you get started quickly:

  • Run in GitHub Codespaces: With one click, you'll get a pre-configured environment to test and explore the lessons.
  • Use Azure OpenAI / Microsoft Foundry: Access powerful AI models through Azure for production-ready scenarios.

Then when you're ready to expand we also have guides for:

  • Using Ollama to run models locally on your hardware for enhanced privacy and control.

🚀 Quick Start with Azure

Automated Setup (Recommended)

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.ps1

This 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.


Manual Setup for Existing Azure Accounts

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://.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.cs

Note: Azure OpenAI samples use az login for authentication. Run az login before running any Azure sample.

For detailed manual setup options, see Azure Resource Setup Guide.


🧹 Resource Cleanup

When you're done with the course, clean up Azure resources to avoid ongoing charges:

./cleanup.ps1

This will:

  • Delete all Azure resources
  • Clear local configuration
  • Remove User Secrets

Learn more in Azure Resource Setup Guide - Cleanup.

🤝 Want to Help?

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.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🌐 Other Courses

We have a lot of other content to help your learning journey. Check out:

Generative AI Series

Generative AI for Beginners Generative AI (.NET) Generative AI (Java) Generative AI (JavaScript)


Core Learning

ML for Beginners Data Science for Beginners AI for Beginners Cybersecurity for Beginners Web Dev for Beginners IoT for Beginners XR Development for Beginners

Getting Help

If you get stuck or have any questions about building AI apps, join:

Microsoft Foundry Discord

If you have product feedback or errors while building visit:

Microsoft Foundry Developer Forum