In this article, we’ll explore how to build intelligent AI agents using Azure OpenAI and semantic kernels (Microsoft C# SDK). You can combine it with OpenAI, Azure OpenAI, Hugging Face, or any other model. We’ll cover the fundamentals, dive into implementation details, and provide practical code examples in C# to illustrate key concepts. Whether you’re a beginner or an experienced developer, this guide will help you harness the power of AI for your applications.
What is Semantic Kernel?
In Kevin Scott's talk on "The era of the AI copilot," he showcased how Microsoft's Copilot system uses a mix of AI models and plugins to enhance user experiences. At the core of this setup is an AI orchestration layer, which allows Microsoft to combine these AI components to create innovative features for users. For developers looking to develop their own copilot-like experiences using AI plugins, Microsoft has introduced the Semantic kernel.
Semantic Kernel is an open-source framework that enables developers to build intelligent agents by providing a standard interface for various AI models and algorithms. The Semantic Kernel SDK allows you to integrate the power of large language models ( LLMs ) in your own applications. The Semantic Kernel SDK enables developers to incorporate prompts with LLMs in their applications, potentially creating their own copilot-like experiences. It allows developers to focus on building intelligent applications without worrying about the underlying complexities of AI models. Semantic Kernel is built on top of the .NET ecosystem and provides a robust and scalable platform for building intelligent apps/agents.

Key Features of Semantic Kernel
Modular architecture: The Semantic Kernel features a modular architecture that enables developers to integrate new AI models and algorithms easily.
Knowledge graph: Semantic Kernel provides a built-in knowledge graph that enables developers to store and query complex relationships between entities.
Machine learning: Semantic Kernel supports various machine learning algorithms, including classification, regression, and clustering.
Natural language processing: Semantic Kernel provides natural language processing capabilities, including text analysis and sentiment analysis.
Integration with external services: Semantic Kernel allows developers to integrate with external services, such as databases and web services.
Let's dive deep into writing some intelligent code using the Semantic kernel C# SDK. I will write them in steps so it will be easy to follow along.
Step 1. Setting up the Environment
Let's set up our environment. You will need to install the following to follow along.
.NET 8 or later
Semantic Kernel SDK (available on NuGet)
Your preferred IDE (Visual Studio, Visual Studio Code, etc.)
Azure OpenAI access
Step 2. Creating a New Project in VS
Open Visual Studio and create a blank, empty .NET 8 console Application.

Step 3. Install NuGet References
Right-click on the project --> click on Manage NuGet reference section to install the following two latest NuGet packages.
Microsoft.SemanticKernel
Microsoft.Extensions.Configuration.json
Note. To avoid hardcoding the Azure OpenAI key and endpoint, I store them as key-value pairs in appsettings.json. Using the #2 package, I can easily retrieve them based on the key.











Join the conversation! Your thoughts help the community grow.