Skip to content

DEV331 Option 3: Refactor a traditional ASPX forms application to a fully serverless model.

Duration: ~45 minutes
Credentials:
Windows local user: .\developer
Windows local password: ILove.Net!
SQL user: developer
SQL pass: ILove.Net!
Development Machine Region: Canada Central

High Level Steps:

Step 1 – Create a new AWS Serverless Core Web App

Step 2 – Add NuGet packages for AWSSDK.DynamoDBv2, AWSSDK.Extensions.NETCore.Setup and Swashbuckle.AspNetCore

Step 3 – Modify the ConfigureServices and Configure methods in the Startup.cs class to include Swagger

Step 4 – Add a DataLayer folder and a ContactsDB class to allow for: get all contacts, get contact by id, save a contact and delete a contact

Step 5 – Add a Models folder and create a model based on the Contact table

Step 6 – Add a Controllers folder, add a scaffolded ContactsController

Step 7 – Add get (all), get by id, post, put and delete actions that map to the ContactsDB class methods

Step 8 – Modify the appsettings.Development.json file to include your profile and region.

Step 9 – Create a DynamoDB table that matches the SQL table for local testing

Step 10 – Run and test the application, open Swagger UI and verify the methods work

Step 12 – Add a Contacts page in the Pages folder to the solution

Step 13 – Code the Contacts page to interact with the new Web API and present a similar UI as the original solution

Step 14 – Test the application locally through the UI and verify the Contacts page is working

Step 15 – Create a DynamoDB access role in IAM for DMS (Database Management Service)

Step 16 – Open the DMS service in the console and create a new migration instance, point the source attributes at your development machine and the target at DynamoDB, test both connections and create a task. Start the task and wait for it to complete.

Step 17 – Create a DynamoDb role for Lambda in IAM

Step 18 – Modify the serverless.template in Visual Studio to include the ARN for the lambda role

Step 19 – Publish the application to AWS Lambda

Step 20 – Verify that the publish succeeded and test your application