Lab 3: Using DynamoDB as a Session State Provider

In the DynamoDB service, a table needs to be created. The table is called ‘ASP.NET_SessionState’ and has a primary key called “SessinID” of type string.
001 Create DynamoDB Table

In Visual Studio, the NuGet packages to be managed and the ‘AWS.SDK: Core’, as well as the ‘AWS.SDK for .Net: SessionProvider’ packages need to be installed.
002 NuGet Packages for AWS

In Visual Studio’s web.config window, the ‘<sessionState mode = “Proc…’ section needs to changed to show the following:
003 SessionState in VS web_config.PNG
The keys for Access keys for this section need to be created in AWS, as the created DynamoDB doesn’t automatically have a key attached to it.

In the ShoppingCart.cs window in Visual Studio, the word ‘serializable’ needs to be inserted above the line ‘public class ShoppingCart’ and ‘public class ShoppingCartItem’ as follows:
004 VS ShoppingCart_cs Serializable.PNG

Then in the AWS DynamoDB table, there should be no items present. However, if the DinoStore application is run, and an item is added to the ‘cart’, then the DynamoDB table will update to record the item being sold.

This slideshow requires JavaScript.


The only challenge that I faced with this lab was that I made the incorrect assumption that ‘Sydney’ was a usable alias for the ap-southeast-2 region in ‘Region’ under ‘<Providers>’ in the web.config window in Visual Studio. This would cause the code to break and show the following message:
009 Config Error after Build

Once the ‘Region’ was corrected, the code worked as expected.



Introduction to Amazon DynamoDB

Introduction and Aim
The purpose of this lab is to create a simple table in Amazon DynamoDB, which is used to store information about a music library. QwikLabs describes Amazon DynamoDB as ‘a fast and flexible NoSQL database service for all applications that need consistent, single-digit millisecond latency at any scale.’



  • Create an Amazon Dynamo DB  table
  • Loading data into an Amazon DynamoDB table
  • Querying Amazon DynamoDB
  • Deleting an Amazon DynamoDB table


Creating a new table
In the DynamoDB, I create a Table called ‘Music’. For the primary key, I write ‘Artist’ and have its type as string. The next step is to click ‘Add Sort Key’ and create a new field type called ‘SongTitle’ that is also a string.
Then Table settings are left as default, and now the database can be created.
InkedCreate Table_LI

The action of creating a DynamoDB is a very simple process on the user’s end, as AWS controls most of the set-up process.


Adding and modifying table data
In DynamoDB, each item is made up of attributes, which is similar to way an entity contains attributes. For DynamoDB, only the primary key attributes are required.
In order to create an item, the specific table is selected, in my case it’s the music table. Then the items tab can be clicked and a ‘Create Item’ option will be displayed.
The lab script asks for the following information to be input into the new item:

Artist: No One You Know (String)
SongTitle: Call Me Today (String)

Then to create another attribute, the ‘Append’ button is used. In this instance, another string type with Field: AlbumTitle, and Value: Somewhat Famous.
Additional Attribute to Create Item

Another attribute is made, this time of type number, with Field: Year, and Value:2015.

Then the item can be saved, now with four attributes.
Personalised Item to Create

The lab script asks for two more items to be created. The final table looks like this:
All Items


Modifying an existing item in the table
The table can be modified by selecting the Music table, and either double-clicking on the cell to edit, or as the lab script suggests; click the items tab and select the year, then in the Actions drop-down, press edit, and save any changes made. The lab script directs for the year ‘2014’ to be changed to ‘2013’.
Editing Date on Music Item


Querying the table.
The table can be queried to find specific items based on various information. The lab script makes mention that ‘the primary key is made of Artist (partition key) and SongTitle (sort key).
In the music table, under the items tab, I can change the drop-down labelled ‘Scan’ to ‘Query’.
The first query requires me input into the Partition…SongTitle…String=value box; ‘No one You know”. Once searched, all tracks with the artist ‘No One You Know’ are displayed.
Query Search -No One You Know
The next query is, keeping with the previous query add another query for Sort Key…SongTitle…String= ‘Call Me Today’.
Query Search-Call Me Today

The final query is, still keeping with the partition key specifications, clear the sort key data, and press the ‘Add filter’ button. In a new filter row, the attribute is set to year of type number, and the value set to 2013. This limits songs from the specified album that have the specified date.
Query Search -Filter Year 2013


Deleting the table
Deleting a table also deletes all the data within the table. To delete the table,I select table to delete, click ‘Actions’, then press ‘Delete Table’. A confirmation pop-up appears, and once confirmed,  the database is deleted.
Delete Table



I found DynamoDB to be a very user-friendly AWS environment due to preset parameters, which resulted in very little configuration adjustments. Although this is suitable for simple tables such as the Music table that was created, I can understand that the reduced amount of configuration can limit the use of the database. A thorough run-through and play within the DynamoDB is a potential solution for gaining understanding of the extents of this service.