Using AWS Rekognition in a C# App: A Hands-On Guide

Introduction: AI Power for .NET Developers

When most people think of artificial intelligence, they picture Python notebooks and data scientists crunching numbers in the cloud. But if you’re a .NET developer, you don’t need to leave your ecosystem to build AI-powered apps. Amazon Web Services (AWS) provides a robust SDK for C#, making it simple to integrate advanced AI services like AWS Rekognition into your existing projects.

Rekognition is Amazon’s image and video analysis service. It can detect faces, identify objects, analyze emotions, flag unsafe content, and even recognize celebrities. The best part? You don’t need to train models yourself—AWS provides the pre-trained intelligence, and you call it directly from your C# code.

This hands-on guide shows you how to:

  • Set up AWS Rekognition for .NET
  • Install the AWS SDK in a C# project
  • Write code to detect faces and labels
  • Explore business use cases for mid-sized companies
  • Apply best practices for performance and cost control

By the end, you’ll be ready to add enterprise-grade AI capabilities to your C# applications.

Why AWS Rekognition for .NET Developers?

  • Stay in your ecosystem: Write AI integrations in C# without switching languages.
  • Fast time-to-value: Skip building models—just call an API.
  • Enterprise fit: Mid-sized companies already using AWS for hosting can extend easily.
  • Rich features: Face detection, emotion analysis, text extraction, moderation, and more.

For .NET teams, Rekognition provides a way to experiment with AI quickly and scale later.

Step 1 – Setting Up AWS Rekognition

Before writing code, configure your AWS environment.

  1. Create an AWS Account (if you don’t already have one).
  2. Set Up IAM User:
    • Go to the AWS console → IAM.
    • Create a user with programmatic access.
    • Attach the AmazonRekognitionFullAccess policy.
    • Save the Access Key ID and Secret Access Key.
  3. Optional CLI Setup: aws configure Enter your keys and select a default region (e.g., us-east-1).

Now your environment is ready to connect to Rekognition.

Step 2 – Installing the AWS SDK for .NET

Add the AWS SDK NuGet package to your C# project:

Install-Package AWSSDK.Rekognition

This package gives you direct access to Rekognition APIs.

Step 3 – Writing Your First Rekognition Program in C#

Let’s write a simple C# console app to detect faces in an image stored in an S3 bucket.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Amazon;
using Amazon.Rekognition;
using Amazon.Rekognition.Model;

class Program
{
    static async Task Main(string[] args)
    {
        var client = new AmazonRekognitionClient("ACCESS_KEY", "SECRET_KEY", RegionEndpoint.USEast1);

        var request = new DetectFacesRequest
        {
            Image = new Image
            {
                S3Object = new S3Object
                {
                    Bucket = "your-bucket-name",
                    Name = "example.jpg"
                }
            },
            Attributes = new List<string> { "ALL" }
        };

        var response = await client.DetectFacesAsync(request);

        foreach (var face in response.FaceDetails)
        {
            Console.WriteLine($"Confidence: {face.Confidence}");
            Console.WriteLine($"Smile: {face.Smile?.Value}");
            Console.WriteLine($"Emotions: {string.Join(", ", face.Emotions.Select(e => $"{e.Type} ({e.Confidence})"))}");
        }
    }
}

What’s happening here:

  • The app connects to Rekognition with your AWS keys.
  • It pulls an image from S3 (example.jpg).
  • Rekognition analyzes the image and returns attributes like confidence, smile detection, and emotions.

Run the program, and you’ll see structured insights from the image.

Step 4 – Detecting Objects and Labels

Beyond faces, Rekognition can identify objects, activities, and scenes.

var request = new DetectLabelsRequest
{
    Image = new Image
    {
        S3Object = new S3Object
        {
            Bucket = "your-bucket-name",
            Name = "image.jpg"
        }
    },
    MaxLabels = 10,
    MinConfidence = 75F
};

var response = await client.DetectLabelsAsync(request);

foreach (var label in response.Labels)
{
    Console.WriteLine($"Label: {label.Name}, Confidence: {label.Confidence}");
}

Typical results might include:

  • Label: Car (99%)
  • Label: Road (97%)
  • Label: Pedestrian (95%)

This makes Rekognition valuable for retail, manufacturing, and logistics apps.

Step 5 – Real Business Use Cases

For mid-sized companies, Rekognition can be a game-changer:

  • Security: Verify employee photos against ID badges.
  • Retail Analytics: Measure foot traffic with in-store cameras.
  • Insurance Claims: Automate validation of accident photos.
  • Content Moderation: Automatically screen user-uploaded images for unsafe content.
  • Manufacturing: Monitor assembly lines for missing or defective parts.

Each of these use cases leverages the same SDK—just different endpoints.

Step 6 – Best Practices and Cost Control

Rekognition is powerful, but costs can rise if unmanaged.

  • Use S3 for storage: Don’t stream raw images; always point Rekognition to S3.
  • Batch requests: Process multiple images in one call when possible.
  • Set thresholds: Tune confidence levels to avoid false positives.
  • Async calls: Use await for better performance in production apps.
  • Monitor usage: Set up AWS Budgets and CloudWatch alarms to track costs.

Pro tip: Start small, test thoroughly, and then scale—this minimizes waste and ensures ROI.

Wrapping Up

AWS Rekognition brings enterprise-grade image recognition to .NET developers with just a few lines of C#. Whether your mid-sized business needs better security, more efficient operations, or richer customer experiences, Rekognition makes it possible without retraining your team or hiring data scientists.

The bottom line: if you can make an API call in C#, you can add AI to your app.

Next Steps

👉 To learn more about how to integrate AI into your .NET projects, check out our book AI Simplified: Harnessing Microsoft Technologies for Cost-Effective AI Solutions.