Amazon DynamoDB

Get started

Everything the samples need on your machine, once: the .NET SDK, a project, the packages, the database and the connection string.

  1. Install the .NET SDK

    .NET SDK 10.0.100 or later 10.0.x. The samples target net10.0. Check what you have:

    Terminal
    dotnet --version
  2. Create a project

    Terminal
    dotnet new console -n ArxSample -f net10.0
    cd ArxSample
  3. Add the packages

    • ARX.SDK.DynamoDb1.0.0-rc.1: The Amazon DynamoDB provider. It brings ARX.SDK and AWSSDK.DynamoDBv2 4.0.110 with it.
    • ARX.SDK1.0.0-rc.1: The core: entities, queries, the schema catalog, errors. Comes with the provider.
    • AWSSDK.DynamoDBv24.0.110: The AWS SDK for .NET's DynamoDB client. Comes with the provider.
    Terminal
    dotnet add package ARX.SDK.DynamoDb --version 1.0.0-rc.1

    Some advanced samples need one more package; their pages give the exact command.

  4. Create the database and the sample schema

    Amazon DynamoDB, or DynamoDB Local for development (tested with DynamoDB Local 2.5.2), through AWSSDK.DynamoDBv2 4.0.110 or later (the lowest version, which the provider is built on; Versions and compatibility lists the versions it is tested on). With Docker, start one (DynamoDB Local needs no password; the AWS SDK only wants a region and any access key):

    Terminal
    docker run --name arx-samples-dynamodb -p 8000:8000 -d amazon/dynamodb-local:2.5.2 -jar DynamoDBLocal.jar -inMemory

    Then save sample-schema.json (download it, or copy it below) in your project folder, next to Program.cs. You don't run it yourself: the Program.cs on every sample page deletes and makes again what it lists before the sample runs.

    sample-schema.json

    The sample schema the samples run against.

    {
      "comment": "The sample tables, as the samples' reset makes them on DynamoDB Local: each table's key attributes (S unless a type says N) and its global secondary indexes, on-demand billing.",
      "tables": [
        { "name": "product", "partitionKey": "sku" },
        { "name": "lead", "partitionKey": "email" },
        { "name": "crm", "partitionKey": "PK", "sortKey": "SK", "indexes": [ { "name": "GSI1", "partitionKey": "GSI1PK", "sortKey": "GSI1SK" } ] },
        { "name": "events", "partitionKey": "PK", "sortKey": "SK" }
      ]
    }
    
  5. Configure the connection

    The samples read the DynamoDB endpoint from the ARX_SAMPLES_DYNAMODB environment variable, never from the code. Set it in the terminal you run them from:

    Terminal

    macOS and Linux (bash, zsh)

    export ARX_SAMPLES_DYNAMODB="http://localhost:8000"
    PowerShell

    Windows PowerShell

    $env:ARX_SAMPLES_DYNAMODB = "http://localhost:8000"
  6. Add a sample and run it

    Each sample page lists its files: copy each into the project with the file name shown, then run:

    Terminal
    dotnet run

    The page shows the output to expect. Each run starts from the sample data: the page's Program.cs remakes the sample database from sample-schema.json first, so a sample can run again and again.