.NET Aspire and GenAI Develop Distributed Architectures — 2025

Mehmet Ozkaya
6 min readMar 3, 2025

--

I have just published a new course — .NET Aspire and GenAI Develop Distributed Architectures 2025

Get Udemy Course with limited discounted coupon — .NET Aspire and GenAI Develop Distributed Architectures 2025

We will Develop AI-Powered Distributed Architectures using .NET Aspire and GenAI to develop EShop Catalog and Basket microservices integrate with Backing services including PostgreSQL, Redis, RabbitMQ, Keycloak, Ollama and Semantic Kernel to Create Intelligent E-Shop Solutions.

Let’s take a high-level look at the journey throughout the course:

Cloud-Native Distributed Architecture

We’ll begin by discussing the core principles of cloud-native applications — what they are, why they matter, and how to design microservices that align with the Twelve-Factor App methodology.

.NET Aspire Framework

Next, we’ll discover how .NET Aspire simplifies building distributed, enterprise-ready applications by providing a clean project structure and built-in solutions for configuration, logging, and more.

E-Shop Microservices

We’ll then start building our E-Shop system, developing multiple microservices:

  • Catalog Service with PostgreSQL and RabbitMQ
  • Basket Service with Redis, consuming the Catalog’s events

Deploy to Azure Container Apps

We’ll containerize and deploy these microservices using .NET Aspire and deploy to Azure Container Apps, We’ll use the azd up and azd down commands to simplify provisioning and teardown.

.NET GenAI Development

We’ll explore the Microsoft.Extensions.AI package and the Semantic Kernel library to integrate advanced AI features into our EShop application.

Use Cases:

  • Customer Support Q&A using Ollama (Llama or Phi models)
  • Product Semantic Search leveraging a vector database
  • Embeddings, and a Retrieval-Augmented Generation (RAG) flow.

The E-Shop Distributed Architecture

Our course project will be The E-Shop Distributed Architecture:

Phase 1 — Setting Up Core Microservices

Our first step is to create two core microservices — Catalog and Basket

Catalog Microservice:

  • Store product data in PostgreSQL relational database
  • Implement EF Core migrations and CRUD operations (Create, Read, Update, Delete) for products.
  • Exposes HTTP endpoints for product listings, details, and price updates.

Basket Microservice:

  • We’ll use Redis Distributed Cache to store customer basket data.
  • Endpoints to create/delete a basket and add/remove items, storing the basket in JSON format.
  • This approach is fast and scalable, perfect for shopping cart data.

Phase 2 — Microservices Communications with .NET Aspire

With the core services created, we introduce .NET Aspire for service discovery and orchestration:

Synchronous Communication

Catalog & Basket use .NET Aspire to discover each other’s endpoints without hardcoding URLs.

For example, when adding an item to the basket, the Basket service calls Catalog to fetch the latest product price Synchronously.

Asynchronous Messaging

RabbitMQ handles the publish-subscribe pattern for events like ProductPriceChanged.

When Catalog updates a product’s price, it publishes ProductPriceChanged integration event to RabbitMQ and the Basket will consume the ProductPriceChanged integration event from RabbitMQ and stay synchronized with the Catalog whenever a user adds an item to their basket.

This setup showcases event-driven architecture in action, as each service communicates asynchronously via RabbitMQ to stay in sync with minimal coupling.

Phase 3 — Authentication & Security

Next, we secure our microservices with Keycloak: Secure basket endpoints with Keycloak using JWT Bearer token

Keycloak Definitions

  • Create a realm, client, and at least one test user.
  • Configure OpenID Connect for token-based auth.

Basket Service Security

  • Protect basket endpoints (e.g., adding items to basket) with JWT Bearer tokens.
  • Validate tokens issued by Keycloak, ensuring only authenticated users can modify their baskets.

By using Keycloak and OpenID Connect, we achieve a standardized approach to authentication across all microservices.

Phase 4 — Frontend Development

Our e-commerce solution needs a user interface:

Blazor WebApp

In the frontend project, we build Blazor application and Razor pages that show product listings and basket functionality. Use HttpClient to call Catalog and Basket services (leveraging Aspire service discovery).

  • Products Page Displays product data from Catalog.
  • Allows adding items to the basket, seamlessly updating the UI.

With Blazor, we get a modern, interactive front end that’s well-integrated with .NET.

Phase 5 — Deployment to Azure Container Apps

Once our microservices are working locally, we’ll deploy to Azure:

Containerization

  • .NET Aspire can containerize each microservice.
  • We push them to Azure Container Registry or let Azure handle building images.

azd up / azd down

  • Use the Azure Developer CLI commands (azd) to deploy or tear down the environment.
  • This process provisions Azure Container Apps, sets up networking, and links secrets or environment variables.

This deployment step ensures we have a scalable solution running in the cloud.

Phase 6 — Adding GenAI Features

Finally, we add cutting-edge GenAI capabilities into EShop Application to enhance customer experiences:

We’ll use the Microsoft.Extensions.AI package with the Semantic Kernel library to integrate advanced generative AI capabilities directly into our .NET microservices.

Ollama for Local LLM Inference

  • Integrate models like Llama3 or Phi3.
  • Provide Customer Support Q&A chatbot: Users can ask product-related questions, and the AI responds with relevant info from your product catalog.

Vector Database (in-memory or Qdrant)

  • Store embeddings for semantic search.
  • Implement a RAG (Retrieval-Augmented Generation) flow: Users get AI-powered product recommendations or search results based on similarity queries.

Semantic Product Search

Instead of relying on simple keyword matching, we’ll generate embeddings for product descriptions using Ollama’s all-minilm model, store them in a Vector Database, and query them via cosine similarity.
This approach significantly enhances search relevance, delivering better user experiences.

Blazor Frontend for AI

Build pages that let users interact with the Q&A or advanced semantic product searches. Combine LLM generation with live EShop data for highly relevant and context-aware results.

This allows us to integrate AI features without always relying on external cloud-based AI services, giving you greater control over data privacy and cost optimization.

Why Learn AI-Powered Distributed Architectures?

There is growing demand for scalable, intelligent applications that can adapt to ever-changing business needs. Modern applications aren’t just about serving static data; they’re event-driven, cloud-native, and responsive to real-time updates.
Additionally, AI is transforming how we interact with software. Whether it’s chatbots, personalization, or semantic search, Generative AI has opened the doors to novel user experiences. Combining the power of microservices with AI ensures that your applications remain resilient, easy to scale, and deeply intelligent.

Get Udemy Course with limited discounted coupon — .NET Aspire and GenAI Develop Distributed Architectures 2025

You will gain real-world experience, you will have a solid understanding of the .NET Aspire and .NET Generative AI to design, develop and deploy ai-powered distributed enterprise applications.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Mehmet Ozkaya
Mehmet Ozkaya

Written by Mehmet Ozkaya

Software Architect | Udemy Instructor | AWS Community Builder | Cloud-Native and Serverless Event-driven Microservices https://github.com/mehmetozkaya

No responses yet

Write a response