Skip to content

Commit e453aca

Browse files
Update
1 parent fdb099b commit e453aca

File tree

6 files changed

+87
-195
lines changed

6 files changed

+87
-195
lines changed

content/learning-paths/servers-and-cloud-computing/net-aspire/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ author_primary: Dawid Borycki
2020
### Tags
2121
skilllevels: Introductory
2222
subjects: Containers and Virtualization
23-
cloud_service_providers: AWS, Google Cloud
23+
cloud_service_providers: AWS, Google Cloud
2424

2525
armips:
2626
- Neoverse

content/learning-paths/servers-and-cloud-computing/net-aspire/aws.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Deploy to AWS EC2
3-
weight: 5
3+
weight: 6
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall

content/learning-paths/servers-and-cloud-computing/net-aspire/gcp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Deploy to GCP
3-
weight: 6
3+
weight: 7
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: Modify the Project
3+
weight: 5
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## Modify the Project
10+
You will now include additional code for the purpose of demonstrating computation intense work. Go to the `NetAspire.Arm.ApiService` project, and create a new file `ComputationService.cs`. Add the code shown below to this file:
11+
12+
```cs
13+
static class ComputationService
14+
{
15+
public static void PerformIntensiveCalculations(int matrixSize)
16+
{
17+
var matrix1 = GenerateMatrix(matrixSize);
18+
var matrix2 = GenerateMatrix(matrixSize);
19+
20+
// Matrix multiplication
21+
var matrixResult = Enumerable.Range(0, matrixSize)
22+
.SelectMany(i => Enumerable.Range(0, matrixSize)
23+
.Select(j =>
24+
{
25+
double sum = 0;
26+
for (int k = 0; k < matrixSize; k++)
27+
{
28+
sum += matrix1[i * matrixSize + k] * matrix2[k * matrixSize + j];
29+
}
30+
return sum;
31+
}))
32+
.ToArray();
33+
}
34+
35+
private static double[] GenerateMatrix(int matrixSize) {
36+
return Enumerable.Range(1, matrixSize * matrixSize)
37+
.Select(x => Random.Shared.NextDouble())
38+
.ToArray();
39+
}
40+
}
41+
```
42+
43+
This code defines a static class, ComputationService, designed to perform computationally intensive tasks, specifically matrix multiplication. It contains a public method, PerformIntensiveCalculations, which generates two matrices of a specified size, multiplies them, and stores the resulting matrix.
44+
45+
The private method GenerateMatrix creates a one-dimensional array representing a matrix of the given size (matrixSize x matrixSize). Each element in the matrix is initialized with a random double value generated using Random.Shared.NextDouble().
46+
47+
The public method PerformIntensiveCalculations multiplies two matrices (matrix1 and matrix2) element by element using nested loops and LINQ. It iterates through each row of the first matrix and each column of the second matrix, calculating the dot product for each element in the resulting matrix. The result of the multiplication is stored in a flattened one-dimensional array, matrixResult.
48+
49+
This code is provided for demonstrating heavy computational operations, such as large matrix manipulations, and can simulate workloads in scenarios that mimic intensive data processing or scientific calculations.
50+
51+
Then, open the `Program.cs` file in the `NetAspire.Arm.ApiService` directory and add modify the `MapGet` function of the app as shown:
52+
53+
```cs
54+
app.MapGet("/weatherforecast", () =>
55+
{
56+
ComputationService.PerformIntensiveCalculations(matrixSize: 800);
57+
58+
var forecast = Enumerable.Range(1, 5).Select(index =>
59+
new WeatherForecast
60+
(
61+
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
62+
Random.Shared.Next(-20, 55),
63+
summaries[Random.Shared.Next(summaries.Length)]
64+
))
65+
.ToArray();
66+
return forecast;
67+
});
68+
```
69+
70+
This will trigger matrix multiplications when you click Weather in the web frontend application.
71+
72+
To test the code, re-run the application using the following command:
73+
74+
```console
75+
dotnet run --project NetAspire.Arm.AppHost
76+
```
77+
78+
Next, navigate to the web frontend, click Weather, and then return to the dashboard. Click Traces to observe that the operation now takes significantly longer to complete—approximately 4 seconds in the example below:
79+
80+
![fig4](figures/04.png)
81+
82+
You are now ready to deploy the application to the cloud.

content/learning-paths/servers-and-cloud-computing/net-aspire/project.md

Lines changed: 0 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -59,119 +59,3 @@ The architecture is also tailored to improve the development experience. Develop
5959

6060
This thoughtfully crafted architecture embodies microservices best practices, promoting scalability, maintainability, and service isolation. It not only simplifies deployment and monitoring but also fosters developer productivity by streamlining workflows and providing intuitive tools for building modern, distributed applications.
6161

62-
## Run the Project
63-
The application will issue a certificate. Before you run the application, add support to trust the HTTPS development certificate by running:
64-
65-
```console
66-
dotnet dev-certs https --trust
67-
```
68-
69-
Now run the project:
70-
```console
71-
cd .\NetAspire.Arm\
72-
dotnet run --project NetAspire.Arm.AppHost
73-
```
74-
75-
The output will look like below:
76-
```output
77-
Building...
78-
info: Aspire.Hosting.DistributedApplication[0]
79-
Aspire version: 8.2.2+5fa9337a84a52e9bd185d04d156eccbdcf592f74
80-
info: Aspire.Hosting.DistributedApplication[0]
81-
Distributed application starting.
82-
info: Aspire.Hosting.DistributedApplication[0]
83-
Application host directory is: /Users/db/Repos/NetAspire.Arm/NetAspire.Arm.AppHost
84-
info: Aspire.Hosting.DistributedApplication[0]
85-
Now listening on: https://localhost:17222
86-
info: Aspire.Hosting.DistributedApplication[0]
87-
Login to the dashboard at https://localhost:17222/login?t=81f99566c9ec462e66f5eab5aa9307b0
88-
```
89-
90-
Click on the link generated for the dashboard. In this case it is: https://localhost:17222/login?t=81f99566c9ec462e66f5eab5aa9307b0. This will direct you to the application dashboard, as shown below:
91-
92-
![fig1](figures/01.png)
93-
94-
On the dashboard, locate and click the endpoint link for `NetAspire.Arm.Web`. This will take you to the Blazor based web application. In the Blazor app, navigate to the Weather section to access and display data retrieved from the WeatherForecast API:
95-
96-
![fig2](figures/02.png)
97-
98-
Return to the dashboard and select the Traces option. This section provides detailed telemetry tracing, allowing you to view the flow of requests, track service dependencies, and analyze performance metrics for your application:
99-
100-
![fig3](figures/03.png)
101-
102-
By following these steps, you will explore the key components of the .NET Aspire application, including its dashboard, data interaction through APIs, and telemetry tracing capabilities.
103-
104-
## Modify the Project
105-
You will now include additional code for the purpose of demonstrating computation intense work. Go to the `NetAspire.Arm.ApiService` project, and create a new file `ComputationService.cs`. Add the code shown below to this file:
106-
107-
```cs
108-
static class ComputationService
109-
{
110-
public static void PerformIntensiveCalculations(int matrixSize)
111-
{
112-
var matrix1 = GenerateMatrix(matrixSize);
113-
var matrix2 = GenerateMatrix(matrixSize);
114-
115-
// Matrix multiplication
116-
var matrixResult = Enumerable.Range(0, matrixSize)
117-
.SelectMany(i => Enumerable.Range(0, matrixSize)
118-
.Select(j =>
119-
{
120-
double sum = 0;
121-
for (int k = 0; k < matrixSize; k++)
122-
{
123-
sum += matrix1[i * matrixSize + k] * matrix2[k * matrixSize + j];
124-
}
125-
return sum;
126-
}))
127-
.ToArray();
128-
}
129-
130-
private static double[] GenerateMatrix(int matrixSize) {
131-
return Enumerable.Range(1, matrixSize * matrixSize)
132-
.Select(x => Random.Shared.NextDouble())
133-
.ToArray();
134-
}
135-
}
136-
```
137-
138-
This code defines a static class, ComputationService, designed to perform computationally intensive tasks, specifically matrix multiplication. It contains a public method, PerformIntensiveCalculations, which generates two matrices of a specified size, multiplies them, and stores the resulting matrix.
139-
140-
The private method GenerateMatrix creates a one-dimensional array representing a matrix of the given size (matrixSize x matrixSize). Each element in the matrix is initialized with a random double value generated using Random.Shared.NextDouble().
141-
142-
The public method PerformIntensiveCalculations multiplies two matrices (matrix1 and matrix2) element by element using nested loops and LINQ. It iterates through each row of the first matrix and each column of the second matrix, calculating the dot product for each element in the resulting matrix. The result of the multiplication is stored in a flattened one-dimensional array, matrixResult.
143-
144-
This code is provided for demonstrating heavy computational operations, such as large matrix manipulations, and can simulate workloads in scenarios that mimic intensive data processing or scientific calculations.
145-
146-
Then, open the `Program.cs` file in the `NetAspire.Arm.ApiService` directory and add modify the `MapGet` function of the app as shown:
147-
148-
```cs
149-
app.MapGet("/weatherforecast", () =>
150-
{
151-
ComputationService.PerformIntensiveCalculations(matrixSize: 800);
152-
153-
var forecast = Enumerable.Range(1, 5).Select(index =>
154-
new WeatherForecast
155-
(
156-
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
157-
Random.Shared.Next(-20, 55),
158-
summaries[Random.Shared.Next(summaries.Length)]
159-
))
160-
.ToArray();
161-
return forecast;
162-
});
163-
```
164-
165-
This will trigger matrix multiplications when you click Weather in the web frontend application.
166-
167-
To test the code, re-run the application using the following command:
168-
169-
```console
170-
dotnet run --project NetAspire.Arm.AppHost
171-
```
172-
173-
Next, navigate to the web frontend, click Weather, and then return to the dashboard. Click Traces to observe that the operation now takes significantly longer to complete—approximately 4 seconds in the example below:
174-
175-
![fig4](figures/04.png)
176-
177-
You are now ready to deploy the application to the cloud.
Lines changed: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
2-
title: Run the Project
2+
title: Run the application
33
weight: 4
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
8+
89
## Run the Project
910
The application will issue a certificate. Before you run the application, add support to trust the HTTPS development certificate by running:
1011

@@ -46,78 +47,3 @@ Return to the dashboard and select the Traces option. This section provides deta
4647
![fig3](figures/03.png)
4748

4849
By following these steps, you will explore the key components of the .NET Aspire application, including its dashboard, data interaction through APIs, and telemetry tracing capabilities.
49-
50-
## Modify the Project
51-
You will now include additional code for the purpose of demonstrating computation intense work. Go to the `NetAspire.Arm.ApiService` project, and create a new file `ComputationService.cs`. Add the code shown below to this file:
52-
53-
```cs
54-
static class ComputationService
55-
{
56-
public static void PerformIntensiveCalculations(int matrixSize)
57-
{
58-
var matrix1 = GenerateMatrix(matrixSize);
59-
var matrix2 = GenerateMatrix(matrixSize);
60-
61-
// Matrix multiplication
62-
var matrixResult = Enumerable.Range(0, matrixSize)
63-
.SelectMany(i => Enumerable.Range(0, matrixSize)
64-
.Select(j =>
65-
{
66-
double sum = 0;
67-
for (int k = 0; k < matrixSize; k++)
68-
{
69-
sum += matrix1[i * matrixSize + k] * matrix2[k * matrixSize + j];
70-
}
71-
return sum;
72-
}))
73-
.ToArray();
74-
}
75-
76-
private static double[] GenerateMatrix(int matrixSize) {
77-
return Enumerable.Range(1, matrixSize * matrixSize)
78-
.Select(x => Random.Shared.NextDouble())
79-
.ToArray();
80-
}
81-
}
82-
```
83-
84-
This code defines a static class, ComputationService, designed to perform computationally intensive tasks, specifically matrix multiplication. It contains a public method, PerformIntensiveCalculations, which generates two matrices of a specified size, multiplies them, and stores the resulting matrix.
85-
86-
The private method GenerateMatrix creates a one-dimensional array representing a matrix of the given size (matrixSize x matrixSize). Each element in the matrix is initialized with a random double value generated using Random.Shared.NextDouble().
87-
88-
The public method PerformIntensiveCalculations multiplies two matrices (matrix1 and matrix2) element by element using nested loops and LINQ. It iterates through each row of the first matrix and each column of the second matrix, calculating the dot product for each element in the resulting matrix. The result of the multiplication is stored in a flattened one-dimensional array, matrixResult.
89-
90-
This code is provided for demonstrating heavy computational operations, such as large matrix manipulations, and can simulate workloads in scenarios that mimic intensive data processing or scientific calculations.
91-
92-
Then, open the `Program.cs` file in the `NetAspire.Arm.ApiService` directory and add modify the `MapGet` function of the app as shown:
93-
94-
```cs
95-
app.MapGet("/weatherforecast", () =>
96-
{
97-
ComputationService.PerformIntensiveCalculations(matrixSize: 800);
98-
99-
var forecast = Enumerable.Range(1, 5).Select(index =>
100-
new WeatherForecast
101-
(
102-
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
103-
Random.Shared.Next(-20, 55),
104-
summaries[Random.Shared.Next(summaries.Length)]
105-
))
106-
.ToArray();
107-
return forecast;
108-
});
109-
```
110-
111-
This will trigger matrix multiplications when you click Weather in the web frontend application.
112-
113-
To test the code, re-run the application using the following command:
114-
115-
```console
116-
dotnet run --project NetAspire.Arm.AppHost
117-
```
118-
119-
Next, navigate to the web frontend, click Weather, and then return to the dashboard. Click Traces to observe that the operation now takes significantly longer to complete—approximately 4 seconds in the example below:
120-
121-
![fig4](figures/04.png)
122-
123-
You are now ready to deploy the application to the cloud.

0 commit comments

Comments
 (0)