LazyStack

Create a .NET Console App

In this step we will create a simple PetStoreConsoleApp. This console app will support all the features of AuthProcess running against AWS Cognito, initialize the PetStore library and make a simple call against the stack.

9.1 Create PetStoreConsoleApp Project

  1. CD into the solution folder (LazyStackTutorial\PetStoreCLI) and create new console project:
    dotnet new console -o PetStoreConsoleApp
    Windows:
    dotnet sln add PetStoreConsoleApp\PetStoreConsoleApp.csproj
    MacOS/Linux:
    dotnet sln add PetStoreConsoleApp/PetStoreConsoleApp.csproj

9.2 Configure PetStoreConsoleApp Project

  1. Copy this content into the PetStoreConsoleApp.csproj file:
    
    <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
            <OutputType>Exe</OutputType>
            <TargetFramework>net6.0</TargetFramework>
            <ImplicitUsings>enable</ImplicitUsings>
            <Nullable>enable</Nullable>        
        </PropertyGroup>
        
        <ItemGroup>
            <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
            <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
            <ProjectReference Include="..\PetStoreClientSDK\PetStoreClientSDK.csproj" />
            <EmbeddedResource Include="..\Stacks\Dev\AwsSettings.json" />
            <EmbeddedResource Include="..\LocalApis.json" />
        </ItemGroup>
    </Project>                
                
  2. Save the file.

9.3 Implement Program

  1. Download Program.cs and move it into your project, replacing the existing Program.cs.
  2. Build project.
    dotnet build

Run Project

9.4 Run Against Stack
  1. CD into solution folder (LazyStackTutorial\PetStoreCLI) and run the project:
    dotnet run -p PetStoreConsoleApp
  2. Here is a sample command window session:

    You can use any login, password and email you want in this tutorial step. The email must be valid so you can receive the authentication code sent to that email in the sign up step. You can sign up only once with the same email address.

    Welcome to the PetStoreConsoleApp program
    Use LocalApi? y/n:n
    1. Sign Up
    2. Sign In
    3. Reset Password
    4. Quit
    >1
    Enter your Login: MyLoginName
    Enter your Password: MyPassword1!
    Enter your Email address: myemail@gmail.com
    Enter authentication code: 984185
    You are Signed Up! You can now SignIn.
    1. Sign Up
    2. Sign In
    3. Reset Password
    4. Quit
    >2
    Enter your Login: MyLoginName
    Enter your current Password: MyPassword1!
    1. Sign Out
    2. Update Password
    3. Update Phone
    4. Update Login
    5. Seed Pets data
    6. Get Pet 1
    7. See Available Pets
    8. GetUserId
    9. Quit
    >5
    Pets added to database
    1. Sign Out
    2. Update Password
    3. Update Phone
    4. Update Login
    5. Seed Pets data
    6. Get Pet 1
    7. See Available Pets
    8. GetUserId
    9. Quit
    >6
    pet: 1 Alf Available
    1. Sign Out
    2. Update Password
    3. Update Phone
    4. Update Login
    5. Seed Pets data
    7. See Available Pets
    8. GetUserId
    9. Quit
    >8
    UserId=b184b386-22c9-41a3-8a33-15d2bf1ff4ed
    1. Sign Out
    2. Update Password
    3. Update Phone
    4. Update Login
    5. Seed Pets data
    7. See Available Pets
    8. GetUserId
    9. Quit
    >9
    

Step Summary

In this step we created a Console App project and used it to run against the AWS Application Stack.