Skip to content

Releases: aws-powertools/powertools-lambda-dotnet

v3.0.1

21 Oct 09:53
958d519

Choose a tag to compare

Summary

In this release we fix two bugs introduced in the last release.

  • AspectInjector dependency that was causing build issues in large projects
  • Tracing utility regression introduced when we added a new way to create subsegments.

📜 Announcement: You can now find our documentation on the official AWS documentation domain at [docs.aws.amazon.com/powertools/dotnet](https://docs.aws.amazon.com/powertools/dotnet/).

Thanks @nCubed for reporting the AspectInjector issue

Changes

🐛 Bug and hot fixes

  • fix: tracing subsegment when using fluent api Tracing.WithSubsegment (#1032) by @hjgraca
  • chore: downgrade AspectInjector to version 2.8.1 (#1040) by @hjgraca

📜 Documentation updates

  • chore(deps): bump squidfunk/mkdocs-material from 00f9276 to f5c556a in /docs (#1041) by @dependabot[bot]
  • chore: add aws docs javascript bootstrap (#1016) by @hjgraca

🔧 Maintenance

This release was made possible by the following contributors:

@ConnorKirk, @dependabot[bot], @hjgraca, dependabot[bot] and github-actions[bot]

v3.0.0

07 Oct 14:25
cfa4560

Choose a tag to compare

Summary

We're excited to announce a major release with new features and important updates:

  • Strongly-typed batch processor with automatic deserialization for SQS, Kinesis, and DynamoDB events
  • Enhanced tracing with improved metadata error handling
  • Bug fix for logging sampling rate

This major version bump reflects significant breaking changes as we update our supported runtimes and dependencies.

Breaking Changes

⚠️ Important: Please review these breaking changes before upgrading:

Migration guide to v3

  • Removed support for .NET 6 - We now require .NET 8 or later
  • AWS SDK v3 no longer supported - We have migrated to AWS SDK v4
  • Version alignment - All Powertools for AWS Lambda utilities will maintain version parity going forward

New Features

Strongly-Typed Batch Processor

📖 Documentation | Migration Guide

Process batch events with type safety and automatic deserialization.

What's New:

  • ITypedRecordHandler<T> and ITypedRecordHandlerWithContext<T> interfaces for strongly-typed processing
  • Specialized processors: TypedSqsBatchProcessor, TypedKinesisEventBatchProcessor, TypedDynamoDbStreamBatchProcessor
  • Automatic JSON deserialization from event records to your types
  • Optional ILambdaContext injection for timeout handling and request tracking

Example Usage:

Simple typed handler:

public class OrderHandler : ITypedRecordHandler<Order>
{
    public async Task<RecordHandlerResult> HandleAsync(Order order, CancellationToken cancellationToken)
    {
        // Direct access to strongly-typed object - no manual deserialization!
        await ProcessOrder(order);
        return RecordHandlerResult.Successful;
    }
}

With Lambda context support (docs):

public class ProductHandlerWithContext : ITypedRecordHandlerWithContext<Product>
{
    public async Task<RecordHandlerResult> HandleAsync(Product product, ILambdaContext context, CancellationToken cancellationToken)
    {
        Logger.LogInformation($"Processing product {product.Id} in request {context.AwsRequestId}");
        Logger.LogInformation($"Remaining time: {context.RemainingTime.TotalSeconds}s");

        // Use context for timeout handling
        if (context.RemainingTime.TotalSeconds < 5)
        {
            Logger.LogWarning("Low remaining time, processing quickly");
        }

        return RecordHandlerResult.Successful;
    }
}

Contributors

Thank you @dcabib for your contributions to this release! ⭐

Changes

🐞 Bug fixes

  • fix(logging): Fix sampling when log level is above Debug #980 @dcabib

📜 Documentation updates

  • chore: remove dotnet6 from docs and add migration guides for v2 and v3 (#1021) by @hjgraca
  • chore(deps): bump squidfunk/mkdocs-material from 86d21da to 00f9276 in /docs (#1013) by @dependabot[bot]
  • chore: Tracing sanitize metadata (#1011) by @hjgraca
  • chore(deps): bump squidfunk/mkdocs-material from 209b62d to 86d21da in /docs (#996) by @dependabot[bot]

🔧 Maintenance

This release was made possible by the following contributors:

@dependabot[bot], @hjgraca and dependabot[bot]

1.60.1

25 Sep 09:53
1fe8ede

Choose a tag to compare

Summary

In this release, we resolved thread safety issues in the Metrics utility that were causing exceptions when multiple threads attempted to collect metrics simultaneously.

Thanks @lachriz-aws for reporting and helping investigate this issue! 🙏

🐛 Bug and hot fixes
fix: concurrency issues in Metrics (#1001) by @hjgraca

1.60.0

09 Sep 10:02
bace4b7

Choose a tag to compare

Summary

This release introduces a new feature for the Idempotency utility that allows developers to manipulate the returned data from idempotent operations, providing greater flexibility and control over the response handling process.

Congratulations @Diogobitten for your first contribution ⭐

Manipulating idempotent responses

Docs

Now you can set up a response hook in the Idempotency configuration to modify the returned data when an operation is idempotent. The hook function is called with the current deserialized response object and the Idempotency DataRecord, allowing you to add custom logic or modify the response as needed.

Idempotency.Config()
    .WithConfig(IdempotencyOptions.Builder()
        .WithEventKeyJmesPath("powertools_json(body).address")
        .WithResponseHook((responseData, dataRecord) => {
            if (responseData is APIGatewayProxyResponse proxyResponse)
            {
                proxyResponse.Headers ??= new Dictionary<string, string>();
                proxyResponse.Headers["x-idempotency-response"] = "true";
                proxyResponse.Headers["x-idempotency-expiration"] = dataRecord.ExpiryTimestamp.ToString();
                return proxyResponse;
            }
            return responseData;
        })
        .Build())
    .WithPersistenceStore(DynamoDBPersistenceStore.Builder()
        .WithTableName(Environment.GetEnvironmentVariable("IDEMPOTENCY_TABLE"))
        .Build())
    .Configure();

Changes

🌟New features and non-breaking changes

  • feat: Add support for response hooks in idempotency utility (#968) by @hjgraca

📜 Documentation updates

  • chore: Remove reference customer section from documentation (#982) by @hjgraca
  • chore: Update copyright information in mkdocs.yml (#976) by @hjgraca
  • feat: Add support for response hooks in idempotency utility (#968) by @hjgraca

🔧 Maintenance

  • chore: Update version for release (#986) by @hjgraca
  • chore: Remove reference customer section from documentation (#982) by @hjgraca
  • chore: Update copyright information in mkdocs.yml (#976) by @hjgraca
  • chore(deps): bump brace-expansion in /examples/Event Handler/BedrockAgentFunction/infra (#973) by @dependabot[bot]
  • chore(deps): bump codecov/codecov-action from 5.4.3 to 5.5.0 (#967) by @dependabot[bot]
  • chore(gitignore): add .kiro, .claude, .amazonq to prevent deletion (#971) by @Diogobitten

This release was made possible by the following contributors:

@Diogobitten, @dependabot[bot], @dreamorosi, @hjgraca and dependabot[bot]

1.54

26 Aug 11:30
0d3043e

Choose a tag to compare

Summary

In this release we fix a bug in the Logging utility where requests containing duplicate HTTP headers (such as multiple Content-Type headers) cause an unhandled exception. When duplicate headers are present, the last header is taken.

Thank you @SamuelGuine for reporting the issue

Logging 2.0.2

Changes

📜 Documentation updates

  • chore(deps): bump squidfunk/mkdocs-material from bb7b015 to 1a4e939 in /docs (#964) by @dependabot[bot]
  • chore(deps): bump squidfunk/mkdocs-material from 0bfdba4 to bb7b015 in /docs (#947) by @dependabot[bot]

🐛 Bug and hot fixes

  • fix: handle duplicate keys in logger state to prevent ArgumentException (#961) by @hjgraca

🔧 Maintenance

This release was made possible by the following contributors:

@dependabot[bot], @hjgraca, @leandrodamascena and dependabot[bot]

1.53

29 Jul 11:38
26ecdc0

Choose a tag to compare

Summary

In this release we improved our Idempotency utility and storage layer is now faster and cheaper by leveraging conditional writes. We also made important changes to the Logger and Metrics utility.

Special thanks to @j-d-ha for reporting logging issues and @sdangol for their first contribution to the project.

Logging

Docs

We've enhanced the AddPowertoolsLogger method with improved service registration and added automatic ILogger interface registration. A new ClearExistingProviders option is now available to prevent multiple logger providers.

builder.Logging.AddPowertoolsLogger(config =>
{
    config.Service = "TestService";
    config.LoggerOutputCase = LoggerOutputCase.PascalCase;
}, clearExistingProviders: true);

Metrics

Docs

Before this release, if you published invalid metrics they could fail silently, leading to data loss. Now Lambda will raise an exception if the following constraints do not hold:

  • Metric Name: Validated according to CloudWatch constraints
  • Metric Value: Validated for numeric values
  • Metric Unit: Validated for allowed units
  • Metric Resolution: Validated for allowed resolutions
  • Dimension Name: Both Dimension name and value are validated for non empty, non-null values.

Idempotency

Docs

Several months ago AWS introduced support for ReturnValuesOnConditionCheckFailure, a feature designed to streamline conditional write operations and reducing costs in Amazon DynamoDB. With this enhancement, Powertools for AWS Lambda now optimistically attempts to write items to DynamoDB. If the item already exists, it seamlessly returns it without requiring an additional operation.

Changes

🌟New features and non-breaking changes

  • feat(metrics): Added runtime validation for the metric name (#943) by @sdangol
  • feat: add support for ReturnValuesOnConditionCheckFailure in Idempotency (#930) by @hjgraca

📜 Documentation updates

  • chore: Add automatic registration of standard logging services and ILogger (#938) by @hjgraca

🔧 Maintenance

  • chore: Update version.json for release 1.53 (#945) by @hjgraca
  • chore(deps): bump github/codeql-action from 3.29.3 to 3.29.4 (#941) by @dependabot[bot]
  • chore(deps): bump aws-powertools/actions from 29979bc5339bf54f76a11ac36ff67701986bb0f0 to 7d2401cbbb232594bde7285bc5b8c0c78dcbe6e2 (#942) by @dependabot[bot]
  • chore(deps): bump github/codeql-action from 3.29.2 to 3.29.3 (#939) by @dependabot[bot]
  • chore: Add automatic registration of standard logging services and ILogger (#938) by @hjgraca
  • chore: Console output overrides lambda console out (#936) by @hjgraca
  • chore: Add missing PTENV to user agent (#927) by @hjgraca

This release was made possible by the following contributors:

@dependabot[bot], @hjgraca, @sdangol, @swopnildangol and dependabot[bot]

1.52

15 Jul 17:40
43bfa78

Choose a tag to compare

Summary

We're thrilled to announce the addition of support for multiple dimension sets within the same Metrics instance. This new feature allows users to gain more granular insights and comprehensive views of their applications by creating aggregating metrics across various dimensions.

Key Features

  • New AddDimensions() method for adding multiple dimensions at once
  • Support for multiple dimension sets in a single Metrics instance
  • Maintains backwards compatibility with existing AddDimension() method
  • Automatic handling of duplicate dimension sets
  • Ensures only the latest dimension value is used as a target member on the root EMF node

Getting Started

To leverage this new functionality, simply use the new AddDimensions() method in your code:

Metrics.AddDimensions(("environment", "prod"), ("region", "us-west-2"));
Metrics.AddDimensions(("environment", "prod"));
Metrics.AddDimensions(("region", "us-west-2"));

Metrics.AddMetric("ExecutionTime", DateTime.Now, Unit.MILLISECONDS);

This will generate CloudWatch Metrics with multiple dimension sets, allowing for more flexible and detailed metric analysis.

Enhanced Metric Output

The new feature produces an enhanced metric output structure, as shown in this example:

{
  "_aws": {
    "Timestamp": 1742467748165,
    "CloudWatchMetrics": [
      {
        "Namespace": "HelloWorldFunction",
        "Metrics": [
          {
            "Name": "ExecutionTime",
            "Unit": "Milliseconds"
          }
        ],
        "Dimensions": [
          [
            "Service"
          ],
          [
            "environment",
            "region"
          ],
          [
            "environment"
          ],
          [
            "region"
          ]
        ]
      }
    ]
  },
  "function_request_id": "c0e5afc1-c033-4aa6-9b13-26bfc324874b",
  "ExecutionTime": 0.0,
  "environment": "prod",
  "functionVersion": "$LATEST",
  "Service": "Powertools",
  "logStreamId": "$LATEST",
  "region": "us-west-2",
  "executionEnvironment": "AWS_Lambda_java17"
}

Changes

📜 Documentation updates

  • chore(deps): bump squidfunk/mkdocs-material from eb04b60 to 0bfdba4 in /docs (#921) by @dependabot[bot]

🔧 Maintenance

This release was made possible by the following contributors:

@hjgraca and dependabot[bot]

1.51.1

02 Jul 12:28
b445d3f

Choose a tag to compare

Summary

We're excited to announce the latest release of Powertools for AWS Lambda (.NET), which brings improvements to our Kafka integration.

Kafka Consumer

Docs

We've improved our Kafka integration by removing the dependency on the Kafka base package from the consumer packages. The base package is now bundled, making it easier to consume and integrate.

Updated packages:

  • AWS.Lambda.Powertools.Kafka.Json (v1.0.2)
  • AWS.Lambda.Powertools.Kafka.Protobuf (v1.0.2)
  • AWS.Lambda.Powertools.Kafka.Avro (v1.0.2)

Key features:

  • Automatic deserialization of Kafka messages (JSON, Avro, and Protocol Buffers)
  • Simplified event record handling with an intuitive interface
  • Support for key and value deserialization
  • ESM support with and without Schema Registry integration
  • Improved error handling for deserialization issues

To get started, install the library corresponding to your schema type:

  • JSON schemas: dotnet add package AWS.Lambda.Powertools.Kafka.Json
  • Avro schemas: dotnet add package AWS.Lambda.Powertools.Kafka.Avro
  • Protocol Buffer schemas: dotnet add package AWS.Lambda.Powertools.Kafka.Protobuf

Changes

🔧 Maintenance

  • chore: update Kafka deserialization to use alias for ConsumerRecords (#922) by @hjgraca
  • chore: remove redundant license comments from multiple files (#920) by @hjgraca
  • chore(deps): bump github/codeql-action from 3.29.0 to 3.29.2 (#918) by @dependabot[bot]
  • chore: Fix kafka dependencies (#913) by @hjgraca
  • chore: add missing UA to event handler and bedrock agents (#917) by @hjgraca

This release was made possible by the following contributors:

@dependabot[bot], @hjgraca and dependabot[bot]

1.51

30 Jun 11:08
3660b0a

Choose a tag to compare

Summary

We're excited to announce the Kafka Consumer utility, which transparently handles message deserialization, provides an intuitive developer experience, and integrates seamlessly with the rest of the Powertools for AWS Lambda ecosystem.

Key features

  • Automatic deserialization of Kafka messages (JSON, Avro, and Protocol Buffers)
  • Simplified event record handling with intuitive interface
  • Support for key and value deserialization
  • Support for ESM with and without Schema Registry integration
  • Proper error handling for deserialization issues

Getting started

To get started, depending on the schema types you want to use, install the library and the corresponding libraries:

  • JSON schemas dotnet add package AWS.Lambda.Powertools.Kafka.Json
  • Avro schemas dotnet add package AWS.Lambda.Powertools.Kafka.Avro
  • Protocol Buffer schemas dotnet add package AWS.Lambda.Powertools.Kafka.Protobuf

Processing Kafka events

Docs

You can use Kafka consumer utility to transform raw Kafka events into an intuitive format for processing.

The Handler function can deserialize both keys and values independently based on your schema configuration. This flexibility allows you to work with different data formats in the same message.

Working with Avro:

image

Working with Protocol Buffers:

image

Working with JSON messages:

image

Error handling

Docs

You can handle errors when processing Kafka messages to ensure your application maintains resilience and provides clear diagnostic information.

The Kafka consumer utility integrates with standard C# exception handling patterns.

image

To learn more about the launch, read the blog post published alongside the release.

🌟New features and non-breaking changes

  • feat(kafka): add logic to handle protobuf deserialization (#909) by @hjgraca

📜 Documentation updates

🔧 Maintenance

This release was made possible by the following contributors:

@dependabot[bot], @hjgraca and dependabot[bot]

1.50.2

20 May 11:31
31b5e2f

Choose a tag to compare

Summary

We're excited to announce that with this release, the Batch Processing and Parameters utilities now support native AOT compilation, completing native AOT support across all Powertools utilities!

Batch processing and Parameters native AOT support

Batch Processing

Parameters

What is Native AOT?

Native AOT (Ahead-of-Time) compilation transforms your .NET applications into self-contained native executables, offering:

  • Up to 60% faster cold start times
  • Reduced memory footprint (up to 80% smaller in some scenarios)
  • Zero JIT compilation overhead
  • Optimizations for serverless and containerized environments

Working with native AOT

To get started with native AOT you need to update your Lambda function's runtime to .NET 8 and add the following to your project file:

<PropertyGroup>
    <PublishAot>true</PublishAot>
</PropertyGroup>

Changes

📜 Documentation updates

  • chore(deps): bump squidfunk/mkdocs-material from f6c81d5 to eb04b60 in /docs (#880) by @dependabot[bot]
  • chore(deps): bump squidfunk/mkdocs-material from 95f2ff4 to f6c81d5 in /docs (#879) by @dependabot[bot]

🔧 Maintenance

  • chore: update batch and parameters version for release 1.50.2 (#891) by @hjgraca
  • chore(deps): bump zgosalvez/github-actions-ensure-sha-pinned-actions from 3.0.24 to 3.0.25 (#889) by @dependabot[bot]
  • chore(deps): bump github/codeql-action from 3.28.17 to 3.28.18 (#888) by @dependabot[bot]
  • chore(deps): bump codecov/codecov-action from 5.4.2 to 5.4.3 (#885) by @dependabot[bot]
  • chore(deps): bump aws-actions/configure-aws-credentials from 4.2.0 to 4.2.1 (#883) by @dependabot[bot]
  • chore(deps): bump squidfunk/mkdocs-material from f6c81d5 to eb04b60 in /docs (#880) by @dependabot[bot]
  • chore: Add AOT support Parameters utility (#882) by @hjgraca
  • chore: Feature/batch aot support (#881) by @hjgraca
  • chore(deps): bump squidfunk/mkdocs-material from 95f2ff4 to f6c81d5 in /docs (#879) by @dependabot[bot]
  • chore(deps): bump aws-actions/configure-aws-credentials from 4.1.0 to 4.2.0 (#876) by @dependabot[bot]

This release was made possible by the following contributors:

@dependabot[bot], @hjgraca and dependabot[bot]