Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issues with old .net version #282

Open
wants to merge 2 commits into
base: dotnet
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion module-1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one slipped in.

```

Make sure you are working on dotnet branch either on your favorite git client or using the following command:
Expand Down
5 changes: 3 additions & 2 deletions module-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion module-2/aws-cli/code-pipeline.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
],
"configuration": {
"BranchName": "master",
"BranchName": "main",
"RepositoryName": "MythicalMysfitsService-Repository"
},
"runOrder": 1
Expand Down
11 changes: 9 additions & 2 deletions module-2/webapi/Controllers/MysfitsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace ModernWebAppNET.Controllers
{
[Route("api/[controller]")]
[Route("api/mysfits")]
[ApiController]
public class MysfitsController : ControllerBase
{
Expand All @@ -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));
}
}

Expand Down
8 changes: 5 additions & 3 deletions module-2/webapi/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 2 additions & 3 deletions module-2/webapi/ModernWebAppNET.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

</Project>
8 changes: 7 additions & 1 deletion module-2/webapi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -50,7 +52,11 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
}

app.UseHttpsRedirection();
app.UseMvc();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
4 changes: 3 additions & 1 deletion module-3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
```
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion module-3/webapi/Controllers/MysfitsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace ModernWebAppNET.Controllers
{
[Route("api/[controller]")]
[Route("api/mysfits]")]
[ApiController]
public class MysfitsController : ControllerBase
{
Expand Down
10 changes: 7 additions & 3 deletions module-3/webapi/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 2 additions & 3 deletions module-3/webapi/ModernWebAppNET.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.3.12.2" />
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.3.6" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

</Project>
8 changes: 7 additions & 1 deletion module-3/webapi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -53,7 +54,12 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)

app.UseHttpsRedirection();
app.UseMiddleware<ErrorHandlingMiddleware>();
app.UseMvc();


app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
2 changes: 1 addition & 1 deletion module-4/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion module-4/webapi/Controllers/MysfitsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace ModernWebAppNET.Controllers
{
[Route("api/[controller]")]
[Route("api/mysfits")]
[ApiController]
public class MysfitsController : ControllerBase
{
Expand Down
10 changes: 7 additions & 3 deletions module-4/webapi/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 4 additions & 5 deletions module-4/webapi/ModernWebAppNET.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.3.12.2" />
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.3.6" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.3.4" />
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

</Project>
7 changes: 6 additions & 1 deletion module-4/webapi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand All @@ -61,7 +63,10 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)

app.UseHttpsRedirection();
app.UseMiddleware<ErrorHandlingMiddleware>();
app.UseMvc();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
2 changes: 1 addition & 1 deletion module-5/webapi/Controllers/MysfitsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace ModernWebAppNET.Controllers
{
[Route("api/[controller]")]
[Route("api/mysfits")]
[ApiController]
public class MysfitsController : ControllerBase
{
Expand Down
10 changes: 7 additions & 3 deletions module-5/webapi/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 5 additions & 1 deletion module-5/webapi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand All @@ -61,7 +62,10 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)

app.UseHttpsRedirection();
app.UseMiddleware<ErrorHandlingMiddleware>();
app.UseMvc();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}