AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore 1.0.0

Prefix Reserved
dotnet add package AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore --version 1.0.0
                    
NuGet\Install-Package AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore --version 1.0.0
                    
#r "nuget: AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore&version=1.0.0
                    
Install as a Cake Tool

Experimental work in progress, not yet released

AWS Lambda Powertools for .NET - Bedrock Agent Function Resolver for ASP.NET Core

Overview

This library provides ASP.NET Core integration for the AWS Lambda Powertools Bedrock Agent Function Resolver. It enables you to easily expose Bedrock Agent functions as endpoints in your ASP.NET Core applications using a simple, fluent API.

Features

  • Minimal API Integration: Register Bedrock Agent functions using familiar ASP.NET Core Minimal API patterns
  • AOT Compatibility: Full support for .NET 8 AOT compilation through source generation
  • Simple Function Registration: Register functions with a fluent API
  • Automatic Request Processing: Automatic parsing of Bedrock Agent requests and formatting of responses
  • Error Handling: Built-in error handling for Bedrock Agent function requests

Installation

Install the package via NuGet:

dotnet add package AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore

Basic Usage

Here's how to register Bedrock Agent functions in your ASP.NET Core application:

using AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore;

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

// Register individual functions
app.MapBedrockFunction("GetWeather", (string city, int month) =>
    $"Weather forecast for {city} in month {month}: Warm and sunny");

app.MapBedrockFunction("Calculate", (int x, int y) =>
    $"Result: {x + y}");

app.Run();

When Amazon Bedrock Agent sends a request to your application, the appropriate function will be invoked with the extracted parameters, and the response will be formatted correctly for the agent.

Using with Dependency Injection

Register the Bedrock resolver with dependency injection for more advanced scenarios:

using AWS.Lambda.Powertools.EventHandler.Resolvers;
using AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore;

var builder = WebApplication.CreateBuilder(args);

// Register the resolver and any other services
builder.Services.AddBedrockResolver();
builder.Services.AddSingleton<IWeatherService, WeatherService>();

var app = builder.Build();

// Register functions that use injected services
app.MapBedrockFunction("GetWeatherForecast", 
    (string city, IWeatherService weatherService) =>
        weatherService.GetForecast(city),
    "Gets weather forecast for a city");

app.Run();

Advanced Usage

Function Documentation

Add descriptions to your functions for better documentation:

app.MapBedrockFunction("GetWeather", 
    (string city, int month) => $"Weather forecast for {city} in month {month}: Warm and sunny",
    "Gets weather forecast for a specific city and month");

Working with Tool Classes

Use the MapBedrockToolClass<T>() method to register all functions from a class directly:

[BedrockFunctionType]
public class WeatherTools
{
    [BedrockFunctionTool(Name = "GetWeather", Description = "Gets weather forecast")]
    public static string GetWeather(string location, int days)
    {
        return $"Weather forecast for {location} for the next {days} days";
    }
}

// In Program.cs - directly register the tool class
app.MapBedrockToolClass<WeatherTools>();

How It Works

  1. When you call MapBedrockFunction, the function is registered with the resolver
  2. An HTTP endpoint is set up at the root path (/) to handle incoming Bedrock Agent requests
  3. When a request arrives, the library:
    • Deserializes the JSON payload
    • Extracts the function name and parameters
    • Invokes the matching function with the appropriate parameters
    • Serializes the result and returns it as a response

Requirements

  • .NET 8.0 or later
  • ASP.NET Core 8.0 or later
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 153 6/3/2025