CloudNimble.WebJobs.Extensions.Amazon 1.0.0-CI-20250608-015954

Prefix Reserved
This is a prerelease version of CloudNimble.WebJobs.Extensions.Amazon.
dotnet add package CloudNimble.WebJobs.Extensions.Amazon --version 1.0.0-CI-20250608-015954
                    
NuGet\Install-Package CloudNimble.WebJobs.Extensions.Amazon -Version 1.0.0-CI-20250608-015954
                    
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="CloudNimble.WebJobs.Extensions.Amazon" Version="1.0.0-CI-20250608-015954" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CloudNimble.WebJobs.Extensions.Amazon" Version="1.0.0-CI-20250608-015954" />
                    
Directory.Packages.props
<PackageReference Include="CloudNimble.WebJobs.Extensions.Amazon" />
                    
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 CloudNimble.WebJobs.Extensions.Amazon --version 1.0.0-CI-20250608-015954
                    
#r "nuget: CloudNimble.WebJobs.Extensions.Amazon, 1.0.0-CI-20250608-015954"
                    
#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 CloudNimble.WebJobs.Extensions.Amazon@1.0.0-CI-20250608-015954
                    
#: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=CloudNimble.WebJobs.Extensions.Amazon&version=1.0.0-CI-20250608-015954&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CloudNimble.WebJobs.Extensions.Amazon&version=1.0.0-CI-20250608-015954&prerelease
                    
Install as a Cake Tool

CloudNimble.WebJobs.Extensions.Amazon

NuGet License: MIT

Overview

CloudNimble.WebJobs.Extensions.Amazon brings the power of AWS services to Azure WebJobs! This package enables you to use Amazon SQS queues as triggers and bindings in your Azure Functions and WebJobs, allowing you to build cloud-agnostic solutions that leverage the best of both worlds.

Why Use This?

  • Multi-Cloud Strategy: Run Azure Functions that process AWS SQS messages
  • Gradual Migration: Move from AWS to Azure (or vice versa) without rewriting your queue processing logic
  • Best of Both Worlds: Use Azure's serverless compute with AWS's messaging infrastructure
  • Familiar Programming Model: If you know Azure WebJobs, you already know how to use this

Features

  • 🚀 SQS Triggers: Process messages from Amazon SQS queues with automatic scaling
  • 📤 SQS Output Bindings: Send messages to SQS queues from your functions
  • 🔄 Automatic Retries: Built-in retry logic with configurable poison message handling
  • 🎯 Multiple Message Types: Support for raw SQS messages, strings, and custom POCOs
  • 📊 Metrics & Monitoring: Integration with Azure Monitor for SQS queue metrics
  • 🔒 Secure: Support for IAM roles, credentials, and LocalStack for development

Installation

dotnet add package CloudNimble.WebJobs.Extensions.Amazon

Quick Start

1. Configure Your Host

using Microsoft.Extensions.Hosting;
using CloudNimble.WebJobs.Extensions.Amazon;

var host = new HostBuilder()
    .ConfigureFunctionsWorkerDefaults()
    .ConfigureServices(services =>
    {
        // Add AWS services
        services.AddDefaultAWSOptions(Configuration.GetAWSOptions());
        services.AddAWSService<IAmazonSQS>();
        
        // Add SQS extension
        services.AddSQSExtension();
    })
    .Build();

host.Run();

2. Create Your First SQS Trigger

public class OrderProcessor
{
    [FunctionName("ProcessOrder")]
    public async Task ProcessNewOrder(
        [SQSTrigger("orders-queue")] Order order,
        ILogger log)
    {
        log.LogInformation($"Processing order {order.Id} for {order.CustomerName}");
        
        // Your business logic here
        await ProcessOrderAsync(order);
    }
}

public class Order
{
    public string Id { get; set; }
    public string CustomerName { get; set; }
    public decimal Total { get; set; }
    public List<OrderItem> Items { get; set; }
}

3. Send Messages to SQS

public class OrderService
{
    [FunctionName("CreateOrder")]
    public async Task<IActionResult> CreateOrder(
        [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest req,
        [SQS("orders-queue")] IAsyncCollector<Order> orderQueue)
    {
        var order = await req.GetBodyAsync<Order>();
        
        // Send to SQS queue
        await orderQueue.AddAsync(order);
        
        return new OkObjectResult(new { orderId = order.Id });
    }
}

Advanced Scenarios

Working with Raw SQS Messages

[FunctionName("ProcessRawMessage")]
public async Task ProcessRawSQSMessage(
    [SQSTrigger("raw-queue")] SQSMessage message,
    ILogger log)
{
    log.LogInformation($"MessageId: {message.MessageId}");
    log.LogInformation($"Body: {message.Body}");
    
    // Access message attributes
    foreach (var attr in message.MessageAttributes)
    {
        log.LogInformation($"Attribute {attr.Key}: {attr.Value.StringValue}");
    }
    
    // Process based on content
    if (message.MessageAttributes.ContainsKey("Type"))
    {
        await RouteMessageByType(message);
    }
}

Batch Processing

[FunctionName("ProcessBatch")]
public async Task ProcessMessageBatch(
    [SQSTrigger("batch-queue", BatchSize = 10)] SQSMessage[] messages,
    ILogger log)
{
    log.LogInformation($"Processing batch of {messages.Length} messages");
    
    var tasks = messages.Select(msg => ProcessSingleMessageAsync(msg));
    await Task.WhenAll(tasks);
}

Dead Letter Queue Handling

[FunctionName("ProcessDeadLetters")]
public async Task HandleDeadLetterMessages(
    [SQSTrigger("orders-queue-dlq")] DeadLetterMessage<Order> deadLetter,
    ILogger log)
{
    log.LogWarning($"Dead letter received. Attempts: {deadLetter.DequeueCount}");
    log.LogWarning($"Original error: {deadLetter.LastError}");
    
    // Attempt remediation or alert operations team
    await NotifyOperationsTeam(deadLetter);
}

Configuration Options

services.Configure<SQSOptions>(options =>
{
    // Polling configuration
    options.MaxPollingInterval = TimeSpan.FromSeconds(20);
    options.BatchSize = 10;
    
    // Retry configuration
    options.MaxDequeueCount = 5;
    options.VisibilityTimeout = TimeSpan.FromMinutes(5);
    
    // Processing configuration
    options.MaxConcurrentCalls = 16;
    options.PrefetchCount = 32;
});

Using with LocalStack

Perfect for local development and testing:

services.AddDefaultAWSOptions(new AWSOptions
{
    ServiceURL = "http://localhost:4566",
    AuthenticationRegion = "us-east-1",
    Credentials = new BasicAWSCredentials("test", "test")
});

Queue Name Resolution

Use application settings for flexible queue naming:

{
  "Values": {
    "OrdersQueue": "prod-orders-queue",
    "OrdersQueueDLQ": "prod-orders-queue-dlq"
  }
}
[FunctionName("ProcessOrder")]
public async Task ProcessOrder(
    [SQSTrigger("%OrdersQueue%")] Order order)
{
    // Queue name resolved from settings
}

Monitoring and Metrics

The extension provides built-in metrics for monitoring:

  • Queue Length: Current approximate message count
  • Message Age: Age of oldest message in queue
  • Processing Rate: Messages processed per second
  • Error Rate: Failed message processing rate

These metrics integrate with Azure Monitor for alerting and autoscaling.

Best Practices

  1. Use POCO Types: Define strongly-typed classes for your messages
  2. Handle Idempotency: Messages may be processed more than once
  3. Set Appropriate Timeouts: Configure visibility timeout based on processing time
  4. Monitor Dead Letter Queues: Set up alerts for DLQ messages
  5. Use Batch Processing: For high-throughput scenarios, process messages in batches

Migration from AWS Lambda

Moving from AWS Lambda to Azure Functions? It's easy:

AWS Lambda:

public async Task Handler(SQSEvent sqsEvent, ILambdaContext context)
{
    foreach (var message in sqsEvent.Records)
    {
        await ProcessMessage(message.Body);
    }
}

Azure Functions with this extension:

[FunctionName("ProcessMessages")]
public async Task Run([SQSTrigger("my-queue")] string message)
{
    await ProcessMessage(message);
}

Troubleshooting

Common Issues

Q: Messages are not being processed

  • Check AWS credentials and permissions
  • Verify queue name and region
  • Check Azure Functions logs for errors

Q: Messages are being processed multiple times

  • Increase visibility timeout
  • Ensure processing completes within timeout
  • Implement idempotency in your logic

Q: High latency when polling

  • Adjust polling intervals
  • Consider batch processing
  • Check network connectivity to AWS

Contributing

We welcome contributions! Please see our Contributing Guide for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support


Made with ❤️ by CloudNimble

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 is compatible.  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 (2)

Showing the top 2 NuGet packages that depend on CloudNimble.WebJobs.Extensions.Amazon:

Package Downloads
SimpleMessageBus.Dispatch.Amazon

SimpleMessageBus is a system for making applications more reliable and responsive to users by processing potentially long-running tasks out-of-band from the user's main workflow. It is designed to run either on-prem, or in the Microsoft Cloud, making it suitable for any application, and able to grow as your needs do.

SimpleMessageBus.Publish.Amazon

SimpleMessageBus is a system for making applications more reliable and responsive to users by processing potentially long-running tasks out-of-band from the user's main workflow. It is designed to run either on-prem, or in the Microsoft Cloud, making it suitable for any application, and able to grow as your needs do.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-CI-20250608-015954 82 6/8/2025
1.0.0-CI-20250608-013940 79 6/8/2025
1.0.0-CI-20250608-012213 78 6/8/2025
1.0.0-CI-20250606-232418 40 6/7/2025