Enterprise AI teams outgrew raw chat completions quickly. Calling Azure OpenAI from a controller works for a demo — but production needs plugin boundaries, memory, planning, telemetry, and governance. That orchestration layer is exactly what this Semantic Kernel guide covers.
Semantic Kernel (SK) is Microsoft's open-source SDK for composing LLM applications with native functions, OpenAPI plugins, memory, and multi-agent workflows. Whether you ship .NET microservices on Azure or Python agents in containers, SK gives you a consistent model for tool-enabled AI — without reinventing orchestration in every project.
This guide is written for developers, AI engineers, architects, and technical leaders who need production-ready patterns: architecture, code, security, scalability, and the mistakes teams make when they treat SK as "just another SDK wrapper."
Why Semantic Kernel Matters for Enterprise AI
Three forces push enterprises toward orchestration frameworks like Semantic Kernel in 2026:
- Tool sprawl — CRM, ERP, ticketing, and internal APIs must be callable by models with audit trails
- Platform consolidation — Azure AI Foundry, Copilot extensibility, and custom apps share similar plugin shapes
- Operational maturity — Teams need versioning, evaluation, and CI/CD for prompts — not copy-paste in Slack
Semantic Kernel does not replace your domain services. It sits between user-facing applications and Azure OpenAI (or other models), enforcing how prompts, context, and plugins combine — a pattern this Semantic Kernel guide implements step by step.
What Is Semantic Kernel?
At its core, Semantic Kernel provides:
- A Kernel — runtime that holds configuration, AI services, and registered plugins
- Plugins — functions exposed to the model (C#, Python, Java, or OpenAPI imports)
- Prompt templates — reusable prompts with variables and automatic function calling
- Memory — semantic storage and retrieval for RAG scenarios
- Planners / agents — multi-step reasoning that selects and chains plugins
- Connectors — adapters for Azure OpenAI, OpenAI, Hugging Face, and vector stores
User / API request
↓
Application (ASP.NET, FastAPI, Azure Function)
↓
Semantic Kernel (orchestration)
├── Chat completion (Azure OpenAI)
├── Plugins (native + OpenAPI)
├── Memory (Azure AI Search)
└── Filters (logging, safety, auth)
↓
Structured response / streamed tokens
Reference: Semantic Kernel documentation (Microsoft Learn).
Semantic Kernel Architecture Deep Dive
The Kernel
The kernel is the composition root — register AI services once, attach plugins, add filters for cross-cutting concerns (logging, PII redaction, authorization). In .NET, integrate with dependency injection so each request gets a scoped kernel with tenant context.
Plugins and Functions
Plugins group related capabilities. A SupportPlugin might expose GetOrderStatus and CreateTicket. SK generates JSON schemas from function signatures so the model understands parameters and types.
public class SupportPlugin
{
[KernelFunction("get_order_status")]
[Description("Returns shipment status for a customer order")]
public async Task<string> GetOrderStatusAsync(
[Description("Order ID such as ORD-10482")] string orderId,
IOrderService orders)
{
var order = await orders.GetAsync(orderId);
return order is null ? "Order not found" : order.Status;
}
}
Prompt Templates
Prompt templates separate instruction text from code. Variables inject user input safely; execution settings control temperature, max tokens, and tool-calling behavior.
Memory and RAG
Memory connectors store embeddings and retrieve top-k matches at query time. Enterprise RAG typically uses Azure AI Search with ACL-aware indexes — SK retrieves snippets, then the chat completion synthesizes an answer grounded on those snippets.
Filters
Filters intercept function invocations and prompt rendering — ideal for enforcing "no PII in logs," requiring manager approval for refunds, or blocking plugins outside business hours.
Getting Started: Your First Semantic Kernel App on Azure
This Semantic Kernel guide walkthrough targets .NET 8 + Azure OpenAI — the most common enterprise stack. Python follows the same concepts with different syntax.
- Create an Azure OpenAI resource and deploy
gpt-4o-minifor development - Add NuGet packages:
Microsoft.SemanticKernel,Microsoft.SemanticKernel.Connectors.AzureOpenAI - Build the kernel with Azure credentials (prefer
DefaultAzureCredential) - Register plugins and invoke a prompt or agent
var builder = Kernel.CreateBuilder();
builder.AddAzureOpenAIChatCompletion(
deploymentName: "gpt-4o-mini",
endpoint: new Uri(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")!),
credentials: new DefaultAzureCredential());
builder.Plugins.AddFromType<SupportPlugin>();
var kernel = builder.Build();
var result = await kernel.InvokePromptAsync(
"Summarize order {{$orderId}} status using available tools.",
new KernelArguments { ["orderId"] = "ORD-10482" });
Console.WriteLine(result);
Store secrets in Azure Key Vault; reference them via App Configuration or container environment variables — never commit keys to source control.
Semantic Kernel in Python
Python SK suits data engineering teams and FastAPI microservices:
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion
kernel = Kernel()
kernel.add_service(AzureChatCompletion(
deployment_name="gpt-4o-mini",
endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
api_key=os.environ["AZURE_OPENAI_KEY"],
))
# Register plugins via kernel.add_plugin(...)
Align Python and .NET plugin contracts if both languages consume the same backend APIs — OpenAPI plugin imports keep schemas synchronized.
OpenAPI Plugins for Existing APIs
Most enterprises already expose REST APIs with OpenAPI specs. SK can import them as plugins without rewriting business logic:
- Point SK at your OpenAPI document (CRM, HR, inventory)
- SK generates callable functions with typed parameters
- Apply APIM policies, OAuth, and rate limits at the API gateway
This pattern accelerates adoption — domain teams keep owning services; AI teams register capabilities into the kernel catalog.
Agents and Multi-Step Orchestration
Single prompt invocations suffice for Q&A. Agents handle research tasks: gather context, call tools, reflect, and iterate.
Agent loop 1. User goal → planner selects next action 2. Invoke plugin OR retrieve memory 3. Model evaluates progress 4. Repeat until done or max iterations 5. Return final answer + audit trail
Set max iteration limits (typically 5–15 depending on task complexity) to prevent runaway token spend. Log each step with correlation IDs for support debugging.
Connect agent concepts with Model Context Protocol (MCP) when standardizing tools across multiple AI hosts beyond a single SK application.
Semantic Kernel Process Framework
Long-running business workflows — loan approval, incident response, onboarding — need durable state. The Process framework models steps, events, and human-in-the-loop gates explicitly instead of hiding state inside chat history.
- Define steps as typed handlers with inputs and outputs
- Persist process state to Azure SQL or Cosmos DB
- Resume after human approval without re-running expensive LLM calls
- Integrate with Azure Service Bus for asynchronous step execution
RAG Patterns with Semantic Kernel Memory
Production RAG on Azure typically follows this architecture:
Ingestion pipeline Blob Storage → Document Intelligence → chunking → embeddings → Azure AI Search Query path User question → SK memory retrieval → top-k chunks → grounded prompt → Azure OpenAI
Best practices for enterprise RAG in SK:
- Chunk by semantic sections, not fixed 512-token blocks only
- Store source URI and ACL metadata with each chunk
- Filter retrieval by user identity before the model sees content
- Return citations in the UI — users trust answers they can verify
Deeper retrieval design: Building RAG Applications.
Semantic Kernel vs LangChain vs AutoGen
| Framework | Strengths | Considerations |
|---|---|---|
| Semantic Kernel | Azure-native, .NET DI, Microsoft support path, Process framework | Smaller community than LangChain in Python |
| LangChain | Huge ecosystem, rapid prototyping | API churn, less opinionated enterprise governance |
| AutoGen | Multi-agent conversation patterns | Research-oriented; operational patterns still maturing |
| Raw Azure OpenAI SDK | Maximum control, minimal abstraction | You rebuild orchestration, memory, and plugin registry |
Platform teams often standardize on SK for customer-facing .NET services while allowing Python LangChain in data science sandboxes — with shared OpenAPI contracts.
Azure Reference Architecture for Semantic Kernel
Azure Front Door / APIM
↓
Azure Container Apps (SK API — .NET or Python)
│ managed identity
├── Azure OpenAI (chat + embeddings)
├── Azure AI Search (vector + keyword)
├── Key Vault (secrets)
├── Azure SQL / Cosmos (process state)
└── Application Insights (traces, token metrics)
Optional: Azure AI Foundry for evaluation and prompt versioning
Deploy SK services like any other microservice — health probes, autoscaling on CPU/RPS, blue-green releases. Use Azure AI Foundry for offline evaluation before promoting prompt or plugin changes.
Security and Governance
Semantic Kernel inherits your application's attack surface. Harden it deliberately:
- Identity — Managed identity to Azure OpenAI; OAuth on behalf of user for Graph-backed plugins
- Authorization — Map Entra ID groups to plugin allowlists per tenant
- Input validation — Never trust model-generated SQL or shell commands without sandboxing
- Output filtering — Azure AI Content Safety on responses; block PII leakage patterns
- Audit — Log plugin name, arguments (redacted), caller identity, latency, token count
- Secrets — Key Vault references; rotate keys; no secrets in prompt templates
Scalability and Performance
| Concern | Mitigation |
|---|---|
| Token cost | Cache retrieval results; compress history; use smaller models for routing |
| Latency | Stream tokens to clients; parallelize independent plugin calls |
| Concurrency | Stateless SK APIs behind Container Apps autoscaling |
| Rate limits | Queue bursts via Service Bus; backoff on Azure OpenAI 429 responses |
| Cold start | Minimum replicas on Container Apps; warm kernel at startup |
Instrument SKActivity or OpenTelemetry exporters — measure p95 latency per plugin, not just end-to-end chat time.
Observability and Evaluation
Production SK apps need three telemetry layers:
- Application Insights — Request traces, dependency calls to Azure OpenAI
- Custom metrics — Tokens per tenant, plugin error rates, agent iteration counts
- Quality evaluation — Golden datasets run in CI; block deploy if groundedness drops
Store prompt versions in git or AI Foundry. Tag each deployment with a prompt hash so incidents map to exact configuration.
CI/CD for Semantic Kernel Projects
- Unit test plugins with mocked dependencies — no live model calls in fast CI
- Integration stage hits Azure OpenAI with fixed seeds and snapshot expected tool selections
- Load test plugin-heavy flows — database connection pools exhaust before LLM quotas do
- Feature flags toggle new plugins per tenant without redeploying the entire kernel
Designing Plugins That Models Actually Use
Models choose tools based on names and descriptions — not your internal class diagrams. Follow these Semantic Kernel guide rules when exposing enterprise APIs:
- Verb-first names —
search_policiesbeatsPolicyHandler.Execute - One action per function — split "search and update" into two plugins for clearer policy
- Constrained parameters — enums and regex patterns reduce invalid tool calls
- Human-readable errors — return messages the model can relay to users, not stack traces
Run monthly reviews of unused plugins — if the model never invokes a tool, its description is wrong or the capability belongs in RAG instead.
Multi-Tenant Semantic Kernel on Azure
SaaS products often serve multiple customers from one SK deployment. Isolate tenants at three layers:
- Request context — Pass tenant ID from JWT into kernel filters
- Data plane — Partition search indexes or use per-tenant filters in Azure AI Search
- Configuration — Tenant-specific plugin allowlists in App Configuration
Never share conversation memory across tenants. Use separate memory collections or enforce tenant predicates on every retrieval query.
Enterprise Use Cases
Customer Support Copilot
SK agent retrieves knowledge base articles, calls order API plugins, drafts replies — human agent approves before send. Reduces handle time while keeping humans accountable.
Financial Analysis Assistant
Read-only SQL plugin over curated views; memory over approved research PDFs; export citations for compliance review.
HR Policy Bot
RAG over employee handbook with Entra-scoped retrieval; escalate to HR ticket plugin when confidence is low.
DevOps Incident Triage
Plugins query Azure Monitor, run approved Kusto queries, open incidents in ServiceNow — Process framework pauses for SRE approval on remediation scripts.
Semantic Kernel and Azure AI Foundry
AI Foundry handles model catalog, prompt flow visual design, and batch evaluation. Semantic Kernel embeds in your custom applications. Common pattern:
- Prototype flows in AI Foundry playground
- Export production logic into SK plugins and agents
- Run Foundry evaluations against SK endpoints before release
New to Foundry? Start with our Azure AI Foundry tutorial. New to SK? Read Semantic Kernel for Beginners first.
Semantic Kernel Best Practices
- Keep plugins small and single-purpose — compose instead of mega-plugins
- Version prompts and treat breaking changes like API semver
- Use structured outputs (JSON schema) when downstream systems parse results
- Prefer managed identity over API keys in Azure environments
- Document each plugin with clear descriptions — models choose tools based on text
- Implement idempotent write plugins where possible
- Separate read and write plugins for clearer policy enforcement
- Test with adversarial prompts (injection, exfiltration) in security review
Common Mistakes in Semantic Kernel Projects
- God kernel — One service registers 80 plugins; startup slow, model confused by tool choice
- No iteration cap — Agent loops until budget alarm fires
- Prompt as database — Business rules only in prose prompts instead of code
- Skipping filters — No authorization on plugin invocation
- Monolithic memory — One search index mixing dev and prod documents
- Ignoring streaming — Users stare at spinners for 30s multi-tool agents
- LangChain port without redesign — Copying patterns that fight SK's DI model
Troubleshooting Semantic Kernel Issues
| Symptom | Likely cause | Fix |
|---|---|---|
| Model never calls plugins | Weak function descriptions or wrong execution settings | Improve Description attributes; enable auto function calling |
| 401 from Azure OpenAI | Expired key or RBAC gap on managed identity | Verify Cognitive Services OpenAI User role |
| Hallucinated tool arguments | Overly complex parameter schemas | Simplify types; add server-side validation |
| Timeout errors | Synchronous slow SQL inside plugins | Async I/O; cache; move heavy jobs to queues |
| Inconsistent RAG answers | Bad chunks or missing ACL filters | Re-index; filter by user claims at retrieval |
| Token spike | Full chat history sent every turn | Summarize history; trim tool results |
Migration Path from Raw OpenAI Calls to Semantic Kernel
- Extract inline prompts into SK prompt templates
- Wrap existing service methods as native plugins
- Add memory connector if users ask document questions
- Introduce agent loop for multi-step tasks previously hardcoded in C#
- Add filters for auth and logging before exposing externally
- Wire evaluation pipeline in AI Foundry or custom CI
Migrate incrementally — parallel-run old and new paths behind a feature flag until metrics match.
Conclusion
This Semantic Kernel guide covered architecture, Azure deployment, plugins, agents, memory, security, and the operational discipline that separates pilots from production. Semantic Kernel is not magic — it is structured orchestration for LLM applications on Microsoft Azure. Teams that invest in plugin boundaries, filters, and evaluation ship faster and sleep better during audits.
Start small: one kernel, two plugins, one grounded use case. Expand the catalog as governance matures. Align with Azure AI Foundry for evaluation and with MCP when multiple AI hosts must share the same tools.
Frequently Asked Questions
Key Takeaways
- Semantic Kernel orchestrates LLM apps with plugins, memory, agents, and filters — not just API wrappers.
- Register native and OpenAPI plugins; enforce security through filters, RBAC, and managed identity on Azure.
- Use memory connectors and Azure AI Search for production RAG with ACL-aware retrieval.
- Cap agent iterations, stream responses, and instrument token usage per tenant.
- Combine SK with Azure AI Foundry for evaluation and MCP for cross-host tool sharing.
- Migrate incrementally from raw OpenAI calls — templates, plugins, then agents and Process workflows.