⚠️ This blog post was created with the help of AI tools. Yes, I used a bit of magic from language models to organize my thoughts and automate the boring parts, but the geeky fun and the 🤖 in C# are 100% mine.

elbruno.Extensions.AI.Claude just landed on NuGet with dual authentication support, polished samples, and drop-in compatibility with Microsoft.Extensions.AI. Here’s a fast tour so you can start shipping Azure+Claude powered experiences immediately.

Highlights

  • Works with Claude Sonnet 4.5, Haiku 4.5, and Opus 4.1 hosted in Azure AI Foundry
  • Implements IChatClient, so it plugs directly into any Microsoft.Extensions.AI pipeline
  • Supports both DefaultAzureCredential (managed identity, dev tools, service principals) and API key auth paths
  • Samples for classic responses + streaming straight from the repo

Install Once

dotnet add package elbruno.Extensions.AI.Claude --version 0.1.0-preview.2

Sample 1 Default Azure Credentials

Keep secrets in Azure and let DefaultAzureCredential figure out the right token.

using Azure.Identity;
using elbruno.Extensions.AI.Claude;
using Microsoft.Extensions.AI;

var endpoint = new Uri(Environment.GetEnvironmentVariable("AZURE_CLAUDE_ENDPOINT")!);
var deployment = Environment.GetEnvironmentVariable("AZURE_CLAUDE_MODEL") ?? "claude-haiku-4-5";

var client = new AzureClaudeClient(endpoint, deployment, new DefaultAzureCredential());

var reply = await client.CompleteAsync(new List<ChatMessage>
{
    new(ChatRole.System, "Respond in bullet points."),
    new(ChatRole.User, "Give me two shipping ideas for a Claude-powered agent."),
});

Console.WriteLine(reply.Message.Text);

Minimal config:

set AZURE_CLAUDE_ENDPOINT=https://<resource>.services.ai.azure.com/anthropic/v1/messages
set AZURE_CLAUDE_MODEL=claude-haiku-4-5

Sample 2 API Key Mode

Need to run outside Azure or keep things lab-simple? Use the API key constructor.

using elbruno.Extensions.AI.Claude;
using Microsoft.Extensions.AI;

var configuration = new ConfigurationBuilder()
    .AddUserSecrets<Program>()
    .AddEnvironmentVariables()
    .Build();

var endpoint = new Uri(configuration["AZURE_CLAUDE_ENDPOINT"]!);
var deployment = configuration["AZURE_CLAUDE_MODEL"] ?? "claude-sonnet-4-5";
var apiKey = configuration["AZURE_CLAUDE_APIKEY"]!; // store in Key Vault or user secrets

var client = new AzureClaudeClient(endpoint, deployment, apiKey);

await foreach (var chunk in client.CompleteStreamingAsync(new List<ChatMessage>
{
    new(ChatRole.System, "Keep outputs under 30 words."),
    new(ChatRole.User, "Pitch a 1-line elevator speech for this package."),
}))
{
    if (!string.IsNullOrEmpty(chunk.Text))
    {
        Console.Write(chunk.Text);
    }
}

Load secrets in dev (user secrets shown; swap for Key Vault in prod):

dotnet user-secrets init
dotnet user-secrets set AZURE_CLAUDE_ENDPOINT "https://<resource>.services.ai.azure.com/anthropic/v1/messages"
dotnet user-secrets set AZURE_CLAUDE_MODEL "claude-sonnet-4-5"
dotnet user-secrets set AZURE_CLAUDE_APIKEY "<api-key>"

Try the Repo Samples

git clone https://github.com/elbruno/elbruno-extensions-ai-claude.git
cd elbruno-extensions-ai-claude

dotnet run --project samples/elbruno.Extensions.AI.Claude.Samples                # DefaultAzureCredential flow
dotnet run --project samples/elbruno.Extensions.AI.Claude.ApiKeySample          # API key flow

Tag @elbruno if you wire this into an agentic workflow. I’d love to see what you build!”

Happy coding!

Greetings

El Bruno

More posts in my blog ElBruno.com.

More info in https://beacons.ai/elbruno


2 responses to “💭Claude in Azure, the .NET Way: elbruno.Extensions.AI.Claude v0.1.0-preview.2”

  1. […] 💭Claude in Azure, the .NET Way: elbruno.Extensions.AI.Claude v0.1.0-preview.2 (Bruno Capuano) […]

    Like

  2. […] an AzureClaudeClient (supports IChatClient, DefaultAzureCredential, API keys, streaming, etc.)elbruno.comelbruno.com. This is a temporary client to use Claude in .NET until official SDK integration […]

    Like

Leave a comment

Discover more from El Bruno

Subscribe now to keep reading and get access to the full archive.

Continue reading