Amazon DynamoDB
Developer Guide (API Version 2012-08-10)

.NET and DAX

Follow these steps to run the .NET sample on your Amazon EC2 instance.


This tutorial uses the .NET Core SDK. It shows how you can run a program in your default Amazon VPC to access your Amazon DynamoDB Accelerator (DAX) cluster. If you prefer, you can use the AWS Toolkit for Visual Studio to write a .NET application and deploy it into your VPC.

For more information, see Creating and Deploying Elastic Beanstalk Applications in .NET Using AWS Toolkit for Visual Studio in the AWS Elastic Beanstalk Developer Guide.

  1. Go to and download the latest .NET Core SDK for Linux. The downloaded file is named as follows: dotnet-sdk-N.N.N-linux-x64.tar.gz

  2. Extract the .NET Core files:

    mkdir dotnet tar zxvf dotnet-sdk-N.N.N-linux-x64.tar.gz -C dotnet

    Replace N.N.N with the actual version number of the .NET Core SDK, for example: 2.1.4

  3. Verify the installation:

    alias dotnet=$HOME/dotnet/dotnet dotnet --version

    This should print the version number of the .NET Core SDK.


    Instead of the version number, you might receive the following error:

    error: cannot open shared object file: No such file or directory

    To resolve the error, install the libunwind package:

    sudo yum install -y libunwind

    After you do this, you should be able to run the dotnet --version command without any errors.

  4. Create a new .NET project:

    dotnet new console -o myApp

    This requires a few minutes to perform a one-time-only setup. When it completes, run the sample project:

    dotnet run --project myApp

    You should receive the following message: Hello World!

  5. The myApp/myApp.csproj file contains metadata about your project. To use the DAX client in your application, you need to modify the file so that it looks like this:

    <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp2.0</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="AWSSDK.DAX.Client" Version="1.0.0" /> </ItemGroup> </Project>
  6. Download the sample program source code (.zip file):


    When the download is complete, extract the source files:

  7. Now run the sample programs, one at a time. For each program, copy its contents into the myApp/Program.cs, and then run the MyApp project.

    Run the following .NET programs:

    cp 01-CreateTable.cs myApp/Program.cs dotnet run --project myApp cp 02-Write-Data.cs myApp/Program.cs dotnet run --project myApp

    The first program creates a DynamoDB table named TryDaxTable. The second program writes data to the table.

  8. Now run some programs to perform GetItem, Query, and Scan operations on your DAX cluster. To determine the endpoint for your DAX cluster, choose one of the following:

    • Using the DynamoDB console — Choose your DAX cluster. The cluster endpoint is shown on the console; for example:
    • Using the AWS CLI — Type the following command:

      aws dax describe-clusters --query "Clusters[*].ClusterDiscoveryEndpoint"

      The cluster endpoint port and address are shown in the output; for example:

      { "Port": 8111, "Address":"" }

    Now run the following programs, specifying your cluster endpoint as a command line parameter. (Replace the sample endpoint with your actual DAX cluster endpoint.)

    cp 03-GetItem-Test.cs myApp/Program.cs dotnet run --project myApp cp 04-Query-Test.cs myApp/Program.cs dotnet run --project myApp cp 05-Scan-Test.cs myApp/Program.cs dotnet run --project myApp

    Take note of the timing information—the number of milliseconds required for the GetItem, Query, and Scan tests.

  9. Run the following .NET program to delete TryDaxTable:

    cp 06-DeleteTable.cs myApp/Program.cs dotnet run --project myApp

For more information about these programs, see the following sections: