Semantic Kernel .NET tutorial: C# tool calling setup

Learn to add Semantic Kernel to an ASP.NET Core API, expose C# functions, and fix tool calling by passing execution settings as kernel arguments.

Player not loading? Watch on YouTube

This tutorial adds Semantic Kernel to an existing ASP.NET Core web API connected to Azure OpenAI. The presenter installs Microsoft.SemanticKernel and registers the kernel through dependency injection, reusing configuration from earlier episodes. The demonstrated setup uses a hosted model service; it does not show how to run models locally.

A DevToolPlugins class supplies two C# methods: one suggests a design pattern, and another estimates code complexity from the number of lines. KernelFunction attributes expose the methods to the model, while description attributes explain when to use them. The controller validates incoming messages and uses FunctionChoiceBehavior.Auto with InvokePromptAsync to let the model choose whether to call a tool.

The first test returns an answer without invoking a plugin. The presenter traces this to execution settings that were created but never passed to the kernel. Passing them as KernelArguments enables the demonstrated function call. A later question about async and await receives a direct model response because neither plugin fits the request.

The tutorial also addresses a package downgrade error. The project’s existing Azure OpenAI package conflicts with the version required by Semantic Kernel. The fix is to update the conflicting packages, restore NuGet dependencies, and rebuild.