Microsoft Agent Framework for .NET (part 2): How to use IChatClient with Azure Foundry and Ollama in .NET
IChatClient is the core of Microsoft Agent Framework. Let’s see how to configure it with Azure Foundry and Ollama.
Recent content on Code4IT
IChatClient is the core of Microsoft Agent Framework. Let’s see how to configure it with Azure Foundry and Ollama.
Learn how to use required members in C# to enforce complete object initialization at compile time and avoid half-configured models. And beware of the SetsRequiredMembers attribute, which can be dangerous if misused.
Microsoft Agent Framework is Microsoft’s production-oriented framework for building AI agents and multi-agent workflows in .NET and Python. Let’s see how it works, why Microsoft created it, and when to choose it over Semantic Kernel, LangChain, or AutoGen.
Snapshot Tests are an uncommon type of test that focuses on checking that no regressions were introduced after a code refactoring. Let’s learn how they work and how to use the Verify NuGet library to add them to your test suite.
A quick comparison of data types, classes, objects, records, and interfaces in C# and Python, designed for .NET developers learning Python.
As you may know, you can send Slack notifications using Azure Logic Apps. Yes, there is a built-in connector; but, frankly, using the Slack API gives you better results.
Handling dates is never trivial. And handling JSON serialization and deserialization of dates is even more difficult. And, even worse, how can you convert a value as DateTime, DateTimeOffset, DateOnly and TimeOnly?
Are you a .NET developer looking to learn Python? Me too! In this article we draw parallels between Python and .NET basic concepts, exploring virtual environments, package management with pip, and the execution lifecycle.
The words ReadOnly, Immutable, Frozen seem similar but have distinct meanings in .NET. Here’s a detailed comparison of Readonly, Immutable, and Frozen collections in C#, with benchmarks and typical use cases.
Should every asynchronous method name end with Async? Does it bring more benefits or more downsides? Let’s reason about this habit, which is common among C# developers.
In C#, Attributes are a handy mechanism to attach metadata to your classes, methods, properties, etc. In this article, we will see how to create custom Attributes and access them at runtime using Reflection.
Learn the differences between metrics, logs, and traces - the three pillars of Observability in distributed systems - and how to use them effectively.
It’s easy to say ‘Public Speaking’. But there are lots of factors that you can (and should) consider when talking to an international audience, especially if English is not your first language.
The Testing Pyramid focuses on Unit Tests; the Testing Diamond focuses on Integration Tests; and what about the Testing Vial?
Dates used to be difficult to test. But with TimeProvider and FakeTimeProvider, everything becomes possible!
Why buy a whole tool when you can build your own? Learn how the Type system works in .NET, and create your own minimal type analyser.
Software Architecture and Software Design are terms that look similar but refer to two totally different aspects of software. Let’s find the differences and their purposes.
Task.WhenAll and Task.WaitAll are common methods in C# that allow you to execute multiple Tasks. But… what happens when an exception is thrown?
The quality of a project can be measured by having a look at how the code is written. SonarQube can help you by running static code analysis and letting you spot the pain points. Let’s learn how to install and run it locally with Docker.
Operations may fail for transient reasons. How can you implement retry patterns? And how can a simple Jitter help you stabilize the system?
Let’s dive deep into the CallerMemberName attribute and explore its usage from multiple angles. We’ll see various methods of invoking it, shedding light on how it is defined at compile time.
Application Insights is a great tool for handling high volumes of logs. How can you configure an ASP.NET application to send logs to Azure Application Insights? What can I do to have Application Insights log my exceptions?
D2 is an open-source tool to design architectural layouts using a declarative syntax. It’s a textual format, which can also be stored under source control. Let’s see how it works, how you can install it, and some practical usage tips.
Applying custom attributes to C# classes and interfaces can be useful for several reasons. Let’s learn how to create Custom Attributes in C#, and let’s explore some practical usage!
Aren’t you tired of adding manual logs to your HTTP APIs to log HTTP requests and responses? By using a built-in middleware in ASP.NET, you will be able to centralize logs management and have a clear view of all the incoming HTTP requests.
Non-functional requirements matter, but we often forget to validate them. You can measure them using Fitness Functions.
Bogus is a library that generates realistic values for your data. When populating fake user names, instead of Foo and Bar, you can have John and Sarah. Let’s see two ways to define and reuse a Faker definition.
Seq is one of the best Log Sinks out there : it’s easy to install and configure, and can be added to an ASP.NET application with just a line of code.
When designing a software system, we naturally focus more on the happy flow. But we should carefully plan to handle errors that fall into three categories: Validation, Transient, and Fatal.
When working with Lists in C#, you are working on a data structure that implements both ICollection and IEnumerable. What’s the difference between ICollection and IEnumerable? Why should you care about them, especially when exposing functionalities to external clients?
WireMock.NET is a popular library used to simulate network communication through HTTP. But there is no simple way to integrate the generated in-memory server with an instance of IHttpClientFactory injected via constructor. Right? Wrong!
The C4 Model is one of the most famous ways to describe software architectures. Let’s see some practical usage with Strucutrizr.
With HashSet, you can get a list of different items in a performant way. What if you need a custom way to define when two objects are equal?
In Postman, you can define scripts to be executed before the beginning of a request. Can we use them to work with endpoints using Cookie Authentication?
When describing a web service, people often use the wrong terms. Are you really creating a REST API, or is it some sort of pseudo-REST?
The sealed keyword is often ignored, yet it can be important to define a proper class design.
You don’t need a physical database to experiment with ORMs. You can use an in-memory DB and seed the database with realistic data generated with Bogus.
How is your project structured? What are the driving forces? If you don’t know how to express this info, you should try the Arc42 template to create a strong foundation for your documentation.
When composing the path to a folder or file location, the Path class can come in handy. Path.Join and Path.Combine may look similar, but their behavior differ in an unexpected way.
Can your system withstand heavy loads? You can answer this question by running Load Tests. Maybe, using K6 as a free tool.
Non-functional requirements. How can you ensure you meet them? Let’s understand SLO, SLA, and SLI, and how they affect your SDLC.
Average teams aim at 100% Code Coverage just to reach the number. Great teams don’t. Why?
Same object, different string representations. How do we achieve it in a standardised way?
You have a collection of items. You want to retrieve N elements randomly. Which alternatives do we have?
Caching helps your applications be more performant. However, depending on the cache size, you’ll need to sacrifice some items to make space for others. Let’s see some strategies.
A simple way to improve efficiency is knowing your IDE shortcuts. Let’s learn how to create custom ones to generate code automatically.
ObservableCollection<T> is a data type that allows you to react when an item is added or removed from the collection. Let’s learn more!
Now you can’t run your application because another process already uses the port. How can you find that process? How to kill it?
When designing a system’s architecture, you have many choices to make. How can you track them? ADRs are formal documents to track the reasons behind your decisions, giving context and info about the consequences of each choice.