diff --git a/module-1/README.md b/module-1/README.md index 6aa5c269..c5f3ec3a 100644 --- a/module-1/README.md +++ b/module-1/README.md @@ -35,7 +35,7 @@ Open the terminal in Visual Studio Code, located under **View > Terminal** Type the following `git` command to clone the necessary code to complete this tutorial: ``` -git clone https://github.com/aws-samples/aws-modern-application-workshop.git +git clone https://github.com/iamtgray/aws-modern-application-workshop.git ``` Make sure you are working on dotnet branch either on your favorite git client or using the following command: diff --git a/module-2/README.md b/module-2/README.md index bc81a6e6..40fd1a76 100644 --- a/module-2/README.md +++ b/module-2/README.md @@ -152,11 +152,12 @@ In order to push container images into our new repository, we will need to obtai `Bash` ``` -$(aws ecr get-login --no-include-email) +aws ecr get-login-password --region $(aws configure get region) | docker login --username AWS --password-stdin $(aws sts get-caller-identity --query Account --output text).dkr.ecr.$(aws configure get region).amazonaws.com ``` `PowerShell` ``` -Invoke-Expression $(Get-ECRLoginCommand | Select-Object -ExpandProperty Command) +(Get-ECRLoginCommand).Password | docker login --username AWS --password-stdin $(Get-STSCallerIdentity | Select-Object -ExpandProperty Account).dkr.ecr.region.amazonaws.com + ``` Next, push the image you created to the ECR repository using the copied tag from above. Using this command, docker will push your image and all the images it depends on to Amazon ECR: diff --git a/module-2/aws-cli/code-pipeline.json b/module-2/aws-cli/code-pipeline.json index c7acc857..8ab2c9d0 100644 --- a/module-2/aws-cli/code-pipeline.json +++ b/module-2/aws-cli/code-pipeline.json @@ -23,7 +23,7 @@ } ], "configuration": { - "BranchName": "master", + "BranchName": "main", "RepositoryName": "MythicalMysfitsService-Repository" }, "runOrder": 1 diff --git a/module-2/webapi/Controllers/MysfitsController.cs b/module-2/webapi/Controllers/MysfitsController.cs index 5106aeba..9b358945 100644 --- a/module-2/webapi/Controllers/MysfitsController.cs +++ b/module-2/webapi/Controllers/MysfitsController.cs @@ -9,7 +9,7 @@ namespace ModernWebAppNET.Controllers { - [Route("api/[controller]")] + [Route("api/mysfits")] [ApiController] public class MysfitsController : ControllerBase { @@ -20,7 +20,14 @@ public IActionResult Get() using (StreamReader r = new StreamReader("./mysfits-response.json")) { var json = r.ReadToEnd(); - return new JsonResult(JObject.Parse(json)); + var content = new ContentResult(); + + content.Content = json; + content.ContentType = "application/json"; + + + return content; + //return new JsonResult(JObject.Parse(json)); } } diff --git a/module-2/webapi/Dockerfile b/module-2/webapi/Dockerfile index 032603d8..db403d9e 100644 --- a/module-2/webapi/Dockerfile +++ b/module-2/webapi/Dockerfile @@ -1,9 +1,11 @@ -FROM microsoft/dotnet:2.1-sdk as build +FROM mcr.microsoft.com/dotnet/sdk:6.0 as build WORKDIR /app COPY . /app -RUN dotnet publish -c Release -r linux-musl-x64 -o out +RUN dotnet add package Newtonsoft.Json +RUN dotnet publish -c Release -r linux-x64 -o out -FROM microsoft/dotnet:2.1-runtime-deps-alpine + +FROM mcr.microsoft.com/dotnet/runtime-deps:6.0 WORKDIR /app COPY --from=build /app/out ./ ENV ASPNETCORE_ENVIRONMENT=Production diff --git a/module-2/webapi/ModernWebAppNET.csproj b/module-2/webapi/ModernWebAppNET.csproj index 44b4f46d..888aec28 100644 --- a/module-2/webapi/ModernWebAppNET.csproj +++ b/module-2/webapi/ModernWebAppNET.csproj @@ -1,12 +1,11 @@ - netcoreapp2.1 + netcoreapp6.0 - - + diff --git a/module-2/webapi/Startup.cs b/module-2/webapi/Startup.cs index 14865f52..13cdc487 100644 --- a/module-2/webapi/Startup.cs +++ b/module-2/webapi/Startup.cs @@ -29,11 +29,13 @@ public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddCors(); + services.AddControllers(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { + app.UseRouting(); app.UseCors(builder => builder .AllowAnyOrigin() @@ -50,7 +52,11 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) } app.UseHttpsRedirection(); - app.UseMvc(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); } } } diff --git a/module-3/README.md b/module-3/README.md index a795c314..63820837 100644 --- a/module-3/README.md +++ b/module-3/README.md @@ -65,7 +65,7 @@ Also provided is a JSON file that can be used to batch insert a number of Mysfit `Bash` ``` -aws dynamodb batch-write-item --request-items file://~/environment/aws-modern-application-workshop/module-3/aws-cli/populate-dynamodb.json +aws dynamodb batch-write-item --request-items file://module-3/aws-cli/populate-dynamodb.json ``` `PowerShell` ``` @@ -133,6 +133,8 @@ Deploy your updated angular app by running the following PowerShell script or Ba ``` ./module-3/deploy-frontend-scripts/Deploy-FrontEnd.ps1 ``` +**Note:** If you have issues dimilar to `./node_modules/@angular/cli/bin/ng: No such file or directory` in your frontend deployment, go to the frontend directory and issue an `npm install` to locate dependencies + **(Optional)** **Note:** If you used AWS Amplify to deploy your Angular app, use the following command to deploy your updated code: diff --git a/module-3/webapi/Controllers/MysfitsController.cs b/module-3/webapi/Controllers/MysfitsController.cs index c7b65d36..ae495206 100644 --- a/module-3/webapi/Controllers/MysfitsController.cs +++ b/module-3/webapi/Controllers/MysfitsController.cs @@ -10,7 +10,7 @@ namespace ModernWebAppNET.Controllers { - [Route("api/[controller]")] + [Route("api/mysfits]")] [ApiController] public class MysfitsController : ControllerBase { diff --git a/module-3/webapi/Dockerfile b/module-3/webapi/Dockerfile index 032603d8..f4472b8e 100644 --- a/module-3/webapi/Dockerfile +++ b/module-3/webapi/Dockerfile @@ -1,9 +1,13 @@ -FROM microsoft/dotnet:2.1-sdk as build +FROM mcr.microsoft.com/dotnet/sdk:6.0 as build WORKDIR /app COPY . /app -RUN dotnet publish -c Release -r linux-musl-x64 -o out +RUN dotnet add package Newtonsoft.Json +RUN dotnet add package AWSSDK.DynamoDBv2 +RUN dotnet add package AWSSDK.Extensions.NETCore.Setup +RUN dotnet publish -c Release -r linux-x64 -o out -FROM microsoft/dotnet:2.1-runtime-deps-alpine + +FROM mcr.microsoft.com/dotnet/runtime-deps:6.0 WORKDIR /app COPY --from=build /app/out ./ ENV ASPNETCORE_ENVIRONMENT=Production diff --git a/module-3/webapi/ModernWebAppNET.csproj b/module-3/webapi/ModernWebAppNET.csproj index 48691625..90f782cb 100644 --- a/module-3/webapi/ModernWebAppNET.csproj +++ b/module-3/webapi/ModernWebAppNET.csproj @@ -1,14 +1,13 @@ - netcoreapp2.1 + netcoreapp6.0 - - + diff --git a/module-3/webapi/Startup.cs b/module-3/webapi/Startup.cs index 1e6e4aab..da54bdad 100644 --- a/module-3/webapi/Startup.cs +++ b/module-3/webapi/Startup.cs @@ -42,6 +42,7 @@ public void ConfigureServices(IServiceCollection services) // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { + app.UseRouting(); app.UseCors(builder => builder .AllowAnyOrigin() @@ -53,7 +54,12 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) app.UseHttpsRedirection(); app.UseMiddleware(); - app.UseMvc(); + + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); } } } diff --git a/module-4/README.md b/module-4/README.md index cec86460..c0567665 100644 --- a/module-4/README.md +++ b/module-4/README.md @@ -132,7 +132,7 @@ cd ./module-4/frontend/src/aws-exports.js CTRL-F through the file to search for the various places `REPLACE_ME` is located and awaiting your specific parameters. Once the edits have been made, save the file and execute the following AWS CLI command: ``` -aws apigateway import-rest-api --parameters endpointConfigurationTypes=REGIONAL --body file://~/environment/aws-modern-application-workshop/module-4/aws-cli/api-swagger.json --fail-on-warnings +aws apigateway import-rest-api --parameters endpointConfigurationTypes=REGIONAL --body file://module-4/aws-cli/api-swagger.json --fail-on-warnings ``` Copy the response this command returns and save the `id` value for the next step: diff --git a/module-4/webapi/Controllers/MysfitsController.cs b/module-4/webapi/Controllers/MysfitsController.cs index 6768957c..f406fa30 100644 --- a/module-4/webapi/Controllers/MysfitsController.cs +++ b/module-4/webapi/Controllers/MysfitsController.cs @@ -12,7 +12,7 @@ namespace ModernWebAppNET.Controllers { - [Route("api/[controller]")] + [Route("api/mysfits")] [ApiController] public class MysfitsController : ControllerBase { diff --git a/module-4/webapi/Dockerfile b/module-4/webapi/Dockerfile index d50b4ea5..a1b55619 100644 --- a/module-4/webapi/Dockerfile +++ b/module-4/webapi/Dockerfile @@ -1,9 +1,13 @@ -FROM microsoft/dotnet:2.1-sdk as build +FROM mcr.microsoft.com/dotnet/sdk:6.0 as build WORKDIR /app COPY . /app -RUN dotnet publish -c Release -r linux-musl-x64 -o out +RUN dotnet add package Newtonsoft.Json +RUN dotnet add package AWSSDK.DynamoDBv2 +RUN dotnet add package AWSSDK.Extensions.NETCore.Setup +RUN dotnet publish -c Release -r linux-x64 -o out -FROM microsoft/dotnet:2.1-runtime-deps-alpine + +FROM mcr.microsoft.com/dotnet/runtime-deps:6.0 WORKDIR /app COPY --from=build /app/out ./ ENV ASPNETCORE_ENVIRONMENT=Production diff --git a/module-4/webapi/ModernWebAppNET.csproj b/module-4/webapi/ModernWebAppNET.csproj index 48691625..bd3c428e 100644 --- a/module-4/webapi/ModernWebAppNET.csproj +++ b/module-4/webapi/ModernWebAppNET.csproj @@ -1,14 +1,13 @@ - netcoreapp2.1 + netcoreapp6.0 - - - - + + + diff --git a/module-4/webapi/Startup.cs b/module-4/webapi/Startup.cs index 9223eaa2..f9a791a3 100644 --- a/module-4/webapi/Startup.cs +++ b/module-4/webapi/Startup.cs @@ -45,6 +45,8 @@ public void ConfigureServices(IServiceCollection services) // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { + app.UseRouting(); + if (env.IsDevelopment()) { app.UseCors(builder => @@ -61,7 +63,10 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) app.UseHttpsRedirection(); app.UseMiddleware(); - app.UseMvc(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); } } } diff --git a/module-5/webapi/Controllers/MysfitsController.cs b/module-5/webapi/Controllers/MysfitsController.cs index 6768957c..f406fa30 100644 --- a/module-5/webapi/Controllers/MysfitsController.cs +++ b/module-5/webapi/Controllers/MysfitsController.cs @@ -12,7 +12,7 @@ namespace ModernWebAppNET.Controllers { - [Route("api/[controller]")] + [Route("api/mysfits")] [ApiController] public class MysfitsController : ControllerBase { diff --git a/module-5/webapi/Dockerfile b/module-5/webapi/Dockerfile index d50b4ea5..a1b55619 100644 --- a/module-5/webapi/Dockerfile +++ b/module-5/webapi/Dockerfile @@ -1,9 +1,13 @@ -FROM microsoft/dotnet:2.1-sdk as build +FROM mcr.microsoft.com/dotnet/sdk:6.0 as build WORKDIR /app COPY . /app -RUN dotnet publish -c Release -r linux-musl-x64 -o out +RUN dotnet add package Newtonsoft.Json +RUN dotnet add package AWSSDK.DynamoDBv2 +RUN dotnet add package AWSSDK.Extensions.NETCore.Setup +RUN dotnet publish -c Release -r linux-x64 -o out -FROM microsoft/dotnet:2.1-runtime-deps-alpine + +FROM mcr.microsoft.com/dotnet/runtime-deps:6.0 WORKDIR /app COPY --from=build /app/out ./ ENV ASPNETCORE_ENVIRONMENT=Production diff --git a/module-5/webapi/Startup.cs b/module-5/webapi/Startup.cs index 9223eaa2..395106ef 100644 --- a/module-5/webapi/Startup.cs +++ b/module-5/webapi/Startup.cs @@ -45,6 +45,7 @@ public void ConfigureServices(IServiceCollection services) // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { + app.UseRouting(); if (env.IsDevelopment()) { app.UseCors(builder => @@ -61,7 +62,10 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) app.UseHttpsRedirection(); app.UseMiddleware(); - app.UseMvc(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); } } }