Lab 3. Using DynamoDB as a Session State Provider


In this lab we will create a session table with the help of DynamoDB service, we will use the NuGet packages to communicate with


Amazon DynamoDB is a fast and flexible NoSQL database service for all applications that need consistent, single-digit millisecond latency at any scale. It is a fully managed cloud database and supports both document and key-value store models.Amazon DynamoDB Accelerator (DAX) is a fully managed, highly available, in-memory cache that can reduce Amazon DynamoDB response times from milliseconds to microseconds, even at millions of requests per second.

Nuget Packages in Visual Studio

NuGet is the package manager for the Microsoft development platform including .NET. The NuGet client tools provide the ability to produce and consume packages.

By doing this lab you will learn:

  • How to create a session table in DynamoDB
  • How to install Nuget packages, manage and how to use it for retrieving data
  • Checking the session table getting updated when a order is placed

The image shown below is the architecture for this lab.


To start with this lab you should 1st create a session table. To create a session table click on > Services >and choose DynamoDB.


When you are on the DynamoDB click on Create table.


Give the table name as ASP.NET_SessionState
Give the Primary key  as Hash 
Hash Attribute name as SessionId
Click on Add Index and Click on Create


When the SessionState table is created, click on the radio button next to ASP.NET_SessionState and on the right hand side you can see the details tabs with different features.

To give the Read Capacity=3 and Write capacity=1 click on capacity tab and you can change.


To turn off the alarms click on the Alarms tab and select the alarms and click on Delete.


To create an Access Key click on your profile name and select My Security Credentials. When you are on your security credentials page click on Create New Access Key.


A pop-up window will appear and click on download to download your key file.


When you have finished downloading the key go to your visual studio and go to your project. You have to download ‘AWS SDK’ for .NET to install that click on Project> Manage NuGet packages.

Note: If you have ‘AWS SDK’ Package no need to install it again. When an error occurs try to install a degraded version of it, do not update it to the latest version.



When you have installed it click on your Web.config and remove the line ‘ and replace the code with the following code which is shown below.


When the code is properly edited, Select NET.702.Dinostore.Object and select the file shoppingCart.cs replace the code as given below.

public class ShoppingCart
public string CustomerId { get; set; }
public DateTime DateCreated { get; set; }
public string CcType { get; set; }
public string CcNumber { get; set; }
public string CcExpiration { get; set; }
public List Items { get; set; }

public ShoppingCart()
DateCreated = DateTime.Now;
Items = new List();




When you are done doing necessary changes to the codes go back to your AWS dynamoDB console and explore the sessiontstate table you should see no items.


Browse your application from the browser and login with the credentials. Add a Dinosaur to the cart.


Click on check out.


Go back to your AWS dynamoDB console and explore the sessionstate table. and you will see an item.


When all these steps are completed successfully you are done with lab 3.


By the end of this lab you have learned:

  • How to create a session table in DynamoDB
  • How to install Nuget packages, manage and how to use it for retrieving data
  • Checking the session table getting updated when a order is placed

Budget Plan

DynamoDB is a part of AWS’s Free tier. Pay only for what you use.  There will be no minimum fee. AWS customers can get started with Amazon DynamoDB for free. The customers will get 25GB as for free storage and up to 25 write capacity units of ongoing throughput capacity and 2.5 million read requests from DynamoDB Streams for free. When you go beyond your free tier they will start charging and price varies according to the regions as for me i have created my DynamoDB service in US West (Oregon) it if i go beyond my free tier it will cost me for throughput:

  • Write Throughput: $0.0065 per hour for every 10 units of Write Capacity (enough capacity to do up to 36,000 writes per hour).
  • Read Throughput: $0.0065 per hour for every 50 units of Read Capacity (enough capacity to do up to 180,000 strongly consistent reads, or 360,000 eventually consistent reads, per hour).

As for the data storage if i go over 25GB it will cost $0.25 per GB-month. To Save up your budget you should make sure that you create the services in the Same Region.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s