The code examples in this topic show you how to use the AWS SDK for .NET 4.x with AWS.
The AWS SDK for .NET 4.x provides a .NET API for AWS infrastructure services. Using the SDK, you can build applications on top of Amazon S3, Amazon EC2, Amazon DynamoDB, and more.
-
Single-service actions - Code examples that show you how to call individual service functions.
-
Single-service scenarios - Code examples that show you how to accomplish a specific task by calling multiple functions within the same service.
-
Cross-service examples - Sample applications that work across multiple AWS services.
Single-service actions and scenarios are organized by AWS service in the dotnetv4 folder. A README in each folder lists and describes how to run the examples.
- 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 build and run the code examples for the AWS SDK for .NET, you need the following:
-
The appropriate .NET SDK for .NET. Most examples use .NET 8, but some require .NET 6.
-
The AWS SDK for .NET. For more information, see the AWS SDK for .NET Developer Guide.
-
AWS credentials, either configured in a local AWS credentials file, or by setting the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. For more information, see the authentication topics in the AWS SDK for .NET Developer Guide and the AWS Tools and SDKs Shared Configuration and Credentials Reference Guide.
To build and run a code example, follow the instructions in the README file for the service. In general, follow these steps:
- Navigate to the directory containing a .sln file.
- Build the solution using
dotnet build SOLUTION.sln
, where SOLUTION.sln is the name of the .sln file. - Navigate to the directory containing the code example and a .csproj file.
- Run the project using the
dotnet run
command.
We rely on dotnet-format to keep this code consistently formatted and styled. To contribute .NET code to this project, please refer to the following installation and usage steps.
We run dotnet-format using a custom configuration file against any changed file or directory. See the .NET Github Action workflow for details.
To invoke dotnet-format yourself, first install it with
dotnet tool install -g dotnet-format`.
Next, run the dotnet-format command in the directory of your solution or project:
dotnet format
Most service folders also include a test project and either integration tests, unit tests, or both. To run all the tests, navigate to the folder that contains the test project and then issue the following command:
dotnet test
If you want more information, run:
dotnet test -l "console;verbosity=detailed"
To specify either unit or integration tests only, use the following category filters with the desired verbosity:
dotnet test --filter Category=Unit -l "console;verbosity=detailed"
or
dotnet test --filter Category=Integration -l "console;verbosity=detailed"
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0