Skip to content

This repository contains a sample implementation of Fanout Architecture using .NET6 Worker Services to process messages from Amazon SNS Topic and Amazon SQS Queue. Since the Worker Services would have no UI, to operate this solution, you need Observability implemented. In this repository, you can also find sample .NET Observability implementatio…

License

Notifications You must be signed in to change notification settings

aws-samples/microservices-dotnet-aws-cdk

Sample .NET6 Worker Services with AWS CDK and AWS Fargate

This repository contains a sample implementation of Fanout Architecture using .NET6 Worker Services to process messages from Amazon Simple Notification Service (SNS) Topic and Amazon Simple Queue Service (SQS) Queue. Since the Worker Services would have no UI, to operate this solution, you need Observability implemented. In this repository, you can also find sample .NET Observability implementation using the combination of AWS X-Ray and Amazon CloudWatch. To provision this solution, you can use AWS Cloud Development Kit (AWS CDK) to implement your modern Infrastructure as Code, using .NET C# to provision all AWS Resources your application needs.

Architecture

Architecture Diagram

Componets:

  1. .NET6 Web API Microservices - Demo Web API to simulate end-user requests.
  2. .NET6 Worker Service 1 - Demo Worker Services that persist on DynamoDB.
  3. .NET6 Worker Service 2 - Demo Worker Services that persist on S3.
  4. SNS - Fully managed pub/sub messaging for asynchronous processing.
  5. SQS - Fully managed message queues for microservices.
  6. Amazon DynamoDb Table - Fast, flexible NoSQL database service for single-digit millisecond performance at any scale.
  7. Amazon Simple Storage Service (Amazon S3) Bucket - Object storage built to retrieve any amount of data from anywhere.
  8. AWS X-Ray - Analyze and debug production, distributed applications.
  9. Amazon CloudWatch - Observability of your AWS resources and applications on AWS.
  10. Amazon Elastic Container Registry (Amazon ECR) - Easily store, share, and deploy your container software anywhere.
  11. AWS CDK - Define cloud infrastructure using familiar programming languages (C#)

Guide to deploy and test the sample

Prerequisites

Before exploring the code, please ensure you have the following tools to deploy and see the demo working.

Deployment Script

This path is for those not interested in the details of the steps executed to deploy the solution. You can run the script as instructed below and jump into the test.

For: [Bash]

./deploy.sh

For: [Powershel]

.\deploy.ps1

After completing the deployment, you can copy the printed URL like http://WebAp-demos-XXXXXXXXXXXX-9999999999.us-west-2.elb.amazonaws.com and jump to test

Test the Solution

To begin the tests, copy the URL printed by the deployment script. It will look like: “http://WebAp-demos-XXXXXXXX-99999999.us-west-2.elb.amazonaws.com”. Make a POST request to the endpoint http://YOUR_ALB_URL/api/Books using your favorite REST API Client, sending the following JSON payload. You can send multiple requests to have some sample data to visualize the Observability result from AWS CloudWatch console.

{
    "Year" : 2022,
    "Title": "Demo book payload",
    "ISBN": 12345612,
    "Authors": ["Author1", "Author2"],
    "CoverPage": "picture1.jpg"
}

.NET Observability with X-Ray and CloudWatch

To see the results, open the AWS Console and navigate to CloudWatch and select the option Traces from the left navigation menu, then go to the end of the page use one of the Trace ID you got from the POST Result you should see a picture like the one bellow.

"Observability Result"

Clean up Resources

After exploring this solution, please remember to clean up, here's the script to help clean up.

Using: [Bash]

./clean.sh

Using: [PowerShell]

.\clean.ps1

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

This repository contains a sample implementation of Fanout Architecture using .NET6 Worker Services to process messages from Amazon SNS Topic and Amazon SQS Queue. Since the Worker Services would have no UI, to operate this solution, you need Observability implemented. In this repository, you can also find sample .NET Observability implementatio…

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks