Skip to content

Commit

Permalink
Merge pull request #1480 from madeline-underwood/NET-ASPIRE
Browse files Browse the repository at this point in the history
.NET Aspire_KB approved
  • Loading branch information
jasonrandrews authored Dec 30, 2024
2 parents ebe6bbf + e62d510 commit 24a9e47
Show file tree
Hide file tree
Showing 8 changed files with 334 additions and 236 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
---
title: Run .NET Aspire applications on Arm-based Virtual Machines in AWS and GCP
title: Run a .NET Aspire application on Arm-based VMs on AWS and GCP

minutes_to_complete: 60

who_is_this_for: This is an introductory learning path for software developers interested in learning how to deploy .NET Aspire applications in AWS and GCP
who_is_this_for: This is an introductory topic for software developers interested in learning how to deploy .NET Aspire applications on Arm-based virtual machines (VMs) on Amazon Web Services (AWS) and Google Cloud Platform (GCP).

learning_objectives:
- Learn about .NET Aspire.
- Create a .NET Aspire project and deploy it to the Arm-powered Virtual Machines in the Cloud.

- Demonstrate knowledge and understanding of .NET Aspire developer tools.
- Create a .NET Aspire application.
- Modify code on a Windows on Arm development machine.
- Deploy a .NET Aspire application to Arm-powered virtual machines in the Cloud.
prerequisites:
- A Windows on Arm computer such as [Windows Dev Kit 2023](https://learn.microsoft.com/en-us/windows/arm/dev-kit), a Lenovo Thinkpad X13s running Windows 11 to build the .NET Aspire project.
- An [Arm based instance](/learning-paths/servers-and-cloud-computing/csp/) from AWS or GCP to deploy the application.
- Any code editor. [Visual Studio Code for Arm64](https://code.visualstudio.com/docs/?dv=win32arm64user) is suitable.
- A Windows on Arm machine, for example the [Windows Dev Kit 2023](https://learn.microsoft.com/en-us/windows/arm/dev-kit), or a Lenovo Thinkpad X13s running Windows 11 to build the .NET Aspire project.
- An [Arm-based instance](/learning-paths/servers-and-cloud-computing/csp/) from AWS or GCP.
- Any code editor. [Visual Studio Code for Arm64](https://code.visualstudio.com/docs/?dv=win32arm64user) is an example of a suitable editor.

author_primary: Dawid Borycki

### Tags
skilllevels: Introductory
subjects: Containers and Virtualization
cloud_service_providers: AWS, Google Cloud
cloud_service_providers: AWS, Google Cloud

armips:
- Neoverse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ review:
question: >
Which command do you use to install the Aspire workload on an Arm-powered VM?
answers:
- sudo apt install aspire
- dotnet workload install aspire
- dotnet install aspire --arm64
- sudo apt install aspire.
- dotnet workload install aspire.
- dotnet install aspire --arm64.
correct_answer: 2
explanation: >
The correct command to install the Aspire workload is `dotnet workload install aspire`, as it uses the .NET CLI to manage workloads.
Expand All @@ -15,23 +15,23 @@ review:
question: >
When creating an AWS EC2 instance, which step ensures secure remote access to the VM?
answers:
- Creating a new key pair in the "Key pair (login)" section
- Selecting the appropriate security group for the instance
- Allowing HTTP and HTTPS traffic in the network settings
- Creating a new key pair in the "Key pair (login)" section.
- Selecting the appropriate security group for the instance.
- Allowing HTTP and HTTPS traffic in the network settings.
correct_answer: 1
explanation: >
Creating a new key pair in the "Key pair (login)" section generates a private key file that is essential for secure SSH access to the EC2 instance.
- questions:
question: >
In Google Cloud Platform, what series should you select to use an Arm64 processor for your VM?
In Google Cloud Platform, which series should you select to use an Arm64 processor for the VM?
answers:
- T2A (Ampere Altra Arm)
- E2 (General Purpose)
- N2D (Compute Optimized)
- T2A (Ampere Altra Arm).
- E2 (General Purpose).
- N2D (Compute Optimized).
correct_answer: 1
explanation: >
The T2A series (Ampere Altra Arm) is designed specifically for Arm64 processors and provides cost-effective, high-performance computing in GCP.
The T2A series (Ampere Altra Arm) is designed specifically for Arm64 processors and provides cost-effective, high-performance computing in the Google Cloud Platform.
# ================================================================================
# FIXED, DO NOT MODIFY
Expand Down
107 changes: 59 additions & 48 deletions content/learning-paths/servers-and-cloud-computing/net-aspire/aws.md
Original file line number Diff line number Diff line change
@@ -1,85 +1,96 @@
---
title: Deploy to AWS EC2
weight: 4
weight: 6

### FIXED, DO NOT MODIFY
layout: learningpathall
---

### Objective
In this section you will learn how to deploy the .NET Aspire application onto an AWS EC2 Virtual Machine powered by Arm-based processors, such as AWS Graviton. This involves leveraging the cost and performance benefits of Arm architecture while demonstrating the seamless deployment of cloud-native applications on modern infrastructure.
In this section, you will learn how to deploy the .NET Aspire application you created on to an AWS Elastic Compute Cloud (EC2) virtual machine powered by Arm-based processors, such as AWS Graviton. This allows you to leverage the cost and performance benefits of Arm architecture while benefiting from the seamless deployment of cloud-native applications on modern infrastructure.

### Set up your AWS EC2 Instance
To set up an Arm-powered EC2 instance, follow these steps:
1. Log in to the [AWS Management Console](http://console.aws.amazon.com).

### Setup your AWS EC2 Instance
Follow these steps to deploy an app to an Arm-powered EC2 instance::
1. Log in to AWS Management Console [here](http://console.aws.amazon.com)
2. Navigate to EC2 Service. In the search box type "EC2". Then, click EC2:
2. Navigate to the EC2 Service.

![fig5](figures/05.png)
As Figure 5 shows, in the search box, type "EC2".

Then, click on **EC2** in the search results:

3. In the EC2 Dashboard, click “Launch Instance” and fill out the following details:
* Name: type arm-server
* AMI: Select Arm-compatible Amazon Machine Image, Ubuntu 22.04 LTS for Arm64.
* Architecture: Select 64-bit (Arm).
* Instance Type: Select t4g.small.
![Figure 5 alt-text#center](figures/05.png "Figure 5: Search for the EC2 Service in the AWS Management Console.")

The configuration should look as follows:
3. In the EC2 Dashboard, click **Launch Instance** and add the following information in these corresponding data fields to configure your setup:
* Name: enter **arm-server**.
* AMI: select **Arm-compatible Amazon Machine Image, Ubuntu 22.04 LTS for Arm64**.
* Architecture: select **64-bit (Arm)**.
* Instance Type: select **t4g.small**.

![fig6](figures/06.png)
The configuration should look like the configuration fields that Figure 6 shows:

4. Scroll down to "Key pair (login)", and click "Create new key pair". This will display the "Create key pair" window, in which you configure the following:
* Key pair name: arm-key-pair
* Key pair type: RSA
* Private key format: .pem
* Click the Create key pair button, and download the key pair to your computer
![Figure 6 alt-text#center](figures/06.png "Figure 6: Configuration Fields.")

4. Scroll down to **Key pair** (login), and click **Create new key pair**.
This displays the **Create key pair** window.
Now configure the following fields:
* Key pair name: **arm-key-pair**.
* Key pair type: **RSA**.
* Private key format: **.pem**.
* Click the **Create key pair** button, and download the key pair to your computer.

![fig7](figures/07.png)

5. Scroll down to "Network Settings", where:
* VPC: use default
* Subnet: select no preference
* Auto-assign public IP: Enable
* Firewall: Check Create security group
* Security group name: arm-security-group
* Description: arm-security-group
* Inbound security groups
5. Scroll down to **Network Settings**, and configure the settings:
* VPC: select the default.
* Subnet: select **No preference**.
* Auto-assign public IP: **Enable**.
* Firewall: Check **Create security group**.
* Security group name: **arm-security-group**.
* Description: **arm-security-group**.
* Inbound security groups.

![fig8](figures/08.png)

6. Configure "Inbound Security Group Rules". Specifically, click "Add Rule" and set the following details:
* Type: Custom TCP
* Protocol: TCP
* Port Range: 7133.
* Source: Select Anywhere (0.0.0.0/0) for public access or restrict access to your specific IP for better security.
* Repeat this step for all three ports the application is using. Here I have 7133, 7511, 17222. These must match the values we had, when we run the app locally.
6. Configure **Inbound Security Group Rules** by selecting **Add Rule** and then setting the following details:
* Type: **Custom TCP**.
* Protocol: **TCP**.
* Port Range: **7133**.
* Source: Select **Anywhere (0.0.0.0/0)** for public access or restrict access to your specific IP for better security.

Repeat this step for all three ports that the application is using. This example demonstrates setup using ports 7133, 7511, and 17222. These must match the values that you have when you run the app locally.

The configuration should look as follows:
The configuration should look like:

![fig9](figures/09.png)

7. Launch an instance by clicking "Launch instance" button. You should see the green box with the Success label. This box also contains a link to the EC2 instance. Click it. It will take you to the instance dashboard, which looks like the one below:
7. Launch an instance by clicking the **Launch instance** button. You should see the green box with the **Success** label.

This box also contains a link to the EC2 instance. Click on it, and it takes you to the instance dashboard, as Figure 10 shows:

![fig10](figures/10.png)

### Deploy the application
Once the EC2 instance is ready, you can connect to it and deploy the application. Follow these steps to connect:
1. Locate the instance public IP (e.g. 98.83.137.101 in this case).
Once the EC2 instance is ready, you can connect to it, and deploy the application. Follow these steps to connect:

1. Locate the instance public IP (here this is 98.83.137.101).

2. Use an SSH client to connect:
* Open the terminal
* Set appropriate permissions for the key pair file (remember to use your IP address)
* Open the terminal.
* Set the appropriate permissions for the key pair file, using your own IP address:
```console
chmod 400 arm-key-pair.pem
ssh -i arm-key-pair.pem [email protected]
```

![fig11](figures/11.png)

You can now install required components, pull the application code from git, and launch the app:
You can now install the required components, pull the application code from git, and launch the app:
In the EC2 terminal run:
```console
sudo apt update && sudo apt upgrade -y
```

This will update the package list and upgrade the installed packages.
This updates the package list and upgrades the installed packages.

Install .NET SDK using the following commands:
```console
Expand All @@ -93,11 +104,11 @@ Verify the installation:
```console
dotnet --version
```
Install the Aspire workload using the dotnet CLI
Install the Aspire workload using the dotnet CLI:
```console
dotnet workload install aspire
```
Clone the repository which contains the application you created in the previous section:
Clone the repository that contains the application that you created in the previous section:
```console
git clone https://github.com/dawidborycki/NetAspire.Arm.git
cd NetAspire.Arm/
Expand All @@ -106,20 +117,20 @@ Trust the development certificate:
```console
dotnet dev-certs https --trust
```
Build and run the project
Build and run the project:
```console
dotnet restore
dotnet run --project NetAspire.Arm.AppHost
```

The application will run the same way as locally. You should see the following:
The application runs the same way as it does locally. You should see the following:

![fig12](figures/12.png)

Finally, open the application in the web browser (using the EC2's public IP):
Finally, open the application in the web browser, using the EC2's public IP:

![fig13](figures/13.png)

### Summary
You have successfully deployed the Aspire app onto an Arm-powered AWS EC2 instance. This demonstrates the compatibility of .NET applications with Arm architecture and AWS Graviton instances, offering high performance and cost-efficiency.
You have successfully deployed the Aspire app on to an Arm-powered AWS EC2 instance. This demonstrates the compatibility of .NET applications with Arm architecture and AWS Graviton instances, offering high performance and cost-efficiency.

Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
---
title: Background
title: .NET Aspire
weight: 2

### FIXED, DO NOT MODIFY
layout: learningpathall
---

### What is the .NET Aspire
.NET Aspire is a comprehensive suite of powerful tools, templates, and packages designed to simplify the development of cloud-native applications using the .NET platform. Delivered through a collection of NuGet packages, .NET Aspire addresses specific cloud-native concerns, enabling developers to build observable and production-ready apps efficiently.
### What is .NET Aspire?
.NET Aspire is a comprehensive suite of powerful tools, templates, and packages designed to simplify the development of cloud-native applications using the .NET platform. Delivered through a collection of NuGet packages, .NET Aspire provides solutions for building cloud-native apps, enabling developers to build observable and production-ready projects efficiently.

Cloud-native applications are typically composed of small, interconnected services or microservices rather than a single monolithic codebase. These applications often consume a variety of services such as databases, messaging systems, and caching mechanisms. With .NET Aspire you get a consistent set of tools and patterns that help you build and run distributed applications, taking full advantage of the scalability, resilience, and manageability of cloud infrastructures.
Cloud-native applications are typically composed of small, interconnected services or microservices, rather than a single monolithic codebase. These applications often consume a variety of services such as:

.NET Aspire enhances the local development experience by simplifying the management of your application's configuration and interconnections. It abstracts low-level implementation details, streamlining the setup of service discovery, environment variables, and container configurations. Specifically, with a few helper method calls, you can create local resources (like a Redis container), wait for them to become available, and configure appropriate connection strings in your projects.
* Databases.
* Messaging systems.
* Caching mechanisms.

.NET Aspire offers integrations for popular services like Redis and PostgreSQL, ensuring standardized interfaces and seamless connections with your app. These integrations handle cloud-native concerns such as health checks and telemetry through consistent configuration patterns. By referencing named resources, configurations are injected automatically, simplifying the process of connecting services.
.NET Aspire gives you a consistent set of tools and patterns that help you to build and run distributed applications, taking full advantage of the scalability, resilience, and manageability of cloud infrastructures.

.NET Aspire provides project templates that include boilerplate code and configurations common to cloud-native apps, such as telemetry, health checks, and service discovery. It offers tooling experiences for Visual Studio, Visual Studio Code, and the .NET CLI to help you create and interact with .NET Aspire projects. The templates come with defaults to help you get started quickly, reducing setup time and increasing productivity.
.NET Aspire enhances the local development experience by simplifying the management of your application's configuration and interconnections. It abstracts low-level implementation details, and streamlines the following:

By providing a consistent set of tools and patterns, .NET Aspire streamlines the development process of cloud-native applications. It manages complex applications during the development phase without dealing with low-level implementation details. .NET Aspire easily connects to commonly used services with standardized interfaces and configurations. There are also various templates and tooling to accelerate project setup and development cycles. Finally, with .NET Aspire, you can create applications that are ready for production with built-in support for telemetry, health checks, and service discovery.
* The setup of service discovery.
* Environment variables.
* Container configurations.

In this Learning Path, you will learn how to create a .NET Aspire application, describe the project, and modify the code on a Windows on Arm development machine. You will then deploy the application to AWS and GCP Arm-powered virtual machines.
With a few helper method calls, you can create local resources, wait for the resources to become available, and then configure appropriate connection strings in your projects.

.NET Aspire offers integrations for popular services like Redis and PostgreSQL, ensuring standardized interfaces and seamless connections with your app. These integrations handle specific cloud-native requirements through consistent configuration patterns. By referencing named resources, configurations are injected automatically, simplifying the process of connecting services.

.NET Aspire provides project templates that include boilerplate code and configurations common to cloud-native apps, such as health checks and telemetry, as well as service discovery. It offers tooling experiences for Visual Studio, Visual Studio Code, and .NET CLI to help you create and interact with .NET Aspire projects. The templates come with default settings that you can use to get started quickly, which reduces setup time and increases productivity.

By providing a consistent set of tools and patterns, .NET Aspire streamlines the development process of cloud-native applications. It manages complex applications during the development phase without dealing with low-level implementation details. .NET Aspire easily connects to commonly-used services with standardized interfaces and configurations. There are also various templates and tooling to accelerate project setup and development cycles.

In this Learning Path, you will learn how to create a .NET Aspire application, describe the project, and modify the code on a Windows on Arm development machine. You will then deploy the application:

* Firstly, to an AWS Arm-powered virtual machine.
* Secondly, to a GCP Arm-powered virtual machine.
Loading

0 comments on commit 24a9e47

Please sign in to comment.