<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: CodeStreet</title>
    <description>The latest articles on Forem by CodeStreet (@codestreet).</description>
    <link>https://forem.com/codestreet</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1944406%2F788e81e5-324c-4a1c-a693-012f23682f15.png</url>
      <title>Forem: CodeStreet</title>
      <link>https://forem.com/codestreet</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/codestreet"/>
    <language>en</language>
    <item>
      <title>Why DevUI Is a Game Changer for .NET Developers? Microsoft Agent Framework DevUI Demo.</title>
      <dc:creator>CodeStreet</dc:creator>
      <pubDate>Fri, 06 Feb 2026 14:51:24 +0000</pubDate>
      <link>https://forem.com/codestreet/why-devui-is-a-game-changer-for-net-developers-4geo</link>
      <guid>https://forem.com/codestreet/why-devui-is-a-game-changer-for-net-developers-4geo</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Building and testing AI agents shouldn't require building a complex user interface from scratch. That's where &lt;strong&gt;DevUI&lt;/strong&gt; comes in - a powerful development tool that's part of the &lt;strong&gt;Microsoft Agent Framework&lt;/strong&gt; for .NET 10. &lt;/p&gt;

&lt;p&gt;In this comprehensive guide, you'll learn how to set up, configure, and test multiple AI agents with different personas using a simple web interface.&lt;/p&gt;

&lt;p&gt;Whether you're building chatbots, AI assistants, or conversational applications, DevUI provides an intuitive playground similar to Swagger UI but designed specifically for AI agents.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Watch the video tutorial above for a complete walkthrough, or continue reading for the step-by-step guide.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What is DevUI?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;DevUI&lt;/strong&gt; is a development interface included with the Microsoft Agent Framework that enables developers to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Test AI agents in real-time&lt;/strong&gt; during development&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Manage conversations&lt;/strong&gt; with multiple agents simultaneously&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Debug agent responses&lt;/strong&gt; without building a production UI&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Prototype quickly&lt;/strong&gt; before implementing custom interfaces&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Validate system prompts&lt;/strong&gt; and agent behavior instantly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of DevUI as your AI agent playground - a tool that accelerates development by providing immediate visual feedback on your agents' behavior and responses.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Benefits
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Zero UI Code Required&lt;/strong&gt;: Test agents immediately without building React, Angular, or Blazor interfaces&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multi-Agent Support&lt;/strong&gt;: Switch between different agents in the same session&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conversation History&lt;/strong&gt;: Built-in conversation management and history tracking&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Development-Only&lt;/strong&gt;: Easily disable for production deployments&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OpenAI Compatible&lt;/strong&gt;: Works with any OpenAI-compatible endpoint including Azure OpenAI, GitHub Models, and more&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before we begin, ensure you have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;.NET 10 SDK&lt;/strong&gt; installed (&lt;a href="https://dotnet.microsoft.com/download" rel="noopener noreferrer"&gt;Download here&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Visual Studio 2026&lt;/strong&gt; or &lt;strong&gt;VS Code&lt;/strong&gt; with C# extensions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Basic knowledge&lt;/strong&gt; of ASP.NET Core&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API access&lt;/strong&gt; to an OpenAI-compatible service (OpenAI, Azure OpenAI, GitHub Models, etc.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API Key&lt;/strong&gt; for your chosen AI service (you can use GitHub Copilot)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Required NuGet Packages
&lt;/h2&gt;

&lt;p&gt;For this tutorial, you'll need the following packages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet add package Microsoft.Agents.AI.DevUI
dotnet add package Microsoft.Agents.AI.Hosting
dotnet add package Microsoft.Extensions.AI
dotnet add package OpenAI
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Package Overview
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Package&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Microsoft.Agents.AI.DevUI&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Provides the DevUI web interface&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Microsoft.Agents.AI.Hosting&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Agent hosting infrastructure and registration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Microsoft.Extensions.AI&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Core AI abstractions and interfaces&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;OpenAI&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;OpenAI SDK for connecting to AI models&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Project Setup
&lt;/h2&gt;

&lt;p&gt;Let's create a new ASP.NET Core application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet new web &lt;span class="nt"&gt;-n&lt;/span&gt; DevUIDemo
&lt;span class="nb"&gt;cd &lt;/span&gt;DevUIDemo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the required packages as shown above, and we're ready to start coding!&lt;/p&gt;




&lt;h2&gt;
  
  
  Implementation Guide
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Configure the ChatClient
&lt;/h3&gt;

&lt;p&gt;Open &lt;code&gt;Program.cs&lt;/code&gt; and set up your application builder and chat client:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Agents.AI.DevUI&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Agents.AI.Hosting&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.AspNetCore.Builder&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Extensions.AI&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Extensions.DependencyInjection&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Extensions.Hosting&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;OpenAI.Chat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.ClientModel&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;WebApplicationBuilder&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;WebApplication&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Configure ChatClient with your AI service&lt;/span&gt;
&lt;span class="n"&gt;IChatClient&lt;/span&gt; &lt;span class="n"&gt;chatClient&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ChatClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"gpt-4o"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;// Model name&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ApiKeyCredential&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetEnvironmentVariable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"OPENAI_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;)!),&lt;/span&gt; 
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;OpenAIClientOptions&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
        &lt;span class="n"&gt;Endpoint&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Uri&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://models.github.ai/inference"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;AsIChatClient&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;?? Security Best Practice&lt;/strong&gt;: Always use environment variables or secure configuration for API keys. Never hardcode credentials in your source code!&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Register Required Services
&lt;/h3&gt;

&lt;p&gt;Add the necessary services to your dependency injection container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Register the chat client for agent use&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddChatClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chatClient&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Register OpenAI response handling&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddOpenAIResponses&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Register conversation state management&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddOpenAIConversations&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These services provide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AddChatClient&lt;/strong&gt;: Registers the chat client for dependency injection&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AddOpenAIResponses&lt;/strong&gt;: Handles OpenAI API response processing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AddOpenAIConversations&lt;/strong&gt;: Manages conversation state and history&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 3: Create AI Agents
&lt;/h3&gt;

&lt;p&gt;Now comes the fun part - creating your AI agents! The framework makes this incredibly simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Create a Comic Book Guy agent from The Simpsons&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddAIAgent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"Comic Book Guy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="s"&gt;"You are Comic Book Guy from The Simpsons. Respond with his characteristic "&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt;
    &lt;span class="s"&gt;"condescending tone, vast knowledge of pop culture, and frequent use of phrases "&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt;
    &lt;span class="s"&gt;"like 'Worst [blank] ever!' Be pedantic and superior in your responses."&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Create a YouTube channel advisor agent&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddAIAgent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"CodeStreet Agent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="s"&gt;"You are an experienced YouTube content strategist specializing in tech channels. "&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt;
    &lt;span class="s"&gt;"Provide actionable advice on content ideas, SEO, thumbnails, audience engagement, "&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt;
    &lt;span class="s"&gt;"and growth strategies for programming and technology channels."&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;** Pro Tip**: Your system prompt is crucial! Be specific about the agent's personality, knowledge domain, and response style for best results.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Configure Endpoints and Run
&lt;/h3&gt;

&lt;p&gt;Finally, build the app and register the DevUI endpoints:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;WebApplication&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Build&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Register OpenAI API endpoints (required for DevUI)&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapOpenAIResponses&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapOpenAIConversations&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Register DevUI endpoint&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapDevUI&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Complete Code Example
&lt;/h3&gt;

&lt;p&gt;Here's the complete &lt;code&gt;Program.cs&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Agents.AI.DevUI&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Agents.AI.Hosting&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.AspNetCore.Builder&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Extensions.AI&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Extensions.DependencyInjection&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Extensions.Hosting&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;OpenAI.Chat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.ClientModel&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;WebApplicationBuilder&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;WebApplication&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;IChatClient&lt;/span&gt; &lt;span class="n"&gt;chatClient&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ChatClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"gpt-4o"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ApiKeyCredential&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetEnvironmentVariable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"OPENAI_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;)!),&lt;/span&gt; 
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;OpenAIClientOptions&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
        &lt;span class="n"&gt;Endpoint&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Uri&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://models.github.ai/inference"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;AsIChatClient&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddChatClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chatClient&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddOpenAIResponses&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddOpenAIConversations&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddAIAgent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Comic Book Guy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="s"&gt;"You are comic-book guy from The Simpsons"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddAIAgent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"CodeStreet Agent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="s"&gt;"You are an agent who gives suggestions for youtube channels"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;WebApplication&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Build&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapOpenAIResponses&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapOpenAIConversations&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapDevUI&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Running Your Application
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Start the Application
&lt;/h3&gt;

&lt;p&gt;Run your application using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or press &lt;code&gt;F5&lt;/code&gt; in Visual Studio.&lt;/p&gt;

&lt;h3&gt;
  
  
  Access DevUI
&lt;/h3&gt;

&lt;p&gt;Once the application starts, navigate to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:[PORT]/devui
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;[PORT]&lt;/code&gt; with the port number shown in your console output (typically 5000 or 5173).&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing Your Agents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Select an Agent&lt;/strong&gt;: On the left sidebar, you'll see both agents listed&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Start a Conversation&lt;/strong&gt;: Click on an agent to begin chatting&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Send Messages&lt;/strong&gt;: Type your message in the input box&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;View Responses&lt;/strong&gt;: Watch your agent respond in character&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Switch Agents&lt;/strong&gt;: Click another agent to test different personas&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;View History&lt;/strong&gt;: All conversation history is maintained automatically&lt;/li&gt;
&lt;/ol&gt;







&lt;h2&gt;
  
  
  Resources and Next Steps
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Official Documentation
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com" rel="noopener noreferrer"&gt;Microsoft Agent Framework Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/ai" rel="noopener noreferrer"&gt;.NET AI Development Guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/openai/openai-dotnet" rel="noopener noreferrer"&gt;OpenAI .NET SDK&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Further Learning
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Advanced Agent Patterns&lt;/strong&gt;: Explore multi-agent conversations and orchestration&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function Calling&lt;/strong&gt;: Enable agents to interact with external systems&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom UI Development&lt;/strong&gt;: Build production interfaces using React or Blazor&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Azure Deployment&lt;/strong&gt;: Deploy agents to Azure App Service or Container Apps&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Sample Code Repository
&lt;/h3&gt;

&lt;p&gt;Find the complete source code for this tutorial: &lt;a href="https://buymeacoffee.com/thecodestreet/e/506289" rel="noopener noreferrer"&gt;Source Code&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;DevUI provides a powerful, efficient way to develop and test AI agents in .NET 10 without the overhead of building custom interfaces. By following this guide, you've learned:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; How to set up the Microsoft Agent Framework&lt;/li&gt;
&lt;li&gt; Configure OpenAI-compatible chat clients&lt;/li&gt;
&lt;li&gt; Create multiple AI agents with distinct personas&lt;/li&gt;
&lt;li&gt; Use DevUI for rapid testing and iteration&lt;/li&gt;
&lt;li&gt; Implement best practices for security and deployment&lt;/li&gt;
&lt;li&gt; Troubleshoot common issues&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Microsoft Agent Framework, combined with DevUI, dramatically reduces the time from concept to functional AI agents. Whether you're building chatbots, virtual assistants, or complex multi-agent systems, these tools provide the foundation for rapid, efficient development.&lt;/p&gt;




&lt;h2&gt;
  
  
  Support me!
&lt;/h2&gt;

&lt;p&gt;If you found this guide helpful, make sure to check out the accompanying YouTube video tutorial where I walk you through the process visually. Don’t forget to &lt;a href="https://youtube.com/@TheCodeStreet?sub_confirmation=1" rel="noopener noreferrer"&gt;subscribe to my channel&lt;/a&gt; for more amazing tutorials!&lt;/p&gt;

&lt;p&gt;I would appreciate it if you could buy me a coffee.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbgo17dxrwwbcyvtij06.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbgo17dxrwwbcyvtij06.png" alt="Buy me a coffee" width="700" height="700"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to leave your questions, comments, or suggestions below. Happy coding!&lt;/p&gt;

</description>
      <category>genai</category>
      <category>ai</category>
      <category>dotnet</category>
      <category>openai</category>
    </item>
    <item>
      <title>Run Large Language Models Locally in Docker | How to Use Qwen 3 with .NET Semantic Kernel?</title>
      <dc:creator>CodeStreet</dc:creator>
      <pubDate>Fri, 19 Sep 2025 17:41:39 +0000</pubDate>
      <link>https://forem.com/codestreet/run-large-language-models-locally-in-docker-how-to-use-qwen-3-with-net-semantic-kernel-3olf</link>
      <guid>https://forem.com/codestreet/run-large-language-models-locally-in-docker-how-to-use-qwen-3-with-net-semantic-kernel-3olf</guid>
      <description>&lt;p&gt;AI development is moving fast — but one thing that still slows developers down is &lt;strong&gt;relying on cloud APIs&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
What if you could run powerful &lt;strong&gt;LLMs (Large Language Models)&lt;/strong&gt; locally, just like spinning up a Docker container?  &lt;/p&gt;

&lt;p&gt;In this blog, I’ll show you how to:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run LLMs locally using &lt;strong&gt;Docker’s Model Runner&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Pull and run the &lt;strong&gt;Qwen 3&lt;/strong&gt; model
&lt;/li&gt;
&lt;li&gt;Connect it to a &lt;strong&gt;.NET console app&lt;/strong&gt; with &lt;strong&gt;Semantic Kernel&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s get started! 🚀&lt;/p&gt;

&lt;p&gt;For a more in-depth walk-through, be sure to watch my &lt;a href="https://youtu.be/J7lFLTfUAaE" rel="noopener noreferrer"&gt;YouTube video&lt;/a&gt;, where I demonstrate everything step by step!&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/J7lFLTfUAaE"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  🔹 Why Run LLMs Inside Docker?
&lt;/h2&gt;

&lt;p&gt;Docker is already the standard for packaging and running applications. Now, with &lt;strong&gt;Docker Model Runner&lt;/strong&gt;, you can:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pull AI models&lt;/strong&gt; just like Docker images
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run models locally&lt;/strong&gt; without cloud APIs
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Expose OpenAI-compatible APIs&lt;/strong&gt; to integrate seamlessly into apps
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This means you can &lt;strong&gt;test, prototype, and even deploy AI workloads locally&lt;/strong&gt; — cost-free and private.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔹 Step 1: Enable Docker Model Runner
&lt;/h2&gt;

&lt;p&gt;Open &lt;strong&gt;Docker Desktop → Settings → AI Features&lt;/strong&gt; and enable:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;Docker Model Runner&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Host-side TCP support&lt;/strong&gt; (on port &lt;code&gt;12434&lt;/code&gt;)
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allows models to expose REST APIs you can call from your apps.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔹 Step 2: Pull and Run Qwen 3 Model
&lt;/h2&gt;

&lt;p&gt;Open your terminal and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Pull the model&lt;/span&gt;
docker model pull qwen/qwen-3b

&lt;span class="c"&gt;# Run the model&lt;/span&gt;
docker model run qwen/qwen-3b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll see an &lt;strong&gt;interactive chat session&lt;/strong&gt; where you can ask questions.&lt;br&gt;&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; Hello
&amp;lt; Hi! How can I assist you today?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🔹 Step 3: Use REST API
&lt;/h2&gt;

&lt;p&gt;The model exposes endpoints on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:12434/v1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, to list available models:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl http://localhost:12434/models
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll see details of Qwen 3 and any other models you’ve pulled.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔹 Step 4: Connect with Semantic Kernel (.NET)
&lt;/h2&gt;

&lt;p&gt;The best part is — you don’t need to rewrite your app.&lt;br&gt;&lt;br&gt;
Semantic Kernel already works with OpenAI APIs, and since Docker exposes the &lt;strong&gt;same structure&lt;/strong&gt;, all you do is &lt;strong&gt;change the base URL&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Install packages
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet add package Microsoft.SemanticKernel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create a Console App
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.SemanticKernel&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Kernel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateBuilder&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddOpenAIChatCompletion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;modelId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"qwen/qwen-3b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"dummy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// not required for local&lt;/span&gt;
    &lt;span class="n"&gt;endpoint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Uri&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"http://localhost:12434/v1"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// Docker endpoint&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;kernel&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Build&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;kernel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;InvokePromptAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Explain Docker in simple terms."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s it! Your &lt;strong&gt;.NET app is now talking to Qwen 3 inside Docker&lt;/strong&gt;, through Semantic Kernel.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔹 Why This Matters
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🖥️ &lt;strong&gt;Local-first AI&lt;/strong&gt; → Run LLMs without internet or billing
&lt;/li&gt;
&lt;li&gt;🔒 &lt;strong&gt;Privacy&lt;/strong&gt; → Your data never leaves your machine
&lt;/li&gt;
&lt;li&gt;⚡ &lt;strong&gt;Developer-friendly&lt;/strong&gt; → Same SDKs, same APIs, just a different base URL
&lt;/li&gt;
&lt;li&gt;🔗 &lt;strong&gt;Drop-in replacement&lt;/strong&gt; → Move between local and cloud seamlessly
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ✅ Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Running AI models is now &lt;strong&gt;as easy as running containers&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
With &lt;strong&gt;Docker Model Runner&lt;/strong&gt;, you can:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pull Qwen 3
&lt;/li&gt;
&lt;li&gt;Run it locally
&lt;/li&gt;
&lt;li&gt;Connect it to .NET apps with Semantic Kernel
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This opens up endless possibilities for building &lt;strong&gt;intelligent apps without cloud dependencies&lt;/strong&gt;.  &lt;/p&gt;




&lt;p&gt;👉 What model are you planning to run first with Docker?&lt;br&gt;&lt;br&gt;
Drop a comment — I’d love to know!  &lt;/p&gt;

</description>
      <category>ai</category>
      <category>docker</category>
      <category>dotnet</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Build Your First AI Agent with Semantic Kernel &amp; DeepSeek R1 Locally with Ollama</title>
      <dc:creator>CodeStreet</dc:creator>
      <pubDate>Sat, 16 Aug 2025 02:40:49 +0000</pubDate>
      <link>https://forem.com/codestreet/how-to-build-your-first-ai-agent-with-semantic-kernel-deepseek-r1-locally-with-ollama-1c3i</link>
      <guid>https://forem.com/codestreet/how-to-build-your-first-ai-agent-with-semantic-kernel-deepseek-r1-locally-with-ollama-1c3i</guid>
      <description>&lt;p&gt;In this post, we will create our first AI Agent using the Microsoft Agentic Framework of Semantic Kernel and DeepSeek R1, running locally on Ollama. &lt;/p&gt;

&lt;p&gt;We’ll walk step by step through setting up a Semantic Kernel agent that leverages DeepSeek R1 via Ollama, showing you how to install the tools, configure the model locally, and connect everything together. By the end, you’ll have a working AI YouTube Title Generator agent running entirely on your machine locally—no cloud subscription required.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/wyLnlnD71Iw"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  What You Will Learn
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How to Get Started with DeepSeek R1&lt;/li&gt;
&lt;li&gt;How to Use Ollama for running local models&lt;/li&gt;
&lt;li&gt;How to install and start running the DeepSeek R1 model&lt;/li&gt;
&lt;li&gt;How to Use Semantic Kernel in C#&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Visual Studio 2022+ (with .NET 9 SDK installed)
.NET 9 is still in preview, so ensure that you have the preview SDK installed.&lt;/li&gt;
&lt;li&gt;Ollama (for managing and running local models)&lt;/li&gt;
&lt;li&gt;DeepSeek1.5b Model&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Installing Ollama
&lt;/h2&gt;

&lt;p&gt;Ollama is a platform or tool (specific details may vary depending on the context) that allows users to interact with large language models (LLMs) locally. It simplifies the process of deploying and running LLMs like LLaMA, Phi, DeepSeek R1, or other open-source models.&lt;/p&gt;

&lt;p&gt;To install Ollama, visit its official website &lt;a href="https://ollama.com/download" rel="noopener noreferrer"&gt;https://ollama.com/download&lt;/a&gt; and install it on your machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Installing DeepSeek R1
&lt;/h2&gt;

&lt;p&gt;DeepSeek's first-generation reasoning models have comparable performance to OpenAI-o1, including six dense models distilled from DeepSeek-R1 based on Llama and Qwen.&lt;/p&gt;

&lt;p&gt;On the Ollama website click on &lt;a href="https://ollama.com/search" rel="noopener noreferrer"&gt;Models&lt;/a&gt; and click on deepseek-r1 and choose &lt;strong&gt;1.5b&lt;/strong&gt; parameter option&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9l8gj5m9zlsvqe84whc5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9l8gj5m9zlsvqe84whc5.png" alt="How To Use DeepSeek With .NET 9 - deepseek-r1:1.5b"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open Command Prompt and run the command below.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ollama run deepseek-r1:1.5b&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;It will download the model and start running automatically.&lt;/p&gt;

&lt;p&gt;Once done, verify that the model is available&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ollama list&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;That’s it! We’re ready to integrate DeepSeek locally.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Creating .NET Console Application
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Launch Visual Studio&lt;/li&gt;
&lt;li&gt;Make sure .NET 9 is installed.&lt;/li&gt;
&lt;li&gt;Create a New Project&lt;/li&gt;
&lt;li&gt;File → New → Project…&lt;/li&gt;
&lt;li&gt;Pick Console App with .NET 9.&lt;/li&gt;
&lt;li&gt;Name Your Project&lt;/li&gt;
&lt;li&gt;e.g., DeepSeekDemoApp or any name you prefer.&lt;/li&gt;
&lt;li&gt;Target Framework Check&lt;/li&gt;
&lt;li&gt;Right-click on your project → Properties.&lt;/li&gt;
&lt;li&gt;Set Target Framework to .NET 9.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  5. Integrating DeepSeek R1 with Semantic Kernel
&lt;/h2&gt;

&lt;p&gt;While you could call DeepSeek via direct HTTP requests to Ollama, using Semantic Kernel offers a powerful abstraction for prompt engineering, orchestration, and more.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add Necessary NuGet Packages
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ItemGroup&amp;gt;
  &amp;lt;PackageReference Include="Microsoft.SemanticKernel" Version="1.61.0" /&amp;gt;
  &amp;lt;PackageReference Include="Microsoft.SemanticKernel.Agents.Core" Version="1.61.0" /&amp;gt;
  &amp;lt;PackageReference Include="Microsoft.SemanticKernel.Connectors.Ollama" Version="1.61.0-alpha" /&amp;gt;
&amp;lt;/ItemGroup&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. Complete code
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Program.cs&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;

var builder = Kernel.CreateBuilder().AddOllamaChatCompletion("deepseek-r1:1.5b",
    new HttpClient
    {
        BaseAddress = new Uri("http://localhost:11434"),

    });

Kernel kernel = builder.Build();

Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("Welcome to TheCodeStreet - AI YouTube Title Generator!");
Console.WriteLine("------------------------------------------------------");
Console.ResetColor();
Console.WriteLine("Provide the keyword to generate title:");
string keyword = Console.ReadLine()?? "";


string instructions = """
You are a professional YouTube content strategist and SEO expert.

🎯 Keyword or Topic: {{keyword}}

Your job is to generate 5 click-worthy and SEO-friendly YouTube video titles based on a given topic or keyword.

📌 Guidelines for Generating Titles:

-- Keep them under 70 characters if possible.
-- Include emotional triggers, power words, or numbers (e.g., “Top 5”, “You Won’t Believe…”).
-- Use strong action verbs (e.g., “Boost”, “Master”, “Avoid”, “Unlock”).
-- Make titles engaging and curiosity-driven (clickbait style but still relevant).
-- Include the keyword or topic for SEO.
-- Avoid duplicate or overly similar titles.

💡 Return only the titles in a numbered list format like:
1. Title one...
2. Title two...
3. ...
""";

 instructions = instructions
    .Replace("{{keyword}}", keyword);

ChatCompletionAgent agent =
    new()
    {
        Name = "TitleGeneratorAgent",
        Instructions = instructions,
        Kernel = kernel,
    };

Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Generating titles...");
Console.WriteLine("------------------------------------------------------");
await foreach (AgentResponseItem&amp;lt;StreamingChatMessageContent&amp;gt; response
    in agent.InvokeStreamingAsync())
{
    Console.Write(response.Message.Content.Replace("**",""));
}
Console.ResetColor();
Console.ReadKey();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  7. Running &amp;amp; Testing
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Ensure Ollama is Running&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;-Some systems auto-run Ollama; otherwise, start it&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ollama run&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run Your .NET App&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;-Hit F5 (or Ctrl+F5) in Visual Studio.&lt;/p&gt;

&lt;p&gt;-Watch for console output—&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2u7vjd07arnok106piz6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2u7vjd07arnok106piz6.png" alt="YouTube Title Generator Agent"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Support me!
&lt;/h2&gt;

&lt;p&gt;If you found this guide helpful, make sure to check out the accompanying YouTube video tutorial where I walk you through the process visually. Don’t forget to &lt;a href="https://youtube.com/@TheCodeStreet?sub_confirmation=1" rel="noopener noreferrer"&gt;subscribe to my channel&lt;/a&gt; for more amazing tutorials!&lt;/p&gt;

&lt;p&gt;I would appreciate it if you could buy me a coffee.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbgo17dxrwwbcyvtij06.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbgo17dxrwwbcyvtij06.png" alt="Buy me a coffee"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to leave your questions, comments, or suggestions below. Happy coding!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>semantickernel</category>
      <category>dotnet</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Create RAG using DeepSeek R1, Ollama &amp; Semantic Kernel .NET</title>
      <dc:creator>CodeStreet</dc:creator>
      <pubDate>Tue, 04 Mar 2025 06:20:59 +0000</pubDate>
      <link>https://forem.com/codestreet/how-to-create-rag-using-deepseek-r1-ollama-semantic-kernel-net-4n1c</link>
      <guid>https://forem.com/codestreet/how-to-create-rag-using-deepseek-r1-ollama-semantic-kernel-net-4n1c</guid>
      <description>&lt;p&gt;Have you ever wanted to combine your own data with AI to get instant insights? In this blog post, we’ll explore exactly how to do that by building a &lt;strong&gt;Retriever-Augmented Generation (RAG)&lt;/strong&gt; application using &lt;strong&gt;DeepSeek R1&lt;/strong&gt;, &lt;strong&gt;Ollama&lt;/strong&gt;, and &lt;strong&gt;Semantic Kernel&lt;/strong&gt;. Our example scenario is a simple &lt;em&gt;expense manager&lt;/em&gt; that tracks daily spending and lets AI answer natural-language questions like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;"How much did I spend on coffee?"&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;"Which day did I spend the most money overall?"&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;"Which day did I spend the least money overall?"&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By the end of this post, you’ll see how you can load your own data (e.g., a text file, PDF documents, or others) and perform natural language Q&amp;amp;A over it using these tools. &lt;/p&gt;

&lt;p&gt;For a more in-depth walk-through, be sure to watch my &lt;a href="https://youtu.be/B4bulA7Vx3o" rel="noopener noreferrer"&gt;YouTube video&lt;/a&gt;, where I demonstrate everything step by step!&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/B4bulA7Vx3o"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  What is RAG (Retriever-Augmented Generation)?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Retriever-Augmented Generation&lt;/strong&gt; (RAG) is an approach that combines:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A Retriever&lt;/strong&gt;: A system/component to fetch relevant documents or pieces of data from a larger collection (e.g., your expense records).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A Language Model&lt;/strong&gt;: A large language model (LLM) that can generate natural language responses based on prompts and retrieved context.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When you ask a question, RAG retrieves relevant snippets or documents from your dataset and uses them to ground the LLM’s response. This helps the AI give more accurate and context-aware answers by focusing on information you’ve provided. Essentially, you augment the AI’s knowledge by feeding it the specific data you care about.&lt;/p&gt;




&lt;h2&gt;
  
  
  Use Cases of RAG
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Customer Support&lt;/strong&gt;: Quickly retrieve knowledge base articles and feed them to an LLM for on-demand issue resolution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Content Search&lt;/strong&gt;: Search large text corpuses and summarize or answer queries about them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Personal Knowledge Management&lt;/strong&gt;: Organize personal notes or expense records, and use AI to query them or generate insights.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Finance and Expense Tracking&lt;/strong&gt;: Like in our example, store transaction history, then ask AI to identify spending patterns, daily totals, or anomalies.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  1. Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Visual Studio 2022+ (with .NET 9 SDK installed)
.NET 9 is still in preview, so ensure that you have the preview SDK installed.&lt;/li&gt;
&lt;li&gt;Ollama (for managing and running local models)&lt;/li&gt;
&lt;li&gt;DeepSeek1.5b Model&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Installing Ollama
&lt;/h2&gt;

&lt;p&gt;Ollama is a platform or tool (specific details may vary depending on the context) that allows users to interact with large language models (LLMs) locally. It simplifies the process of deploying and running LLMs like LLaMA, Phi, DeepSeek R1, or other open-source models.&lt;/p&gt;

&lt;p&gt;To install Ollama visit its official website &lt;a href="https://ollama.com/download" rel="noopener noreferrer"&gt;https://ollama.com/download&lt;/a&gt; and install it on your machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Installing DeepSeek R1
&lt;/h2&gt;

&lt;p&gt;DeepSeek's first-generation reasoning models with comparable performance to OpenAI-o1, including six dense models distilled from DeepSeek-R1 based on Llama and Qwen.&lt;/p&gt;

&lt;p&gt;On the Ollama website click on &lt;a href="https://ollama.com/search" rel="noopener noreferrer"&gt;Models&lt;/a&gt; and click on deepseek-r1 and choose &lt;strong&gt;1.5b&lt;/strong&gt; parameter option&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9l8gj5m9zlsvqe84whc5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9l8gj5m9zlsvqe84whc5.png" alt="How To Use DeepSeek With .NET 9 - deepseek-r1:1.5b" width="800" height="724"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open Command Prompt and run the below command.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ollama run deepseek-r1:1.5b&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;It will download the model and start running automatically.&lt;/p&gt;

&lt;p&gt;Once done, verify the model is available&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ollama list&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;That’s it! We’re ready to integrate DeepSeek locally.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Creating .NET Console Application
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Launch Visual Studio&lt;/li&gt;
&lt;li&gt;Make sure .NET 9 is installed.&lt;/li&gt;
&lt;li&gt;Create a New Project&lt;/li&gt;
&lt;li&gt;File → New → Project…&lt;/li&gt;
&lt;li&gt;Pick Console App with .NET 9.&lt;/li&gt;
&lt;li&gt;Name Your Project&lt;/li&gt;
&lt;li&gt;e.g., DeepSeekDemoApp or any name you prefer.&lt;/li&gt;
&lt;li&gt;Target Framework Check&lt;/li&gt;
&lt;li&gt;Right-click on your project → Properties.&lt;/li&gt;
&lt;li&gt;Set Target Framework to .NET 9.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  5. Integrating DeepSeek R1 with Semantic Kernel
&lt;/h2&gt;

&lt;p&gt;While you could call DeepSeek via direct HTTP requests to Ollama, using Semantic Kernel offers a powerful abstraction for prompt engineering, orchestration, and more.&lt;/p&gt;

&lt;h3&gt;
  
  
  Add Necessary NuGet Packages
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ItemGroup&amp;gt;
  &amp;lt;PackageReference Include="Microsoft.KernelMemory.AI.Ollama" Version="0.97.250211.1" /&amp;gt;
&amp;lt;PackageReference Include="Microsoft.KernelMemory.Core" Version="0.97.250211.1" /&amp;gt;
  &amp;lt;PackageReference Include="Microsoft.SemanticKernel" Version="1.35.0" /&amp;gt;
&amp;lt;/ItemGroup&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;a href="https://buymeacoffee.com/codestreet/e/374480" rel="noopener noreferrer"&gt;Download Complete Project&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Source Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using Microsoft.KernelMemory;
using Microsoft.KernelMemory.AI.Ollama;

var config = new OllamaConfig
{
    Endpoint = "http://localhost:11434",
    TextModel = new OllamaModelConfig("deepseek-r1:1.5b", 131072),
    EmbeddingModel = new OllamaModelConfig("deepseek-r1:1.5b", 2048)
};

var memory = new KernelMemoryBuilder()
    .WithOllamaTextGeneration(config)
    .WithOllamaTextEmbeddingGeneration(config)
    .Build&amp;lt;MemoryServerless&amp;gt;();

Console.WriteLine("Processing document, please wait...");

await memory.ImportDocumentAsync("expenses.txt", documentId: "DOC001");

Console.WriteLine("Model is ready to take questions\n");

while(await memory.IsDocumentReadyAsync("DOC002"))
{

    Console.WriteLine("Ask your questions\n");

    var question = Console.ReadLine();

    var answer = await memory.AskAsync(question);

    Console.WriteLine(answer.Result);

    Console.WriteLine("\n Sources:");

    foreach(var x in answer.RelevantSources)
    {
        Console.WriteLine($" {x.SourceName} - {x.SourceUrl} - {x.Link}");
    }

}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Daily expense data
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Date        | Category       | Amount
------------|----------------|-------
2025-02-13  | Groceries      | 45.30
2025-02-13  | Transport      | 12.00
2025-02-14  | Coffee         | 4.50
2025-02-14  | Rent           | 800.00
2025-02-15  | Groceries      | 54.20
2025-02-16  | Entertainment  | 30.00
2025-02-16  | Transport      | 10.00
2025-02-17  | Bills          | 120.00
2025-02-17  | Coffee         | 3.75
2025-02-18  | Groceries      | 62.40

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Save this info as expenses.txt, put it into the bin directory, and run the application.
&lt;/h3&gt;

&lt;p&gt;Now you are good for asking some questions like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;“How much did I spend on coffee?”&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;“Which day did I spend the most money overall?”&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;“Which day did I spend the least money overall?”&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The AI will use the embedded expense data to calculate or deduce answers. It should also list the sources (e.g., the document ID containing relevant info)&lt;/p&gt;

&lt;h2&gt;
  
  
  Support me
&lt;/h2&gt;

&lt;p&gt;If you found this guide helpful, make sure to check out the accompanying YouTube video tutorial, in which I walk you through the process visually. Don’t forget to &lt;a href="https://youtube.com/@TheCodeStreet?sub_confirmation=1" rel="noopener noreferrer"&gt;subscribe to my channel&lt;/a&gt; for more amazing tutorials!&lt;/p&gt;

&lt;p&gt;I would appreciate it if you could buy me a coffee.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbgo17dxrwwbcyvtij06.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbgo17dxrwwbcyvtij06.png" alt="Buy me a coffee" width="700" height="700"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>deepseek</category>
      <category>ai</category>
      <category>rag</category>
      <category>csharp</category>
    </item>
    <item>
      <title>How to Build Blog Generator AI App Using Deep Seek R1 and Semantic Kernel in .NET9</title>
      <dc:creator>CodeStreet</dc:creator>
      <pubDate>Thu, 06 Feb 2025 10:46:19 +0000</pubDate>
      <link>https://forem.com/codestreet/how-to-build-blog-generator-ai-app-using-deep-seek-r1-and-semantic-kernel-in-net9-5555</link>
      <guid>https://forem.com/codestreet/how-to-build-blog-generator-ai-app-using-deep-seek-r1-and-semantic-kernel-in-net9-5555</guid>
      <description>&lt;p&gt;In this post, I’m excited to share the journey behind our latest project: building a blog generator AI app that harnesses the power of Deep Seek R1, Semantic Kernel, and .NET9. This blog serves as a companion to my YouTube video where I walk through the entire process step-by-step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Have you ever found yourself staring at a blank screen, struggling to come up with blog content? What if you could let AI do the heavy lifting and generate blog posts for you? In this tutorial, I'll show you how to build an AI-powered blog generator that not only speeds up content creation but also produces quality posts automatically.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/s4xWkZL69pg"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  What You'll Learn
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Integrating Deep Seek R1:&lt;/strong&gt; Learn how to leverage advanced search capabilities to gather relevant content and ideas.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Using Semantic Kernel:&lt;/strong&gt; Discover how to orchestrate AI tasks for natural language processing and content generation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Building with .NET9:&lt;/strong&gt; See how .NET9 provides a robust framework for developing and deploying your AI application.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Step-by-Step Guidance:&lt;/strong&gt; Follow a clear, concise guide that breaks down the process into manageable steps.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why Build an AI-Powered Blog Generator?
&lt;/h2&gt;

&lt;p&gt;Automating blog creation saves you time and effort, allowing you to focus on other aspects of your business or creative pursuits. This project not only demonstrates cutting-edge technology integration but also provides a scalable solution for content creators and developers alike.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technologies at a Glance
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Deep Seek R1:&lt;/strong&gt; This tool helps in deep searching, ensuring your content is backed by extensive and relevant data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Semantic Kernel:&lt;/strong&gt; Acts as the brain behind content generation by processing natural language and orchestrating AI tasks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;.NET9:&lt;/strong&gt; The latest iteration of .NET offers improved performance, modern features, and a great development experience for building robust applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Visual Studio 2022+ (with .NET 9 SDK installed)
.NET 9 is still in preview, so ensure that you have the preview SDK installed.&lt;/li&gt;
&lt;li&gt;Ollama (for managing and running local models)&lt;/li&gt;
&lt;li&gt;DeepSeek1.5b Model&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Installing Ollama
&lt;/h2&gt;

&lt;p&gt;Ollama is a platform or tool (specific details may vary depending on the context) that allows users to interact with large language models (LLMs) locally. It simplifies the process of deploying and running LLMs like LLaMA, Phi, DeepSeek R1, or other open-source models.&lt;/p&gt;

&lt;p&gt;To install Ollama visit its official website &lt;a href="https://ollama.com/download" rel="noopener noreferrer"&gt;https://ollama.com/download&lt;/a&gt; and install it on your machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Installing DeepSeek R1
&lt;/h2&gt;

&lt;p&gt;DeepSeek's first-generation reasoning models with comparable performance to OpenAI-o1, including six dense models distilled from DeepSeek-R1 based on Llama and Qwen.&lt;/p&gt;

&lt;p&gt;On the Ollama website click on &lt;a href="https://ollama.com/search" rel="noopener noreferrer"&gt;Models&lt;/a&gt; and click on deepseek-r1 and choose &lt;strong&gt;1.5b&lt;/strong&gt; parameter option&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9l8gj5m9zlsvqe84whc5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9l8gj5m9zlsvqe84whc5.png" alt="How To Use DeepSeek With .NET 9 - deepseek-r1:1.5b" width="800" height="724"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open Command Prompt and run the below command.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ollama run deepseek-r1:1.5b&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;It will download the model and start running automatically.&lt;/p&gt;

&lt;p&gt;Once done, verify the model is available&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ollama list&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;That’s it! We’re ready to integrate DeepSeek locally.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Creating .NET Console Application
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Launch Visual Studio&lt;/li&gt;
&lt;li&gt;Make sure .NET 9 is installed.&lt;/li&gt;
&lt;li&gt;Create a New Project&lt;/li&gt;
&lt;li&gt;File → New → Project…&lt;/li&gt;
&lt;li&gt;Pick Console App with .NET 9.&lt;/li&gt;
&lt;li&gt;Name Your Project&lt;/li&gt;
&lt;li&gt;e.g., DeepSeekDemoApp or any name you prefer.&lt;/li&gt;
&lt;li&gt;Target Framework Check&lt;/li&gt;
&lt;li&gt;Right-click on your project → Properties.&lt;/li&gt;
&lt;li&gt;Set Target Framework to .NET 9.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  5. Integrating DeepSeek R1 with Semantic Kernel
&lt;/h2&gt;

&lt;p&gt;While you could call DeepSeek via direct HTTP requests to Ollama, using Semantic Kernel offers a powerful abstraction for prompt engineering, orchestration, and more.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add Necessary NuGet Packages
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ItemGroup&amp;gt;
  &amp;lt;PackageReference Include="Codeblaze.SemanticKernel.Connectors.Ollama" Version="1.3.1" /&amp;gt;
  &amp;lt;PackageReference Include="Microsoft.SemanticKernel" Version="1.35.0" /&amp;gt;
&amp;lt;/ItemGroup&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Codeblaze.SemanticKernel.Connectors.Ollama;
using Microsoft.Extensions.DependencyInjection;

var builder = Kernel.CreateBuilder().AddOllamaChatCompletion("deepseek-r1:1.5b", "http://localhost:11434");

builder.Services.AddScoped&amp;lt;HttpClient&amp;gt;();

Kernel kernel = builder.Build();
var chatCompletionService = kernel.GetRequiredService&amp;lt;IChatCompletionService&amp;gt;();

string GetUserInput(string prompt)
{
    Console.ForegroundColor = ConsoleColor.Green;
    Console.WriteLine(prompt);
    Console.ForegroundColor = ConsoleColor.White;
    return Console.ReadLine();
}

string topic = GetUserInput("Tell me the topic for the blog");
string tone = GetUserInput("Provide blog tone");
int length = Convert.ToInt32(GetUserInput("Provide total blog length"));
string keywords = GetUserInput("Provide some keywords to target");

string prompt = $@"
Your_prompt
";

var blogResponse = await kernel.InvokePromptAsync(prompt);

Console.ForegroundColor = ConsoleColor.DarkCyan;

Console.WriteLine(blogResponse.ToString());

Console.WriteLine("Press enter to exit...");
Console.ReadLine();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://buymeacoffee.com/codestreet/e/368951" rel="noopener noreferrer"&gt;Downlaod Complete Project&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Generated Blog
&lt;/h2&gt;

&lt;p&gt;It generates the blog into markdown format, which Dev.to and Github support, you can also easily convert it into WordPress formats.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fikb9spve5qfe3y8uihj3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fikb9spve5qfe3y8uihj3.png" alt="How to Build Blog Generator AI App Using Deep Seek R1" width="800" height="397"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# The Future of Social Media Marketing: Why It’s Revolutionizing Modern Business Strategies  

## The Rise of Social Media in the Modern World  

In an era where social media has taken center stage as a key tool for business growth, social media marketing has emerged as a transformative force. From connecting with customers and driving sales to engaging the public on every level, this platform is reshaping how businesses approach their communication strategies.  

## The Key Benefits of Social Media Marketing  

### 1. **Sustainable Social Media Strategy**  
One of the most significant advantages of social media marketing is its ability to break free from traditional marketing boundaries. By leveraging platforms like Instagram and Facebook, businesses can consistently build relationships with customers who may not be reachable through other channels. This strategy ensures that the brand remains relevant and effective in the face of ever-changing market conditions.  

### 2. **Increased Visibility &amp;amp; Reach**  
Social media is renowned for its global reach. Through consistent posting and interactive content, brands gain visibility beyond their local markets. For example, a small business might see its product appear on billions of Instagram stories or Facebook posts every day, creating a loyal audience that would be difficult to compete with in a traditional marketing campaign.  

### 3. **Targeted Audience Engagement**  
One of the most powerful tools of social media marketing is its ability to target specific audiences. By analyzing data from platforms like Instagram and Facebook, businesses can identify demographics and interests where they can create more effective campaigns. This targeted approach ensures that marketing efforts align with customer needs, leading to higher engagement and conversions.  

### 4. **Building a Social Following**  
Social media is not just about sharing content; it’s also about building a community around the brand. By engaging with followers regularly and responding to comments, businesses can establish trust and credibility. This follows can lead to long-term relationships with customers who are drawn to brands that value their connection and want to share their own.  

### 5. **Improved Customer Relationships**  
Social media marketing is about more than just selling a product. It’s also about fostering meaningful connections. By sharing personal stories, tips, and updates, businesses can connect deeply with their audience and strengthen long-term relationships. This creates loyalty and trust that can translate into repeat business.  

## Examples of Social Media Marketing in Action  

### Instagram Marketing: A Global Reach  
A small tech startup, *TechGenius*, used Instagram to launch its latest product line. They created content that highlighted the benefits of their innovation, connecting with customers across countries through consistent posting and interactive posts. This strategy not only brought their product to a global audience but also built a loyal following.  

### Facebook Marketing: Building a Community  
A retail store, *FashionFlix*, used Facebook to create a community around its products. By sharing behind-the-scenes content, engaging with customers, and participating in influencer collaborations, the brand established itself as knowledgeable and trustworthy. This not only helped sell their clothing but also fostered connections that could lead to word-of-mouth referrals.  

### A/B Testing on Social Media: Measuring Success  
Social media marketing often involves testing different strategies to determine what works best for a business. By running A/B tests on platforms like Instagram or Facebook, companies can see which content types resonate with their audience and adjust their marketing efforts accordingly. This data-driven approach ensures that marketing initiatives are effective and aligned with customer needs.  

## Tools &amp;amp; Platforms for Social Media Marketing  

From content creation tools to analytics platforms, there’s no shortage of resources available to businesses looking to improve their social media strategy. Platforms like Instagram, Facebook, and YouTube have built into them powerful tools for creating engaging posts, tracking engagement, and measuring performance. By utilizing these features effectively, businesses can maximize the impact of their social media marketing efforts.  

## The Ultimate Guide: Tips on Social Media Marketing  

### 1. **Content Creation**  
The foundation of any successful social media strategy is well-crafted content. Businesses should focus on creating engaging, relevant, and timely posts that resonate with their audience. Whether it’s showcasing a product, sharing tips for a task or discussing recent events, the right content can catch people’s attention and encourage action.  

### 2. **Engagement**  
Social media is not just about posting; it’s also about interacting with your audience. Regular updates and timely responses to comments and questions create a sense of connection and trust. This engagement not only helps build relationships but also reinforces the brand’s message, making customers more likely to return for future purchases.  

### 3. **Analytics**  
To maximize the effectiveness of social media marketing, businesses should track their performance through analytics tools. These tools allow them to measure the impact of their content, identify trends in their audience, and adjust their strategies accordingly. By staying data-driven, they can ensure that their efforts are aligned with customer needs and driving results.  

### 4. **Leverage Influencer Marketing**  
Influencers are a powerful tool in social media marketing. Businesses should engage with influencers to gain credibility and reach a wider audience. Collaborating with influencers or following them on platforms like Instagram can help establish authority and trust, leading to more engagement from their followers.  

### 5. **Stay Updated with Trends**  
Social media is a dynamic platform that evolves quickly. To stay ahead of the curve, businesses should be aware of new trends and tools available on platforms like Instagram, Facebook, and Twitter. Keeping their strategy updated ensures they remain relevant in a competitive market and can adapt to changing customer preferences.  


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Support me
&lt;/h2&gt;

&lt;p&gt;If you found this guide helpful, make sure to check out the accompanying YouTube video tutorial where I walk you through the process visually. Don’t forget to &lt;a href="https://youtube.com/@TheCodeStreet?sub_confirmation=1" rel="noopener noreferrer"&gt;subscribe to my channel&lt;/a&gt; for more amazing tutorials!&lt;/p&gt;

&lt;p&gt;I would appreciate it if you could buy me a coffee.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbgo17dxrwwbcyvtij06.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbgo17dxrwwbcyvtij06.png" alt="Buy me a coffee" width="700" height="700"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Building a blog generator AI app is not only an exciting project but also a practical solution for anyone looking to enhance their content creation process. I hope this guide inspires you to explore the possibilities of AI in your projects. If you have any questions or ideas, feel free to leave a comment below!&lt;/p&gt;

&lt;p&gt;Feel free to leave your questions, comments, or suggestions below. Happy coding!&lt;/p&gt;

</description>
      <category>deepseek</category>
      <category>dotnet</category>
      <category>ai</category>
      <category>csharp</category>
    </item>
    <item>
      <title>How To Use DeepSeek With .NET 9 | Hands-On With DeepSeek R1, Semantic Kernel &amp; C#</title>
      <dc:creator>CodeStreet</dc:creator>
      <pubDate>Sat, 01 Feb 2025 07:40:23 +0000</pubDate>
      <link>https://forem.com/codestreet/how-to-use-deepseek-with-net-9-hands-on-with-deepseek-r1-semantic-kernel-c-16ol</link>
      <guid>https://forem.com/codestreet/how-to-use-deepseek-with-net-9-hands-on-with-deepseek-r1-semantic-kernel-c-16ol</guid>
      <description>&lt;p&gt;In this post, we will integrate DeepSeek R1 into a .NET 9 using Semantic Kernel. If you’re looking to get started with DeepSeek models locally, this hands-on guide is for you.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/iN42Q55YTxQ"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  What You Will Learn
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How to Get Started with DeepSeek R1&lt;/li&gt;
&lt;li&gt;How to Use Ollama for running local models&lt;/li&gt;
&lt;li&gt;How to install and start running the DeepSeek R1 model&lt;/li&gt;
&lt;li&gt;How to Use Semantic Kernel in C#&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Visual Studio 2022+ (with .NET 9 SDK installed)
.NET 9 is still in preview, so ensure that you have the preview SDK installed.&lt;/li&gt;
&lt;li&gt;Ollama (for managing and running local models)&lt;/li&gt;
&lt;li&gt;DeepSeek1.5b Model&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Installing Ollama
&lt;/h2&gt;

&lt;p&gt;Ollama is a platform or tool (specific details may vary depending on the context) that allows users to interact with large language models (LLMs) locally. It simplifies the process of deploying and running LLMs like LLaMA, Phi, DeepSeek R1, or other open-source models.&lt;/p&gt;

&lt;p&gt;To install Ollama visit its official website &lt;a href="https://ollama.com/download" rel="noopener noreferrer"&gt;https://ollama.com/download&lt;/a&gt; and install it on your machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Installing DeepSeek R1
&lt;/h2&gt;

&lt;p&gt;DeepSeek's first-generation reasoning models with comparable performance to OpenAI-o1, including six dense models distilled from DeepSeek-R1 based on Llama and Qwen.&lt;/p&gt;

&lt;p&gt;On the Ollama website click on &lt;a href="https://ollama.com/search" rel="noopener noreferrer"&gt;Models&lt;/a&gt; and click on deepseek-r1 and choose &lt;strong&gt;1.5b&lt;/strong&gt; parameter option&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9l8gj5m9zlsvqe84whc5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9l8gj5m9zlsvqe84whc5.png" alt="How To Use DeepSeek With .NET 9 - deepseek-r1:1.5b" width="800" height="724"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open Command Prompt and run the below command.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ollama run deepseek-r1:1.5b&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;It will download the model and start running automatically.&lt;/p&gt;

&lt;p&gt;Once done, verify the model is available&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ollama list&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;That’s it! We’re ready to integrate DeepSeek locally.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Creating .NET Console Application
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Launch Visual Studio&lt;/li&gt;
&lt;li&gt;Make sure .NET 9 is installed.&lt;/li&gt;
&lt;li&gt;Create a New Project&lt;/li&gt;
&lt;li&gt;File → New → Project…&lt;/li&gt;
&lt;li&gt;Pick Console App with .NET 9.&lt;/li&gt;
&lt;li&gt;Name Your Project&lt;/li&gt;
&lt;li&gt;e.g., DeepSeekDemoApp or any name you prefer.&lt;/li&gt;
&lt;li&gt;Target Framework Check&lt;/li&gt;
&lt;li&gt;Right-click on your project → Properties.&lt;/li&gt;
&lt;li&gt;Set Target Framework to .NET 9.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  5. Integrating DeepSeek R1 with Semantic Kernel
&lt;/h2&gt;

&lt;p&gt;While you could call DeepSeek via direct HTTP requests to Ollama, using Semantic Kernel offers a powerful abstraction for prompt engineering, orchestration, and more.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add Necessary NuGet Packages
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ItemGroup&amp;gt;
  &amp;lt;PackageReference Include="Codeblaze.SemanticKernel.Connectors.Ollama" Version="1.3.1" /&amp;gt;
  &amp;lt;PackageReference Include="Microsoft.SemanticKernel" Version="1.35.0" /&amp;gt;
&amp;lt;/ItemGroup&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. Complete code
&lt;/h2&gt;

&lt;p&gt;The Semantic Kernel can use a custom connector to talk to local endpoints. For simplicity, we’ll outline a sample approach:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Program.cs&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using Codeblaze.SemanticKernel.Connectors.Ollama;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;

var builder = Kernel.CreateBuilder().AddOllamaChatCompletion("deepseek-r1:1.5b", "http://localhost:11434");

builder.Services.AddScoped&amp;lt;HttpClient&amp;gt;();
var kernel = builder.Build();

while (true)
{
    string input = "";
    Console.WriteLine("Ask anything to Deepseek");
    input = Console.ReadLine();
    var response = await kernel.InvokePromptAsync(input);
    Console.WriteLine($"\nDeepseek: {response}\n");
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  7. Running &amp;amp; Testing
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Ensure Ollama is Running&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;-Some systems auto-run Ollama; otherwise, start it&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ollama run&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run Your .NET App&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;-Hit F5 (or Ctrl+F5) in Visual Studio.&lt;/p&gt;

&lt;p&gt;-Watch for console output—&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhv6wwvqi3srtvvnplkc7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhv6wwvqi3srtvvnplkc7.png" alt="Running DeepSeek on .NET" width="800" height="201"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Support me!
&lt;/h2&gt;

&lt;p&gt;If you found this guide helpful, make sure to check out the accompanying YouTube video tutorial where I walk you through the process visually. Don’t forget to &lt;a href="https://youtube.com/@TheCodeStreet?sub_confirmation=1" rel="noopener noreferrer"&gt;subscribe to my channel&lt;/a&gt; for more amazing tutorials!&lt;/p&gt;

&lt;p&gt;I would appreciate it if you could buy me a coffee.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbgo17dxrwwbcyvtij06.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbgo17dxrwwbcyvtij06.png" alt="Buy me a coffee" width="700" height="700"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to leave your questions, comments, or suggestions below. Happy coding!&lt;/p&gt;

</description>
      <category>deepseek</category>
      <category>dotnet</category>
      <category>ai</category>
      <category>csharp</category>
    </item>
    <item>
      <title>Create Your First AI-Powered C# App with Semantic Kernel: A Step-by-Step Guide</title>
      <dc:creator>CodeStreet</dc:creator>
      <pubDate>Tue, 10 Dec 2024 16:53:47 +0000</pubDate>
      <link>https://forem.com/codestreet/create-your-first-ai-powered-c-app-with-semantic-kernel-a-step-by-step-guide-3ca0</link>
      <guid>https://forem.com/codestreet/create-your-first-ai-powered-c-app-with-semantic-kernel-a-step-by-step-guide-3ca0</guid>
      <description>&lt;p&gt;Welcome to the exciting world of artificial intelligence (AI) development with C#! In this comprehensive guide, you'll learn how to &lt;strong&gt;build your first AI-powered application&lt;/strong&gt; using &lt;strong&gt;Semantic Kernel&lt;/strong&gt;, a powerful toolkit that seamlessly integrates advanced AI models with popular programming languages like C#. &lt;/p&gt;

&lt;p&gt;Whether you're a seasoned developer looking to dive into AI or a beginner eager to enhance your C# skills, this tutorial is designed to help you get started quickly and efficiently.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/-KJSopIOdls"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;What is Semantic Kernel?&lt;/li&gt;
&lt;li&gt;Prerequisites&lt;/li&gt;
&lt;li&gt;Setting Up Your Development Environment&lt;/li&gt;
&lt;li&gt;
Building Your First AI-Powered C# Application

&lt;ul&gt;
&lt;li&gt;Step 1: Create a New C# Console Application&lt;/li&gt;
&lt;li&gt;Step 2: Install Semantic Kernel&lt;/li&gt;
&lt;li&gt;Step 3: Integrate Semantic Kernel into Your Project&lt;/li&gt;
&lt;li&gt;Step 4: Implementing the Chatbot Logic&lt;/li&gt;
&lt;li&gt;Step 5: Running and Testing Your Application&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Enhancements and Next Steps&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  What is Semantic Kernel?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Semantic Kernel&lt;/strong&gt; is a robust toolkit (SDK) developed to bridge the gap between advanced AI models and conventional programming languages like C#, Python, and Java. &lt;/p&gt;

&lt;p&gt;By leveraging Semantic Kernel, developers can seamlessly integrate powerful AI capabilities from platforms such as &lt;strong&gt;OpenAI&lt;/strong&gt;, &lt;strong&gt;Azure OpenAI&lt;/strong&gt;, and &lt;strong&gt;Hugging Face&lt;/strong&gt; into their applications with minimal effort.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx10xrm05608up8r246ur.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx10xrm05608up8r246ur.png" alt="Image Credit: Microsoft" width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Features:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Easy Integration:&lt;/strong&gt; Connects AI models with C#, Python, Java, and more.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Plugin System:&lt;/strong&gt; Allows developers to create and link small functionalities called &lt;strong&gt;plugins&lt;/strong&gt; with just a few lines of code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI-Powered Automation:&lt;/strong&gt; Utilizes AI to automatically organize and manage these plugins, enabling the creation and execution of plans to achieve specific goals.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Choose Semantic Kernel?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Streamlined Development:&lt;/strong&gt; Quickly build complex AI applications by chaining plugins effortlessly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Intelligent Planning:&lt;/strong&gt; Let AI handle the orchestration of tasks, making your development process smarter and more efficient.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Versatility:&lt;/strong&gt; Supports multiple AI models and programming languages, providing flexibility for various projects.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before diving into building your AI-powered C# application, ensure you have the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Basic Knowledge of C#:&lt;/strong&gt; Familiarity with C# programming and the .NET framework.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Development Environment:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Visual Studio 2022&lt;/strong&gt; or later installed on your machine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;.NET SDK 9.0&lt;/strong&gt; installed.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Internet Connection:&lt;/strong&gt; Required for downloading dependencies and accessing AI services.&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;API Keys:&lt;/strong&gt; Access to AI services like OpenAI or Azure OpenAI (optional but recommended for enhanced functionalities).&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  Setting Up Your Development Environment
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Install Visual Studio
&lt;/h3&gt;

&lt;p&gt;If you haven't already, download and install &lt;a href="https://visualstudio.microsoft.com/" rel="noopener noreferrer"&gt;Visual Studio&lt;/a&gt; (preferably the latest version) to get started with C# development.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Install .NET SDK 9.0
&lt;/h3&gt;

&lt;p&gt;Download and install the &lt;a href="https://dotnet.microsoft.com/download/dotnet/9.0" rel="noopener noreferrer"&gt;.NET SDK 9.0&lt;/a&gt; to ensure compatibility with Semantic Kernel and to leverage the latest features of C#.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Create a New C# Console Application
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Open Visual Studio:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Launch Visual Studio and select &lt;strong&gt;"Create a new project"&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Choose Project Template:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select &lt;strong&gt;"Console App"&lt;/strong&gt; and click &lt;strong&gt;"Next"&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Configure Your Project:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Project Name:&lt;/strong&gt; &lt;code&gt;AIPoweredApp&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Location:&lt;/strong&gt; Choose a suitable directory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Framework:&lt;/strong&gt; Ensure &lt;code&gt;.NET 9.0&lt;/code&gt; is selected.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;"Create"&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 4: Install Semantic Kernel via NuGet
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Open NuGet Package Manager:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Right-click on your project in the &lt;strong&gt;Solution Explorer&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;"Manage NuGet Packages..."&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Browse and Install Semantic Kernel:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the &lt;strong&gt;Browse&lt;/strong&gt; tab, search for &lt;strong&gt;"SemanticKernel"&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select the package and click &lt;strong&gt;"Install"&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Accept any license agreements if prompted.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Building Your First AI-Powered C# Application
&lt;/h2&gt;

&lt;p&gt;In this section, we'll build a simple AI-powered chatbot that interacts with users through the console. The chatbot leverages Semantic Kernel to process user input and generate intelligent responses.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create a New C# Console Application
&lt;/h3&gt;

&lt;p&gt;Assuming you've already created a new C# Console Application named &lt;code&gt;AIPoweredApp&lt;/code&gt;, let's proceed to set up the project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Install Semantic Kernel
&lt;/h3&gt;

&lt;p&gt;As covered in the setup, ensure Semantic Kernel is installed via NuGet. This provides the necessary libraries to integrate AI functionalities into your application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Integrate Semantic Kernel into Your Project
&lt;/h3&gt;

&lt;p&gt;Open the &lt;code&gt;Program.cs&lt;/code&gt; file and set up the necessary namespaces and services.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;

var builder = Kernel.CreateBuilder();

builder.AddOpenAIChatCompletion("gpt-4o", "&amp;lt;&amp;lt;YOUR API KEY&amp;gt;&amp;gt;");

Kernel kernel = builder.Build();

var chatService = kernel.GetRequiredService&amp;lt;IChatCompletionService&amp;gt;();

ChatHistory chatHistory = new ChatHistory();

while (true)
{
    Console.ForegroundColor = ConsoleColor.Yellow;
    Console.Write("User&amp;gt;&amp;gt; ");

    var userMessage = Console.ReadLine();

    chatHistory.AddUserMessage(userMessage);

    var response = chatService.GetStreamingChatMessageContentsAsync(chatHistory, kernel: kernel);

    Console.ForegroundColor = ConsoleColor.Green;
    Console.Write("AI&amp;gt;&amp;gt; ");

    string fullMessage = "";

    await foreach(var chat in response)
    {
        Console.Write(chat);
        fullMessage += chat;
    }

    Console.WriteLine();

    chatHistory.AddAssistantMessage(fullMessage);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Enhancements and Next Steps
&lt;/h2&gt;

&lt;p&gt;Congratulations on building your first AI-powered C# application! To take your project further, consider the following enhancements:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add More AI Features:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Implement natural language understanding (NLU) for better context handling.&lt;br&gt;
Integrate sentiment analysis to tailor responses based on user emotions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Improve User Interface:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Develop a graphical user interface (GUI) using WPF or Windows Forms for a more interactive experience.&lt;br&gt;
Create a web-based interface using ASP.NET Core.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Persist Chat History:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Save conversation history to a database or file for future reference.&lt;br&gt;
Implement user authentication to manage personalized chats.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Deploy Your Application:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Host your application on cloud platforms like Azure or AWS.&lt;br&gt;
Make it accessible as a web service or mobile app.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Explore Advanced Semantic Kernel Features:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Utilize Semantic Kernel's planners for complex task automation.&lt;br&gt;
Integrate multiple AI models to enhance chatbot capabilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Embarking on AI development with C# and Semantic Kernel opens up a world of possibilities for creating intelligent and responsive applications. In this tutorial, you built a foundational AI-powered chatbot, setting the stage for more advanced projects and integrations. &lt;/p&gt;

&lt;p&gt;As you continue to explore and enhance your skills, Semantic Kernel will serve as a valuable tool in your AI development toolkit, enabling you to build sophisticated applications easily.&lt;/p&gt;

&lt;p&gt;Stay tuned for more tutorials in our AI C# Series, where we'll delve into advanced features, real-world projects, and optimization techniques to help you master AI integration in your C# applications.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>dotnet</category>
      <category>csharp</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Create Timer Trigger Azure Functions with .NET 9: Step-by-Step Guide for Beginners</title>
      <dc:creator>CodeStreet</dc:creator>
      <pubDate>Fri, 06 Dec 2024 03:42:57 +0000</pubDate>
      <link>https://forem.com/codestreet/how-to-create-timer-trigger-azure-functions-with-net-9-step-by-step-guide-for-beginners-37e7</link>
      <guid>https://forem.com/codestreet/how-to-create-timer-trigger-azure-functions-with-net-9-step-by-step-guide-for-beginners-37e7</guid>
      <description>&lt;p&gt;Welcome to this comprehensive guide on Mastering Timer Trigger Azure Functions with .NET 9 using Visual Studio! If you're venturing into serverless computing or aiming to enhance your Azure skillset, you've come to the right place. &lt;/p&gt;

&lt;p&gt;This tutorial will walk you through creating your first Timer Trigger Azure Function with .NET 9 using Visual Studio. We'll explore practical use cases, provide a step-by-step implementation, and discuss some potential drawbacks to help you make informed decisions.&lt;/p&gt;

&lt;p&gt;👉 Watch the accompanying video tutorial &lt;a href="https://youtu.be/B-I-A1g1GlE" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/B-I-A1g1GlE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Azure Functions and Timer Triggers
&lt;/h2&gt;

&lt;p&gt;Azure Functions is a serverless computing service offered by Microsoft Azure that allows you to run event-driven code without the need to manage infrastructure. Whether responding to HTTP requests, processing data from queues, or handling file uploads, Azure Functions provides a flexible and scalable platform for executing code based on various triggers.&lt;/p&gt;

&lt;p&gt;One such trigger is the Timer Trigger, which enables your function to run on a predefined schedule, much like a traditional cron job. Timer Triggers are perfect for tasks that need to be executed at regular intervals, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Data Backups: Automate the backup process of databases or file systems.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scheduled Notifications: Send out periodic email summaries or alerts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;System Maintenance: Perform routine maintenance tasks like cleaning up temporary files or optimizing databases.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Report Generation: Generate and distribute reports on a daily, weekly, or monthly basis.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This guide will focus on creating a Timer Trigger Azure Function using .NET 9 within Visual Studio, covering everything from setup to deployment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use Cases for Timer Trigger Azure Functions
&lt;/h2&gt;

&lt;p&gt;Timer Triggers are incredibly versatile and can be applied to a wide array of scenarios. Here are some common use cases:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scheduled Data Processing:&lt;/strong&gt; Automate tasks like aggregating data, generating reports, or processing logs at specific intervals.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;System Maintenance:&lt;/strong&gt; Perform routine maintenance tasks such as cleaning up temporary files, optimizing databases, or updating system configurations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Notifications and Alerts:&lt;/strong&gt; Send out regular email summaries, system health checks, or alert notifications to the users or system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automated Backups:&lt;/strong&gt; Schedule regular backups of databases, file systems, or application data to ensure data integrity and availability.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before diving into the tutorial, ensure you have the following tools and accounts set up:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Azure Account:&lt;/strong&gt; If you don't have one, you can sign up for a free trial on the Azure website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Visual Studio 2022 or Later:&lt;/strong&gt; Ensure you have Visual Studio installed. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Azure Functions Tools:&lt;/strong&gt; During the Visual Studio installation, ensure that the Azure development workload is selected. If already installed, you can modify your installation to include it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.NET 9 SDK:&lt;/strong&gt; Ensure you have the latest .NET 9 SDK installed. Download here.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Azure CLI (Optional):&lt;/strong&gt; Useful for managing Azure resources from the command line. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With these prerequisites in place, you're ready to create your first Timer Trigger Azure Function using Visual Studio.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating Your First Timer Trigger Azure Function in Visual Studio
&lt;/h2&gt;

&lt;p&gt;Let's embark on the journey of creating a Timer Trigger Azure Function using .NET 9 within Visual Studio. We'll follow a structured, step-by-step approach to ensure clarity and ease of understanding.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating Your First Timer Trigger Azure Function
&lt;/h2&gt;

&lt;p&gt;Let’s dive into creating a Timer Trigger Azure Function using .NET 9. We’ll follow a step-by-step approach to ensure clarity and ease of understanding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Open Visual Studio 2022&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Create New Project&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Search for “Azure Function”&lt;/strong&gt; (Make sure you have installed Azure Payload on your Visual Studio)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flyk5gtc48fvtx7bfp4g3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flyk5gtc48fvtx7bfp4g3.png" alt="Code Street - Steps to create Azure Timer Trigger Functions" width="800" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Choose Trigger Type and DotNet Version&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpsp0gevr2ettoi1gq4rc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpsp0gevr2ettoi1gq4rc.png" alt="Code Street - Steps to create Azure Timer Trigger Functions" width="800" height="496"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Click on Create&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After completing these steps, Visual Studio will scaffold your new Timer Trigger Azure Function with the necessary files and configurations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Function Code
&lt;/h2&gt;

&lt;p&gt;Let’s examine the generated code to understand how Timer Triggers work.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;

public static class ScheduledBackupFunction
{
    [FunctionName("ScheduledBackupFunction")]
    public static void Run([TimerTrigger("0*5 */5 * * * *")] TimerInfo myTimer, ILogger log)
    {
        log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
        // Add your backup logic here
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key Components:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;[FunctionName("ScheduledBackupFunction")]&lt;/strong&gt;: This attribute defines the name of the function.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;[TimerTrigger("0 */5 * * * *")]&lt;/strong&gt;: This attribute sets the schedule using a CRON expression. In this case, the function runs every 5 minutes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run Method&lt;/strong&gt; : Contains the code that executes when the function is triggered. Currently, it logs the execution time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before deploying to Azure, it’s essential to test your function locally.&lt;/p&gt;

&lt;p&gt;For that change the CRON expression to TimerTrigger &lt;strong&gt;*/5 * * * * *&lt;/strong&gt; so it will run in every 5 second.&lt;/p&gt;

&lt;p&gt;Press F5 to run and observe the log:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[2024-04-27T12:00:00.000Z] C# Timer trigger function executed at: 4/27/2024 12:00:00 PM
[2024-04-27T12:00:00.000Z] C# Timer trigger function executed at: 4/27/2024 12:00:05 PM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Something similar you will get.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploying the Function to Azure
&lt;/h3&gt;

&lt;p&gt;There are various ways to deploy the Azure functions you can follow along with the video for smooth deployment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Drawbacks of Timer Trigger Azure Functions
&lt;/h2&gt;

&lt;p&gt;While Timer Trigger Azure Functions are powerful, they come with certain limitations and potential drawbacks:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Dependency on Accurate Time Settings: Timer Triggers rely on CRON expressions, making them sensitive to time zone settings and daylight-saving changes. Incorrect configurations can lead to missed or duplicate executions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Limited Precision: The CRON schedule in Azure Functions doesn't support sub-minute precision. If you need tasks to run more frequently than once a minute, Timer Triggers might not be suitable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cold Start Delays: Especially on the Consumption Plan, functions might experience cold starts, leading to delays in execution when the function hasn't been invoked recently.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Complexity in Error Handling: Handling errors in scheduled tasks can be more complex compared to event-driven triggers. Ensuring retries and managing failures requires careful planning.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Monitoring and Logging Challenges: While Azure provides monitoring tools, tracking and debugging scheduled executions can be less straightforward compared to interactive triggers like HTTP requests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Potential for Overlapping Executions: If a function takes longer to execute than the interval defined in the Timer Trigger, it might lead to overlapping executions, causing conflicts or resource contention.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Conclusion and Next Steps
&lt;/h3&gt;

&lt;p&gt;Congratulations! You've successfully created and deployed your first Timer Trigger Azure Function using .NET 9 in Visual Studio. This serverless approach allows you to automate routine tasks efficiently, ensuring reliability and scalability without the overhead of managing infrastructure.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Takeaways:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Azure Functions provide a scalable, serverless platform for executing code in response to various triggers.
-- Timer Triggers are ideal for scheduled tasks, automating processes like backups, notifications, and maintenance.
.NET 9 offers robust support for building Azure Functions, enabling developers to leverage modern language features.&lt;/li&gt;
&lt;li&gt;Security Best Practices: Always store sensitive information securely using environment variables or Azure Key Vault.&lt;/li&gt;
&lt;li&gt;Be Aware of Limitations: Understand the potential drawbacks of Timer Triggers and implement strategies to mitigate them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you found this guide helpful, make sure to check out the accompanying &lt;a href="https://youtu.be/B-I-A1g1GlE" rel="noopener noreferrer"&gt;YouTube video tutorial&lt;/a&gt; where I walk you through the process visually. Don’t forget to subscribe to my channel for more Azure and .NET tutorials!&lt;/p&gt;

&lt;p&gt;Feel free to leave your questions, comments, or suggestions below. Happy coding!&lt;/p&gt;

</description>
      <category>azurefunctions</category>
      <category>azure</category>
      <category>dotnet</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Building Scalable Applications with Azure Functions: Best Practices and Tips</title>
      <dc:creator>CodeStreet</dc:creator>
      <pubDate>Sat, 09 Nov 2024 14:11:58 +0000</pubDate>
      <link>https://forem.com/codestreet/building-scalable-applications-with-azure-functions-best-practices-and-tips-1bgf</link>
      <guid>https://forem.com/codestreet/building-scalable-applications-with-azure-functions-best-practices-and-tips-1bgf</guid>
      <description>&lt;p&gt;In today’s fast-paced digital landscape, building scalable applications is essential to accommodate growing user bases, handle increased workloads, and ensure seamless performance. Azure Functions, a serverless computing service provided by Microsoft Azure, offers a robust platform for developing scalable applications without the overhead of managing infrastructure. &lt;/p&gt;

&lt;p&gt;Whether you’re an experienced developer or a newbie, understanding how to leverage Azure Functions effectively can significantly enhance your application's scalability and performance. In this blog post, we’ll delve into the best practices and tips for building scalable applications with Azure Functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to Azure Functions
&lt;/h2&gt;

&lt;p&gt;Azure Functions is a serverless compute service that enables you to run event-driven code without having to explicitly provision or manage infrastructure. &lt;/p&gt;

&lt;p&gt;With Azure Functions, you can execute code in response to various triggers, such as HTTP requests, timers, or messages from other Azure services like Azure Blob Storage and Azure Service Bus. &lt;/p&gt;

&lt;p&gt;This serverless approach allows developers to focus on writing code while Azure handles the scaling, patching, and maintenance of the underlying infrastructure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of Using Azure Functions for Scalability
&lt;/h2&gt;

&lt;p&gt;Before diving into best practices, it’s essential to understand why Azure Functions is an excellent choice for building scalable applications:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automatic Scaling:&lt;/strong&gt; Azure Functions can automatically scale out based on demand. Whether you have one request or thousands per second, Azure Functions can handle the load seamlessly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cost-Effective:&lt;/strong&gt; You pay only for the compute resources you consume, making it a cost-efficient solution, especially for applications with variable or unpredictable workloads.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Flexibility:&lt;/strong&gt; Supports multiple programming languages, including C#, JavaScript, Python, and more, allowing developers to work in their preferred language.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rapid Development:&lt;/strong&gt; The serverless model accelerates development cycles by reducing the time spent on infrastructure management.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With these advantages in mind, let’s explore how to harness Azure Functions to build scalable applications effectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices for Building Scalable Applications
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Choose the Right Trigger&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Azure Functions can be triggered by various events, such as HTTP requests, timers, queues, and more. Selecting the appropriate trigger based on your application's requirements is crucial for scalability.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;HTTP Triggers:&lt;/strong&gt; Ideal for APIs or webhooks. They can handle a high volume of requests and are suitable for front-end applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Timer Triggers:&lt;/strong&gt; Useful for scheduled tasks like batch processing or cleanup jobs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Queue Triggers:&lt;/strong&gt; Perfect for decoupling components and handling background processing, ensuring tasks are processed asynchronously.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Event Grid Triggers:&lt;/strong&gt; Suitable for event-driven architectures, allowing functions to respond to events from Azure services or custom sources.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: Assess the nature of the tasks your application performs and choose triggers that align with those tasks to optimize performance and scalability.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;2. Optimize Function Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Efficient code is the backbone of scalable applications. Optimizing your function code ensures that each execution consumes minimal resources and completes quickly.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Keep Functions Lightweight&lt;/strong&gt;: Functions should perform a single, focused task. Avoid adding unnecessary logic that can slow down execution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Asynchronous Programming:&lt;/strong&gt; Utilize asynchronous programming models to handle I/O-bound operations efficiently, allowing functions to process multiple tasks concurrently.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Minimize External Calls:&lt;/strong&gt; Reduce dependencies on external services or APIs, which can introduce latency. If necessary, implement retries and exponential backoff strategies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Efficient Data Processing:&lt;/strong&gt; Handle data processing in-memory when possible and avoid excessive data transformations or manipulations.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[FunctionName("ProcessQueueMessage")]
public async Task Run([QueueTrigger("myqueue-items")] string myQueueItem, ILogger log)
{
    log.LogInformation($"Processing message: {myQueueItem}");
    // Perform asynchronous operations
    await SomeAsyncOperation(myQueueItem);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Manage Dependencies Wisely&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dependencies, such as libraries and external packages, can impact the startup time and performance of your functions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Minimize Dependencies:&lt;/strong&gt; Only include necessary libraries to reduce the function’s footprint and improve cold start times.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use Managed Dependencies:&lt;/strong&gt; Leverage Azure’s managed dependencies and extensions where possible to avoid adding unnecessary packages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Optimize Package Sizes:&lt;/strong&gt; Choose lightweight libraries and avoid bloated packages that can increase the deployment size and slow down function execution.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: Regularly review and update your dependencies to benefit from performance improvements and security patches.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;4. Implement Proper Scaling Strategies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Azure Functions provide built-in scaling capabilities, but implementing additional strategies can enhance scalability further.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Understand Scaling Limits:&lt;/strong&gt; Be aware of Azure’s scaling limits and plan your application architecture accordingly. For example, the Consumption Plan has certain limits on execution time and resources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use Premium or Dedicated Plans for High Demands:&lt;/strong&gt; If your application requires higher performance or needs to run continuously, consider using Premium or Dedicated (App Service) plans which offer better scaling options.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Partition Workloads:&lt;/strong&gt; Distribute workloads across multiple functions or queues to prevent bottlenecks and ensure even load distribution.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: Monitor your application’s performance and adjust your scaling strategy as needed to accommodate changing demands.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;5. Use Durable Functions for Orchestration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Durable Functions extend Azure Functions by enabling stateful orchestrations. They are ideal for managing complex workflows and long-running processes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Chaining Functions:&lt;/strong&gt; Execute functions sequentially, passing data from one to the next.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Fan-Out/Fan-In:&lt;/strong&gt; Run multiple functions in parallel and aggregate the results.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Human Interaction:&lt;/strong&gt; Incorporate manual approvals or user inputs into automated workflows.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Error Handling and Retries:&lt;/strong&gt; Implement robust error handling and retry mechanisms to ensure reliability.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[FunctionName("OrchestratorFunction")]
public async Task OrchestratorFunction([OrchestrationTrigger] IDurableOrchestrationContext context)
{
    var tasks = new List&amp;lt;Task&amp;lt;string&amp;gt;&amp;gt;();
    for (int i = 0; i &amp;lt; 5; i++)
    {
        tasks.Add(context.CallActivityAsync&amp;lt;string&amp;gt;("ActivityFunction", i));
    }
    await Task.WhenAll(tasks);
    var results = tasks.Select(t =&amp;gt; t.Result).ToList();
    // Process results
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Monitor and Analyze Performance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Continuous monitoring is essential to maintain and improve the scalability of your applications.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Azure Monitor:&lt;/strong&gt; Utilize Azure Monitor to track performance metrics, such as execution times, memory usage, and request rates.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Application Insights:&lt;/strong&gt; Integrate Application Insights for detailed telemetry, including request traces, dependency tracking, and exception logging.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Logging Best Practices:&lt;/strong&gt; Implement structured and meaningful logging to facilitate troubleshooting and performance analysis.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Tip: Set up alerts for critical metrics to proactively address performance issues before they impact users.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Secure Your Functions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Security is paramount, especially when scaling applications that handle sensitive data or critical operations.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Authentication and Authorization:&lt;/strong&gt; Implement proper authentication mechanisms, such as Azure Active Directory (AAD) or OAuth, to control access to your functions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Secure Secrets:&lt;/strong&gt; Store sensitive information, like connection strings and API keys, in Azure Key Vault or Azure App Configuration instead of hardcoding them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Network Security:&lt;/strong&gt; Use Virtual Networks (VNet) and service endpoints to restrict access to your functions and related resources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Input Validation:&lt;/strong&gt; Validate and sanitize all inputs to prevent common vulnerabilities like SQL injection and cross-site scripting (XSS).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[FunctionName("SecureHttpTrigger")]
public async Task&amp;lt;IActionResult&amp;gt; Run(
    [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
    ILogger log)
{
    // Validate inputs and authenticate user
    // Perform secure operations
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;8. Use Appropriate Storage Solutions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/codestreet/azure-storage-accounts-explained-the-ultimate-guide-to-real-world-applications-aac"&gt;Choosing the right storage solution&lt;/a&gt; is critical for the performance and scalability of your application.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Azure Blob Storage:&lt;/strong&gt; Ideal for storing large amounts of unstructured data, such as images, videos, and backups.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Azure Cosmos DB:&lt;/strong&gt; A globally distributed, multi-model database service that provides low latency and high availability for mission-critical applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Azure SQL Database:&lt;/strong&gt; A fully managed relational database service suitable for applications requiring structured data storage and complex queries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Azure Table Storage:&lt;/strong&gt; A NoSQL key-value store for rapid development using massive semi-structured datasets.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: Evaluate your data access patterns and choose a storage solution that aligns with your scalability and performance requirements.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;9. Manage Costs Effectively&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While Azure Functions can be cost-effective, unmanaged scaling can lead to unexpected expenses. Implement strategies to monitor and control costs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Set Budget Alerts:&lt;/strong&gt; Use Azure Cost Management to set budgets and receive alerts when spending approaches thresholds.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Optimize Resource Usage:&lt;/strong&gt; Ensure functions are optimized to complete tasks quickly, reducing the compute time and associated costs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Choose the Right Plan:&lt;/strong&gt; Select the appropriate hosting plan (Consumption, Premium, or Dedicated) based on your application's workload and budget constraints.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: Regularly review your usage patterns and adjust your scaling and resource allocation strategies to optimize costs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;10. Avoid Cold Starts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Cold starts occur when a function is invoked after being idle, leading to increased latency as the runtime initializes. Minimizing cold starts is crucial for maintaining responsiveness.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use Premium Plans:&lt;/strong&gt; Premium plans offer pre-warmed instances that are always ready to handle requests, reducing cold start occurrences.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**Keep Functions Warm: **Implement warm-up triggers or scheduled functions to periodically invoke functions and keep them active.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Optimize Initialization Code:&lt;/strong&gt; Reduce the complexity and size of the initialization code to speed up startup times.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: Analyze cold start patterns using monitoring tools and adjust your deployment strategy accordingly.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Building scalable applications is a critical aspect of modern software development, ensuring that your applications can handle growth, adapt to changing demands, and provide a seamless user experience. Azure Functions offers a powerful, serverless platform that simplifies the process of developing scalable, event-driven applications. &lt;/p&gt;

&lt;p&gt;By following the best practices and tips outlined in this blog post—ranging from optimizing function code and managing dependencies to implementing robust monitoring and security measures—you can harness the full potential of Azure Functions to build resilient and scalable applications.&lt;/p&gt;

&lt;p&gt;Enjoyed the insights? 👉 &lt;a href="https://dev.to/codestreet"&gt;Follow me&lt;/a&gt; for more tech wisdom and don't forget to subscribe to my &lt;a href="https://youtube.com/@CodeStreetYT" rel="noopener noreferrer"&gt;YouTube channel&lt;/a&gt;! 🎥🚀&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>azure</category>
      <category>azurefunctions</category>
      <category>beginners</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>Azure Storage Accounts Explained: The Ultimate Guide to Real-World Applications</title>
      <dc:creator>CodeStreet</dc:creator>
      <pubDate>Thu, 22 Aug 2024 06:20:31 +0000</pubDate>
      <link>https://forem.com/codestreet/azure-storage-accounts-explained-the-ultimate-guide-to-real-world-applications-aac</link>
      <guid>https://forem.com/codestreet/azure-storage-accounts-explained-the-ultimate-guide-to-real-world-applications-aac</guid>
      <description>&lt;p&gt;An Azure Storage Account is essentially a container that holds all your Azure Storage services, such as blobs, files, queues, tables, and disks. It provides a unique namespace for your data that can be accessed from anywhere in the world via HTTP or HTTPS.&lt;/p&gt;

&lt;p&gt;Azure Storage is a scalable and secure cloud storage solution from Microsoft Azure that offers various storage services for different types of data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Storage in Azure Storage Accounts
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Blob Storage:&lt;/strong&gt; Used to store unstructured data like images, videos, and documents. It's perfect for applications that need to handle large amounts of binary or text data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. File Storage:&lt;/strong&gt; Offers fully managed file shares in the cloud that can be accessed via the SMB protocol. Ideal for scenarios where applications require shared access to files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Queue Storage:&lt;/strong&gt; Provides a messaging queue that can be used to build distributed and decoupled applications. Useful in scenarios where different components of an application need to communicate asynchronously.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Table Storage:&lt;/strong&gt; A NoSQL key-value store that is optimized for fast data access. It's highly scalable and is often used for storing large amounts of structured data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Disk Storage:&lt;/strong&gt; Provides persistent, highly durable, and scalable disk storage for use with Azure Virtual Machines. Ideal for storing VM operating systems and data disks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-Life Applications of Azure Storage Accounts
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Data Backup and Recovery
&lt;/h3&gt;

&lt;p&gt;Azure Storage is widely used for data backup and disaster recovery. Companies can back up their on-premises data to Azure Blob Storage using tools like Azure Backup or third-party software. The data is stored securely and can be retrieved whenever necessary, ensuring business continuity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; A financial institution backs up its daily transaction logs to Azure Blob Storage. In the event of a system failure, the data can be quickly restored, minimizing downtime and data loss.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Hosting Static Websites
&lt;/h3&gt;

&lt;p&gt;Azure Blob Storage can host static websites, which include HTML, CSS, JavaScript, and other client-side assets. It's a cost-effective and scalable solution for hosting websites that do not require server-side processing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; A small business hosts its product catalog website on Azure Blob Storage. The website is accessed globally with minimal latency and no need for server management.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Media Content Delivery
&lt;/h3&gt;

&lt;p&gt;Azure Blob Storage is an excellent solution for storing and delivering large media files like videos, audio, and images. It can be integrated with Azure CDN (Content Delivery Network) to distribute content efficiently across the globe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; A streaming service stores its video library in Azure Blob Storage. The videos are streamed to users worldwide with the help of Azure CDN, providing a seamless viewing experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Big Data Analytics
&lt;/h3&gt;

&lt;p&gt;Azure Storage, combined with Azure Data Lake, allows organizations to store massive amounts of unstructured data and perform analytics using tools like Azure Databricks, HDInsight, or Synapse Analytics.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; A retail company collects transaction data from its stores and online channels. The data is stored in Azure Data Lake and processed using Azure Synapse Analytics to gain insights into customer behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. IoT Data Storage
&lt;/h3&gt;

&lt;p&gt;Azure Storage is used in IoT (Internet of Things) solutions to store large volumes of sensor data. The data can be stored in Blob Storage or Table Storage and then processed or analyzed as needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; A manufacturing company uses IoT sensors to monitor its production lines. The sensor data is stored in Azure Table Storage, where it is analyzed to predict equipment failures and optimize maintenance schedules.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Enterprise File Sharing
&lt;/h3&gt;

&lt;p&gt;Azure File Storage provides cloud-based file shares that can be accessed from anywhere. This is particularly useful for enterprises that need to provide shared access to files across different locations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; A global law firm uses Azure File Storage to share case files between its offices in different countries. The files are securely accessed and updated by legal teams working in different time zones.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Messaging and Workflow Management
&lt;/h3&gt;

&lt;p&gt;Azure Queue Storage is often used in scenarios where different components of an application need to communicate asynchronously. It helps in managing workflows and ensuring reliable message delivery between services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; An e-commerce platform uses Azure Queue Storage to manage order processing. When an order is placed, a message is added to the queue, and the order processing service picks up the message to fulfill the order.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Persistent Storage for Virtual Machines
&lt;/h3&gt;

&lt;p&gt;Azure Disk Storage is used to provide persistent storage for Azure Virtual Machines (VMs). This storage is essential for running VMs that require reliable and high-performance storage for operating systems, applications, and data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; A healthcare organization runs a database server on an Azure VM with Azure Disk Storage. The disk provides the necessary performance and durability to handle sensitive patient data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up and Managing Azure Storage Accounts
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Creating a Storage Account
&lt;/h3&gt;

&lt;p&gt;Creating an Azure Storage Account is a straightforward process through the Azure Portal, Azure CLI, or Azure PowerShell. Here’s how you can do it via the Azure Portal:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Navigate to the Azure Portal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on "Create a resource" and search for "Storage account."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click "Create" and fill in the necessary details like subscription, &lt;br&gt;
resource group, storage account name, region, and performance tier.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Review and create the storage account.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Configuring Access and Security
&lt;/h3&gt;

&lt;p&gt;Azure Storage Accounts provide several options for securing access to your data:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Shared Access Signatures (SAS):&lt;/strong&gt; Allow limited access to resources in your storage account without exposing your account key.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Azure Active Directory (AAD):&lt;/strong&gt; Use AAD to authenticate access to blob and queue data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Network Security:&lt;/strong&gt; Use Virtual Network (VNet) rules and firewall rules to restrict access to your storage account.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Monitoring and Diagnostics
&lt;/h3&gt;

&lt;p&gt;Azure provides robust monitoring and diagnostics for storage accounts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Azure Monitor:&lt;/strong&gt; Use Azure Monitor to track metrics like availability, capacity, transactions, and latency.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Azure Storage Analytics:&lt;/strong&gt; Provides detailed logs and metrics for monitoring requests to your storage account.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Azure Storage Accounts offers versatile and scalable storage solutions for a wide range of applications, from simple data backup to complex big data analytics and IoT scenarios. By understanding the different types of storage available and how to use them effectively, you can build robust and efficient applications that leverage the full power of the cloud.&lt;/p&gt;

&lt;p&gt;Enjoyed the insights? 👉 &lt;a href="https://dev.to/codestreet"&gt;Follow me&lt;/a&gt; for more tech wisdom and don't forget to subscribe to my YouTube channel! 🎥🚀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/rajivcodelab" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;br&gt;
&lt;a href="https://youtube.com/@CodeStreetYT" rel="noopener noreferrer"&gt;YouTube&lt;/a&gt;&lt;/p&gt;

</description>
      <category>azure</category>
      <category>azurestorage</category>
      <category>dotnet</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Azure Functions Hosting Models: In-Process vs. Isolated Process - What's Best for Your Project?</title>
      <dc:creator>CodeStreet</dc:creator>
      <pubDate>Mon, 19 Aug 2024 01:58:57 +0000</pubDate>
      <link>https://forem.com/codestreet/azure-functions-hosting-models-in-process-vs-isolated-process-whats-best-for-your-project-23gg</link>
      <guid>https://forem.com/codestreet/azure-functions-hosting-models-in-process-vs-isolated-process-whats-best-for-your-project-23gg</guid>
      <description>&lt;p&gt;In this blog post, we'll explore the differences between the In-Process and Isolated Process hosting models in Azure Functions, along with their benefits and drawbacks. By the end, you'll have a clear understanding of which model to choose for your specific use case.&lt;/p&gt;

&lt;p&gt;Azure Functions is a popular serverless computing service that allows developers to run small pieces of code, known as functions, in the cloud.&lt;/p&gt;

&lt;p&gt;One of the key decisions you'll face when working with Azure Functions in .NET is choosing between the &lt;strong&gt;In-Process&lt;/strong&gt; and &lt;strong&gt;Isolated Process hosting&lt;/strong&gt; models. Both models have their own advantages and trade-offs, making it crucial to understand when to use each one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Hosting Models
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In-Process Hosting Model&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The In-Process hosting model is the traditional hosting model for Azure Functions. In this model, your function code runs in the same process as the Azure Functions runtime. This allows for direct access to the runtime's features, such as logging, configuration, and binding, with minimal overhead.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Isolated Process Hosting Model&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Isolated Process hosting model, introduced with .NET 5 and beyond, separates the function code from the Azure Functions runtime. Your code runs in a separate process, isolated from the runtime, allowing for greater flexibility and customization, especially for .NET applications that require specific .NET version support or advanced dependency management.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits and Drawbacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  In-Process Hosting Model
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Benefits&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Performance:&lt;/strong&gt; Running in the same process as the runtime results in lower latency and faster execution times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Simplicity:&lt;/strong&gt; The In-Process model offers easier access to built-in features like logging, dependency injection, and triggers without additional configuration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Mature Ecosystem:&lt;/strong&gt; Since this is the original hosting model, it has a more mature ecosystem with extensive documentation and community support.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Compatibility:&lt;/strong&gt; Direct access to Azure Functions runtime features like bindings, configuration, and triggers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Drawbacks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Tight Coupling:&lt;/strong&gt; Your function code is tightly coupled to the Azure Functions runtime, making it harder to upgrade or use different versions of .NET.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Limited Flexibility:&lt;/strong&gt; You have less control over the runtime environment, which might be restrictive if you have specific version or configuration needs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Limited .NET Versions:&lt;/strong&gt; Only supports .NET versions that are compatible with the runtime, which can be a limitation for some advanced applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Isolated Process Hosting Model
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Flexibility:&lt;/strong&gt; The Isolated Process model allows you to run your function code in a separate process, giving you full control over the environment and the ability to use any version of .NET.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Custom Middleware:&lt;/strong&gt; You can create and use custom middleware, allowing for advanced scenarios like custom authentication, logging, and error handling.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Modular Design:&lt;/strong&gt; The isolated nature of the process means your function code is less dependent on the Azure Functions runtime, making it easier to upgrade or change runtime versions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Future-Proofing:&lt;/strong&gt; As Azure Functions evolves, the Isolated Process model is more likely to receive new features and updates, making it a more future-proof choice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Drawbacks:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Performance Overhead:&lt;/strong&gt; Running in a separate process introduces some latency due to inter-process communication, which can result in slightly slower execution times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Complexity:&lt;/strong&gt; The Isolated Process model requires more configuration and setup, including managing your own dependency injection, logging, and bindings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Learning Curve:&lt;/strong&gt; For developers accustomed to the In-Process model, the Isolated Process model may have a steeper learning curve, especially when working with custom middleware and dependency injection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Limited Ecosystem:&lt;/strong&gt; While growing, the ecosystem and community support for the Isolated Process model are not as extensive as for the In-Process model.&lt;/p&gt;

&lt;h2&gt;
  
  
  When to Use In-Process vs. Isolated Process
&lt;/h2&gt;

&lt;h3&gt;
  
  
  When to Use In-Process:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Performance-Critical Applications: If your application requires the lowest possible latency and the highest performance, the In-Process model is often the better choice.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Simple, Rapid Development: For small to medium-sized applications where simplicity and ease of access to runtime features are key, the In-Process model is ideal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Legacy Applications: If you’re working with existing Azure Functions that were built using the In-Process model, and there’s no pressing need to switch, sticking with In-Process can save time and effort.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  When to Use Isolated Process:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Advanced Customization: If your application requires advanced customization, such as using custom middleware, or if you need to work with specific versions of .NET that the runtime doesn’t support, the Isolated Process model is the way to go.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Modern, Modular Applications: For new projects that aim to be future-proof, modular, and maintainable, the Isolated Process model offers greater flexibility and control.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Complex Enterprise Applications: In scenarios where different teams or services need to run different versions of .NET, or where there are strict requirements for isolation and security, the Isolated Process model provides the necessary separation and customization.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Choosing between the In-Process and Isolated Process hosting models in Azure Functions depends on your specific application needs. The In-Process model offers simplicity, performance, and ease of use, making it suitable for many scenarios. &lt;/p&gt;

&lt;p&gt;However, as applications grow in complexity, or if you require specific .NET version support and advanced customization, the Isolated Process model provides the flexibility and future-proofing needed for modern development.&lt;/p&gt;

</description>
      <category>azure</category>
      <category>azurefunctions</category>
      <category>dotnet</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Create Custom Middleware in Azure Functions: A Step-by-Step Guide with .NET 8</title>
      <dc:creator>CodeStreet</dc:creator>
      <pubDate>Sun, 18 Aug 2024 08:59:49 +0000</pubDate>
      <link>https://forem.com/codestreet/how-to-create-custom-middleware-in-azure-functions-a-step-by-step-guide-with-net-8-17gp</link>
      <guid>https://forem.com/codestreet/how-to-create-custom-middleware-in-azure-functions-a-step-by-step-guide-with-net-8-17gp</guid>
      <description>&lt;p&gt;This blog post will walk us through creating custom middleware in Azure Functions using .NET 8. We’ll build a custom exception handler middleware that catches unhandled exceptions, logs them, and returns a standardized error response. &lt;/p&gt;

&lt;p&gt;By the end of this guide, you'll clearly understand how to create and use middleware in your Azure Functions projects.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/8JJawhS5bhg"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Azure Functions has become a go-to solution for building serverless applications. One of the powerful features of Azure Functions in .NET 8 is the ability to use middleware in isolated process mode. &lt;/p&gt;

&lt;p&gt;Middleware allows you to inject logic into the request-processing pipeline, making it an essential tool for handling cross-cutting concerns like logging, authentication, and error handling.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Middleware?
&lt;/h2&gt;

&lt;p&gt;Middleware is a component that processes incoming requests before they reach your core application logic. Think of it as a filter or gatekeeper that can modify requests, enforce security policies, or handle errors. &lt;/p&gt;

&lt;p&gt;In the context of Azure Functions, middleware can be used to perform tasks like logging, validation, and exception handling across multiple functions without repeating code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Setting Up Your Azure Functions Project
&lt;/h2&gt;

&lt;p&gt;Before we dive into the middleware, let’s set up a basic Azure Functions project in .NET 8.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Setting Up Your Azure Functions Project
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Create a New Project:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Open Visual Studio 2022 and create a new Azure Functions project.&lt;/li&gt;
&lt;li&gt;Choose the “ &lt;strong&gt;.NET 8 Isolated Process&lt;/strong&gt; ” template.&lt;/li&gt;
&lt;li&gt;Name your project and click “ &lt;strong&gt;Create&lt;/strong&gt;.”&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Install Required Packages:
&lt;/h4&gt;

&lt;p&gt;Ensure that you have the necessary NuGet packages installed for Azure Functions and middleware. The Microsoft.Azure.Functions.Worker package should already be included in your project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Creating Custom Exception Handling Middleware
&lt;/h3&gt;

&lt;p&gt;Now that your project is set up, let’s create a custom middleware class that will handle exceptions globally.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using Microsoft.Azure.Functions.Worker;
using System.Text.Json;

public class CustomExceptionHandler : IFunctionsWorkerMiddleware
{
    public async Task Invoke(FunctionContext context, FunctionExecutionDelegate next)
    {
        try
        {
            await next(context);
            Console.WriteLine("No exception occurred");
        }
        catch (Exception ex)
        {
            var request = await context.GetHttpRequestDataAsync();
            var response = request!.CreateResponse();
            response.StatusCode = System.Net.HttpStatusCode.InternalServerError;

            var errorMessage = new { Message = "An unhandled exception occurred. Please try again later", Exception = ex.Message };
            string responseBody = JsonSerializer.Serialize(errorMessage);

            await response.WriteStringAsync(responseBody);

            Console.WriteLine("Exception occurred");
            context.GetInvocationResult().Value = response;
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Try-Catch Block:&lt;/strong&gt; The Invoke method wraps the next middleware or function execution in a try-catch block. If an exception occurs, it is caught and handled.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom Error Response:&lt;/strong&gt; When an exception is caught, the middleware creates an HTTP response with a 500 status code. It also serializes a custom error message, which includes a generic message and the exception details.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logging:&lt;/strong&gt; The middleware logs whether an exception occurred or not, making it easier to track issues during development.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 3: Registering the Middleware in the Function App
&lt;/h3&gt;

&lt;p&gt;With the middleware created, the next step is to register it in your Azure Functions app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Hosting;

var host = new HostBuilder()
    .ConfigureFunctionsWorkerDefaults(worker =&amp;gt;
    {
        worker.UseMiddleware&amp;lt;CustomExceptionHandler&amp;gt;();
    })
    .Build();

host.Run();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;UseMiddleware:&lt;/strong&gt; The UseMiddleware method registers your custom middleware in the function app’s pipeline. This ensures that the middleware is invoked for every incoming request, before any function logic is executed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 4: Modify/Create Azure Function to Test the Middleware
&lt;/h3&gt;

&lt;p&gt;Let’s create a simple Azure Function that will deliberately cause an exception, allowing us to test our middleware.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Functions.Worker.Http;

[Function("Custom-Middleware")]
public IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequest req)
{
    _logger.LogInformation("C# HTTP trigger function processed a request.");

    int.TryParse(req.Query["number"], out int number);
    int res = 10 / number; // This will throw a DivideByZeroException if 'number' is 0

    return new OkObjectResult(new { result = res });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DivideByZeroException:&lt;/strong&gt; This function parses a number from the query string and divides 10 by that number. If the number is 0, a DivideByZeroException will be thrown, which our middleware will catch and handle.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 5: Running and Testing the Function
&lt;/h3&gt;

&lt;p&gt;Now that everything is set up, let’s run the function app and test it by triggering the function with different inputs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Valid Input:&lt;/strong&gt; If you pass a non-zero number, the function will return the result of the division.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Invalid Input (Zero):&lt;/strong&gt; If you pass 0, the function will throw an exception. The middleware will catch this exception, log it, and return a standardized error message to the client.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s what the error response might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "Message": "An unhandled exception occurred. Please try again later",
    "Exception": "Attempted to divide by zero."
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In this post, we’ve explored how to create and use custom middleware in Azure Functions using .NET 8 in isolated process mode. We walked through a practical example of an exception-handling middleware that catches unhandled exceptions and returns a standardized error response.&lt;/p&gt;

&lt;p&gt;If you found this guide helpful, consider sharing it with others and stay tuned for more Azure Functions tutorials!&lt;/p&gt;

</description>
      <category>azurefunctions</category>
      <category>azure</category>
      <category>dotnetcore</category>
      <category>serverless</category>
    </item>
  </channel>
</rss>
