This example shows you how to use the AWS SDK for .NET (v3) to create a REST service that lets you do the following:
- Read, write, and update work items that are stored in an Amazon DynamoDB table.
- Use Amazon Simple Email Service (Amazon SES) to send email reports of work items.
- Running this code might result in charges to your AWS account.
- Running the tests might result in charges to your AWS account.
- We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see Grant least privilege.
- This code is not tested in every AWS Region. For more information, see AWS Regional Services.
To run the code in this example, you need the following:
- An AWS account.
- .NET 6
- To set up your development environment, see Setting up your AWS SDK for .NET environment.
Follow the instructions in the README for the DynamoDB application. to use the AWS Cloud Development Kit (AWS CDK) or AWS Command Line Interface (AWS CLI) to create and manage the table resource used in this example.
To email reports from the app, you must register at least one email address with Amazon SES. This verified email is specified as the sender for emailed reports.
- In a browser, navigate to the Amazon SES console.
- If necessary, select your AWS Region.
- Choose Verified identities.
- Choose Create identity.
- Select Email address.
- Enter an email address that you own.
- Choose Create identity.
- You will receive an email from Amazon Web Services that contains instructions on how to verify the email with Amazon SES. Follow the instructions in the email to complete verification.
Tip: For this example, you can use the same email account for both the sender and the recipient.
This application has two parts: a user interface that uses React and a
RESTful API created with C# and .NET 6. The React user interface is a single-page
application (SPA) that interacts with the C# RESTful API by making GET
, PUT
, and
POST
requests.
The API uses the DynamoDBContext object to perform CRUD operations on a DynamoDB table. The API returns JSON data in an HTTP response, as shown in the following illustration.
Before you run the .NET application, set the configuration values for your DynamoDB table,
and your verified sender email address in the appsettings.json
file. Alternatively, add an appsettings.development.json
file
with your local settings.
After the example compiles, you can run it from the command line. To do so, navigate to the folder that contains the .csproj file and run the following command:
dotnet run
Alternatively, you can run the example from within your IDE.
The .NET application is intended to be used with the Item Tracker web client.
Follow the instructions in the README to set up and run this client.
The client expects the API to be available at http://localhost:8080/api
, which can be configured in launchSettings.json
.
When the web application is running, you will see something like the following.
A user can perform the following tasks using the web application:
- View all items.
- View active items only.
- View archived items only.
- Add a new item.
- Change an active item into an archived item.
- Send a report as an email attachment.
The web application displays active, archived, or all items. For example, the following illustration shows the React application displaying active data.
Here is the React application displaying archived data.
The user can insert a new item into the work item table from the user interface in the React front end application. In the following image, you can see the new item form.
The user can enter an email recipient in the Email text field and choose Send Report. The recipient will get an email like the following.
Active items are selected from the database and used to dynamically create a .csv document. Then, the application uses Amazon SES to email the document to the email address entered. The following image shows an example of a report.
To avoid charges, delete all the resources that you created for this tutorial. Follow the instructions in the Destroying resources section of the README for the DynamoDB sample application.
Congratulations! You have used the AWS SDK for .NET (v3) to create a REST service that manages data in an Amazon DynamoDB table, explored the database through the React frontend web application, and sent reports using Amazon SES.
- Amazon DynamoDB Developer Guide
- Amazon SES Developer Guide
- DynamoDB API Reference
- Amazon SES API Reference
- Amazon DynamoDB .NET API Reference
- Amazon SES .NET API Reference
For more AWS multiservice examples, see cross-service.