Aspiring .NET with Azure OpenAI and Ollama

Chris Ayers

Chris Ayers

Senior Risk SRE
Azure CXP AzRel
Microsoft

BlueSky: @chris-ayers.com
LinkedIn: - chris-l-ayers
Blog: https://chris-ayers.com/
GitHub: Codebytes
Mastodon: @Chrisayers@hachyderm.io
Twitter: @Chris_L_Ayers

Agenda

  • Why .NET Aspire?
  • .NET Aspire Integrations
  • Consuming Resources
  • Local Azure Development
  • Deploying to Azure
  • What's New in 9.3
  • Demos
  • Q&A

.NET Aspire is designed to improve the
experience of building .NET cloud-native apps

Why .NET Aspire

Orchestration and Fundamentals

  • Service Management
  • Configuration
  • Service Discovery
  • Health & Telemetry

Integrations

  • Azure Services
  • Local Development
  • Multi-Platform
  • Community Ecosystem

Tooling

  • IDE Integration
  • Dashboard
  • AppHost Project
  • CLI Support

Service Defaults & Features

  • Security Defaults
    • Azure AD authentication
    • Secure secrets management
  • Resilience & Scalability
    • Automatic retry policies
    • Circuit breakers for failure protection
  • Custom Commands
    • Workflow automation
    • Database migrations, data seeding
    • Development environment reset
  • Launch Profiles
    • Multiple environments (local, cloud, test)
    • Environment variable configuration

.NET Aspire Dashboard

fit

Dashboard Features

  • Real-time Monitoring
  • Interactive Debugging
  • Resource Management
  • Secret Management
  • Copilot AI Debugging

Service Discovery and Configuration

  • Automatic Configuration: AppHost passes settings to services
  • Implicit Discovery: Services reference only what they need
  • Named Endpoints: Multiple endpoints per service
  • Environment Variables: Structured configuration strings

Testing in .NET Aspire

  • Integration Testing: Test multiple components together
  • Container Testing: Test with containerized services
  • Emulator Support: Use local emulators for cloud services
  • End-to-End Testing: Test full application workflows

.NET Aspire Integrations

Integrations

The Two Sides to .NET Aspire Integrations

Hosting Integrations

  • Provision and manage resources
  • Automate infrastructure setup
  • Cloud-native functionality
  • Integrated logging and monitoring
  • Authentication and authorization
  • Configuration management

Client Integrations

  • Configure service connections
  • Consume hosted services
  • Service discovery
  • Service defaults
  • Integrated logging and monitoring

Official Integrations

Cloud-Agnostic

  • Databases: PostgreSQL, MySQL, MongoDB, SQL Server
  • Messaging: Kafka, RabbitMQ, NATS
  • AI & Observability: Ollama, Semantic Kernel, OpenTelemetry

Cloud-Specific

  • Azure Services: OpenAI, Cosmos DB, SQL, Redis, Key Vault, App Service, ACR, App Config
  • AWS Support: Via Hosting.AWS package

Community Toolkit Integrations

Multi-Language Support

  • JavaScript: Bun, Deno
  • Systems Programming: Go, Rust
  • Enterprise: Java/Spring
  • Extensions: Node.js, SQL, MongoDB, Redis

Additional Services

  • AI & Search: Ollama, Meilisearch
  • Data: SQLite, Data API Builder
  • Web: Azure Static Web Apps emulator
  • Customization: Advanced configurations

Local to Cloud Integrations

Provider Local Development Cloud Production
OpenAI Ollama, Foundry local, LM Studio Azure OpenAI Service, Azure AI Foundry
Models Llama 3, Phi-4, Qwen GPT-4o, GPT-4o-mini
Embeddings Local embedding models text-embedding-3-small/large
Vector DB Qdrant, Chroma, pgvector Azure AI Search, Cosmos DB
Image Gen DALL-E via API DALL-E 3 via Azure

Resource Management & Development

Local to Cloud

  • Zero-Friction: Seamless local to cloud transitions
  • Emulator Support: Local containers for speed
  • Hybrid Development: Mix local/cloud resources
  • Environment Control: Component-level targeting

Configuration

  • Simple Connections: Easy Azure and third-party integration
  • Auto Configuration: Service discovery and management
  • Secret Handling: Secure credential management
  • Minimal Code: Connect with just a few lines

Microsoft.Extensions.AI

  • Unified API: Common interface for AI providers
  • Pipeline Architecture: Chain components efficiently
  • DI Integration: Works with .NET service container
  • Provider-Agnostic: Single interface, multiple backends
  • Local Development: Connect to Ollama, LM Studio
  • Cloud Ready: Same code for Azure OpenAI
  • Transport Options: HTTP, gRPC, direct calls
  • Performance: Auto-batching and throttling

AI Local-to-Cloud Transitions

// Local development with Ollama
builder.AddOllama("ollama")
    .WithModel("llama3");

// Add client to use the model
 builder.AddOllamaApiClient();
// Single line change for production
builder.AddAzureOpenAI("ai");

// Same client code works unchanged
builder.AddAzureOpenAIClient();
  • Same Application Code: Business logic remains identical
  • Configuration-Based Switching: Environment determines provider
  • Consistent Capabilities: Text completion, embeddings, image generation
  • Resource Integration: Works with .NET Aspire's resource model
  • Example: Use Ollama locally → Azure OpenAI in production

Azure Deployment & Authentication

Deployment Targets

  • Azure App Service
  • Azure Container Apps
  • Kubernetes

New in 9.3

  • Per-resource publishing
  • Resource-to-compute mapping
  • Improved CI/CD parameters

Authentication

  • Credential Providers
  • Key Vault Integration
  • Secure Access

Developer CLI

  • Native .NET Aspire support
  • Auto-detects app structure
  • Environment variable mapping

Kubernetes Deployment (9.3)

  • Kubernetes Environment Support
    • AddKubernetesEnvironment("env")
    • Configure global manifest settings
    • Per-resource customization
    • Strong typing for deployment definitions
builder.AddKubernetesEnvironment("env")
       .WithProperties(env =>
       {
           env.DefaultImagePullPolicy = "Always";
       });

builder.AddContainer("service", "nginx")
       .PublishAsKubernetesService(resource =>
       {
           resource.Deployment!.Spec.RevisionHistoryLimit = 5;
       });

Compute Environments (9.3)

  • Multiple Environment Support
    • Deploy to different targets
    • Mix container/non-container
    • Support hybrid deployments
    • Resource-specific control
// Support for explicit environment mapping
var k8s = builder.AddKubernetesEnvironment("k8s-env");
var compose = builder.AddDockerComposeEnvironment("docker-env");

builder.AddProject<Projects.Api>("api")
       .WithComputeEnvironment(compose);

builder.AddProject<Projects.Frontend>("frontend")
       .WithComputeEnvironment(k8s);

What's New in .NET Aspire 9.3

App Model

  • Easier container config
  • Custom URLs
  • YARP (Preview)
  • New lifecycle events
  • MySQL support
  • Hidden resources

Dashboard

  • Copilot AI debugging
  • Persistent filters
  • Traces view
  • Context menus
  • Friendly names
  • Metrics pause alert

Deployment

  • New publisher model
  • Azure App Service
  • Use existing ACR
  • Improved CI/CD params
  • Docker/K8s customization
  • Better telemetry & security

DEMOS

Questions ?

Resources

Follow Chris Ayers

BlueSky: @chris-ayers.com
LinkedIn: - chris-l-ayers
Blog: https://chris-ayers.com/
GitHub: Codebytes
Mastodon: @Chrisayers@hachyderm.io
Twitter: @Chris_L_Ayers

Feedback

Follow Chris Ayers

BlueSky: @chris-ayers.com
LinkedIn: - chris-l-ayers
Blog: https://chris-ayers.com/
GitHub: Codebytes
Mastodon: @Chrisayers@hachyderm.io
Twitter: @Chris_L_Ayers

Needed for mermaid, can be anywhere in file except frontmatter