IRONSOFTWAREHOME

How to Read & Write QR Codes on AWS Lambda

Curtis Chau
Curtis Chau
Updated: August 2, 2026

This how-to article offers a detailed guide for setting up an AWS Lambda function with IronQR. In this tutorial, you will discover how to configure IronQR for reading and writing QR codes directly to an S3 bucket.

Installation

This article will use an S3 bucket, so the AWSSDK.S3 package is required.

Start using IronQR in your project today with a free trial.

First Step:
arrow pointer

Create an AWS Lambda Project

With Visual Studio, creating a containerized AWS Lambda is an easy process:

  • Install the AWS Toolkit for Visual Studio
  • Select an 'AWS Lambda Project (.NET Core - C#)'
  • Select a '.NET 8 (Container Image)' blueprint, then select 'Finish'.

Select container image

Add Package Dependencies

The IronQR library in .NET 8 operates on AWS Lambda without requiring additional dependencies. To configure it, modify the project's Dockerfile as shown below:

FROM public.ecr.aws/lambda/dotnet:8

# Install necessary packages and update repositories
RUN dnf update -y

WORKDIR /var/task

# This COPY command copies the .NET Lambda project's build artifacts from the host machine into the image. 
# The source of the COPY should match where the .NET Lambda project publishes its build artifacts. If the Lambda function is being built 
# with the AWS .NET Lambda Tooling, the `--docker-host-build-output-dir` switch controls where the .NET Lambda project
# will be built. The .NET Lambda project templates default to having `--docker-host-build-output-dir`
# set in the aws-lambda-tools-defaults.json file to "bin/Release/lambda-publish".
#
# Alternatively, Docker multi-stage build could be used to build the .NET Lambda project inside the image.
# For more information on this approach, check out the project's README.md file.
COPY "bin/Release/lambda-publish"  .
Text

Modify the FunctionHandler Code

This example creates a QR code, uploads it to an S3 bucket, and reads the newly generated QR code.

The file path is specified in the IronQrNuget directory, with a globally unique identifier (GUID) used as the file name. The Write method generates the QR code based on the provided value, and the resulting JPG byte array is then passed to the Read method for reading the QR code. This demonstrates that this AWS Lambda function is capable of reading QR codes.

using Amazon.Lambda.Core;
using Amazon.S3;
using Amazon.S3.Model;
using IronQr;

// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]

namespace IronQrNuGetAwsLambda
{
    public class Function
    {
        private static readonly IAmazonS3 _s3Client = new AmazonS3Client(Amazon.RegionEndpoint.APSoutheast1);

        /// <summary>
        /// Main handler for AWS Lambda
        /// </summary>
        /// <param name="context">The ILambdaContext that provides methods for logging and describing the Lambda environment.</param>
        /// <returns></returns>
        public async Task FunctionHandler(ILambdaContext context)
        {
            // Set the license key for IronQR
            IronQr.License.LicenseKey = "IronQR-MYLICENSE-KEY-1EF01";

            string bucketName = "deploymenttestbucket";
            string objectKey = $"IronQrNuget/{Guid.NewGuid()}.png";

            try
            {
                // Create a QR code with the content "12345"
                var myQr = QrWriter.Write("12345");

                context.Logger.LogLine("QR created.");

                // Upload the JPG to S3
                await UploadJpgToS3Async(bucketName, objectKey, myQr.Save().ExportBytesAsJpg());

                context.Logger.LogLine($"QR uploaded successfully to {bucketName}/{objectKey}");

                // Read the QR code
                QrImageInput imageInput = new QrImageInput(myQr.Save());
                QrReader reader = new QrReader();
                var resultFromByte = reader.Read(imageInput);

                foreach (var item in resultFromByte)
                {
                    // Log the read value
                    context.Logger.LogLine($"QR value is = {item.Value}");
                }
            }
            catch (Exception e)
            {
                context.Logger.LogLine($"[ERROR] FunctionHandler: {e.Message}");
            }
        }

        // Function to upload the JPG file to S3
        private async Task UploadJpgToS3Async(string bucketName, string objectKey, byte[] jpgBytes)
        {
            using (var memoryStream = new MemoryStream(jpgBytes))
            {
                var request = new PutObjectRequest
                {
                    BucketName = bucketName,
                    Key = objectKey,
                    InputStream = memoryStream,
                    ContentType = "image/jpg",
                };

                await _s3Client.PutObjectAsync(request);
            }
        }
    }
}

Increase Memory and Timeout

The memory allocation for the Lambda function depends on the size of the documents and the number processed simultaneously. As a starting point, set the memory to 512 MB and the timeout to 300 seconds in the aws-lambda-tools-defaults.json.

"function-memory-size" : 512,
"function-timeout" : 300
JSON

If the memory is insufficient, the program will raise the error: 'Runtime exited with error: signal: killed.' Increasing the memory size can help resolve this issue. For further guidance, check the troubleshooting article: AWS Lambda - Runtime Exited Signal: Killed.

Publish

To publish in Visual Studio, simply right-click the project and choose 'Publish to AWS Lambda...' Then, configure the required settings. For more information, visit the AWS website.

Try It Out!

You can activate the Lambda function either through the Lambda console or through Visual Studio.

Frequently Asked Questions

How do I set up IronQR on AWS Lambda?

To set up IronQR on AWS Lambda, you need to create a containerized project in Visual Studio, add the IronQR library, configure dependencies, modify the Dockerfile, and deploy the function with appropriate memory and timeout settings.

What prerequisites are needed to use IronQR on AWS Lambda?

You need Visual Studio, AWS Toolkit for Visual Studio, the AWSSDK.S3 package for S3 bucket interaction, and the IronQR library.

Can IronQR read and write QR codes directly to an S3 bucket?

Yes, IronQR can be configured to read and write QR codes directly to an S3 bucket on AWS Lambda.

How do I increase memory and timeout settings for IronQR on AWS Lambda?

You can increase memory and timeout settings by adjusting the 'function-memory-size' and 'function-timeout' fields in the aws-lambda-tools-defaults.json file.

How is the IronQR library integrated into a .NET 8 containerized project?

IronQR is integrated by adding the library to the project, modifying the Dockerfile, and setting up the FunctionHandler to create and read QR codes using IronQR.

What should I do if the Lambda function runs out of memory?

If the function runs out of memory, try increasing the memory allocation setting in the aws-lambda-tools-defaults.json file and ensure it has enough resources to operate efficiently.

How do I deploy an AWS Lambda function with IronQR?

Deploy the function by configuring the project for AWS Lambda, increasing memory and timeout settings if necessary, and using Visual Studio to publish the project to AWS Lambda.

Is additional setup required for IronQR to work on AWS Lambda?

No additional dependencies are required for IronQR to work on AWS Lambda when using .NET 8, other than the standard AWS setup.

What is required to publish a project with IronQR to AWS Lambda in Visual Studio?

To publish, right-click the project, select 'Publish to AWS Lambda...', and configure the necessary settings in the publish dialog.

How can I test the deployed Lambda function using IronQR?

You can activate and test the Lambda function through the AWS Lambda console or directly from Visual Studio after deployment.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 74,386Version:2026.9just released

Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronQR
nuget.org/packages/IronQR/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronQR"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronQR to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronQR.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required