Skip to content

Commit

Permalink
Merge pull request #1809 from dotnet/main
Browse files Browse the repository at this point in the history
✅ Merge `main` into `live`
  • Loading branch information
dotnet-policy-service[bot] authored Oct 11, 2024
2 parents 9ad5b81 + e76fd22 commit c91f8a3
Show file tree
Hide file tree
Showing 11 changed files with 518 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
# The '*' pattern is global owners.

* @IEvangelist

# Community Toolkit docs

# /docs/community-toolkit/* @aaronpowell
2 changes: 2 additions & 0 deletions docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@
},
"author": {
"docs/**/*.*": "IEvangelist",
"docs/community-toolkit/**/*.*": "aaronpowell",
"docs/database/**/*.*": "CamSoper",
"docs/storage/**/*.*": "CamSoper",
"docs/deployment/**/*.*": "CamSoper"
},
"ms.author": {
"docs/**/*.*": "dapine",
"docs/community-toolkit/**/*.*": "aapowell",
"docs/database/**/*.*": "casoper",
"docs/storage/**/*.*": "casoper",
"docs/deployment/**/*.*": "casoper"
Expand Down
70 changes: 70 additions & 0 deletions docs/community-toolkit/hosting-azure-static-web-apps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: Azure Static Web Apps emulator
description: Learn how to use the .NET Aspire Azure Static Web Apps emulator integration to run Azure Static Web Apps locally using the emulator.
ms.date: 10/11/2024
---

# .NET Aspire Azure Static Web Apps emulator integration

[!INCLUDE [includes-hosting](../includes/includes-hosting.md)]

[!INCLUDE [banner](includes/banner.md)]

In this article, you learn how to use the .NET Aspire [Azure Static Web Apps emulator](/azure/static-web-apps/local-development) hosting integration to run Azure Static Web Apps locally using the emulator. The emulator provides support for proxying both the static frontend and the API backend using resources defined in the app host.

This integration requires the [Azure Static Web Apps CLI](/azure/static-web-apps/local-development#get-started) to run, and only supports hosting the emulator for local development, not deploying to Azure Static Web Apps.

## Hosting integration

To get started with the .NET Aspire Azure Static Web Apps emulator hosting integration, install the [📦 Aspire.CommunityToolkit.Hosting.Azure.StaticWebApps](https:/orgs/CommunityToolkit/packages/nuget/package/Aspire.CommunityToolkit.Hosting.Azure.StaticWebApps) NuGet package in the AppHost project.

### [.NET CLI](#tab/dotnet-cli)

```dotnetcli
dotnet add package Aspire.CommunityToolkit.Hosting.Azure.StaticWebApps
```

### [PackageReference](#tab/package-reference)

```xml
<PackageReference Include="Aspire.CommunityToolkit.Hosting.Azure.StaticWebApps"
Version="*" />
```

---

For more information, see [dotnet add package](/dotnet/core/tools/dotnet-add-package) or [Manage package dependencies in .NET applications](/dotnet/core/tools/dependencies).

## Example usage

In the _:::no-loc text="Program.cs":::_ file of your app host project, define the backend and frontend resources. Then, call the `AddSwaEmulator` method to create the emulator and pass the resources using the `WithAppResource` and `WithApiResource` methods.

```csharp
var builder = DistributedApplication.CreateBuilder(args);

// Define the API resource
var api = builder.AddProject<Projects.Aspire_CommunityToolkit_StaticWebApps_ApiApp>("api");

// Define the frontend resource
var web = builder
.AddNpmApp("web", Path.Combine("..", "Aspire.CommunityToolkit.StaticWebApps.WebApp"), "dev")
.WithHttpEndpoint(env: "PORT")
.WithExternalHttpEndpoints();

// Create a SWA emulator with the frontend and API resources
_ = builder
.AddSwaEmulator("swa")
.WithAppResource(web)
.WithApiResource(api);

builder.Build().Run();
```

The preceding code defines the API and frontend resources and creates an emulator with the resources. The emulator is then started using the `Run` method.

## See also

- [Azure Static Web Apps emulator](/azure/static-web-apps/local-development)
- [Azure Static Web Apps](/azure/static-web-apps/)
- [.NET Aspire Community Toolkit GitHub repo](https:/CommunityToolkit/Aspire)
- [Sample app source code](https:/CommunityToolkit/Aspire/tree/main/examples/swa)
50 changes: 50 additions & 0 deletions docs/community-toolkit/hosting-golang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: Go hosting
author: tommasodotNET
description: Learn how to use the .NET Aspire Go hosting integration to host Go applications.
ms.date: 10/11/2024
---

# .NET Aspire Go hosting

[!INCLUDE [includes-hosting](../includes/includes-hosting.md)]

[!INCLUDE [banner](includes/banner.md)]

In this article, you learn how to use the .NET Aspire Go hosting integration to host Go applications.

## Hosting integration

To get started with the .NET Aspire Go hosting integration, install the [📦 Aspire.CommunityToolkit.Hosting.Go](https:/orgs/CommunityToolkit/packages/nuget/package/Aspire.CommunityToolkit.Hosting.Golang) NuGet package in the AppHost project.

### [.NET CLI](#tab/dotnet-cli)

```dotnetcli
dotnet add package Aspire.CommunityToolkit.Hosting.Golang
```

### [PackageReference](#tab/package-reference)

```xml
<PackageReference Include="Aspire.CommunityToolkit.Hosting.Golang"
Version="*" />
```

---

For more information, see [dotnet add package](/dotnet/core/tools/dotnet-add-package) or [Manage package dependencies in .NET applications](/dotnet/core/tools/dependencies).

## Example usage

In the _:::no-loc text="Program.cs":::_ file of your app host project, call the `AddGolangApp` method to add a Go application to the builder.

```csharp
var golang = builder.AddGolangApp("golang", "../go-service");
```

The Go application can be added as a reference to other resources in the AppHost project.

## See also

- [.NET Aspire Community Toolkit GitHub repo](https:/CommunityToolkit/Aspire)
- [Sample Go app](https:/CommunityToolkit/Aspire/tree/main/examples/golang)
99 changes: 99 additions & 0 deletions docs/community-toolkit/hosting-java.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
title: Java/Spring hosting
author: justinyoo
description: A .NET Aspire hosting integration for hosting Java/Spring applications using either the Java runtime or a container.
ms.date: 10/11/2024
---

# .NET Aspire Java/Spring hosting integration

[!INCLUDE [includes-hosting](../includes/includes-hosting.md)]

[!INCLUDE [banner](includes/banner.md)]

In this article, you learn how to use the .NET Aspire Java/Spring hosting integration to host Java/Spring applications using either the Java runtime or a container.

## Prerequisites

This integration requires the [OpenTelemetry Agent for Java](https://opentelemetry.io/docs/zero-code/java/agent/) to be downloaded and placed in the `agents` directory in the root of the project. Depending on your preferred shell, use either of the following commands to download the agent:

# [Bash](#tab/bash)

```bash
# bash/zsh
mkdir -p ./agents
wget -P ./agents \
https:/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
```

# [PowerShell](#tab/powershell)

```powershell
# PowerShell
New-item -type Directory -Path ./agents -Force
Invoke-WebRequest `
-OutFile "./agents/opentelemetry-javaagent.jar" `
-Uri "https:/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar"
```

---

## Get started

To get started with the .NET Aspire Azure Static Web Apps emulator integration, install the [📦 Aspire.CommunityToolkit.Hosting.Java](https:/orgs/CommunityToolkit/packages/nuget/package/Aspire.CommunityToolkit.Hosting.Java) NuGet package in the AppHost project.

### [.NET CLI](#tab/dotnet-cli)

```dotnetcli
dotnet add package Aspire.CommunityToolkit.Hosting.Java
```

### [PackageReference](#tab/package-reference)

```xml
<PackageReference Include="Aspire.CommunityToolkit.Hosting.Java"
Version="*" />
```

---

For more information, see [dotnet add package](/dotnet/core/tools/dotnet-add-package) or [Manage package dependencies in .NET applications](/dotnet/core/tools/dependencies).

## Example Usage

The following sections detail various example usage scenarios, from hosting a containerized Spring app to hosting an executable Spring app.

### [Container hosting](#tab/container-hosting)

In the _:::no-loc text="Program.cs":::_file of your app host project, call the `AddSpringApp` method to define the containerized Spring app. Use the `JavaAppContainerResourceOptions` to define the containerized Spring app.

```csharp
var containerapp = builder.AddSpringApp(
"containerapp",
new JavaAppContainerResourceOptions
{
ContainerImageName = "<repository>/<image>",
OtelAgentPath = "<agent-path>"
});
```

### [Executable hosting](#tab/executable-hosting)

In the _:::no-loc text="Program.cs":::_ file of your AppHost project, call the `AddSpringApp` method to define the executable Spring app. Use the `JavaAppExecutableResourceOptions` to define the executable Spring app.

```csharp
var executableapp = builder.AddSpringApp(
"executableapp",
new JavaAppExecutableResourceOptions
{
ApplicationName = "target/app.jar",
OtelAgentPath = "../../../agents"
});
```

---

## See also

- [Java developer resources](/java)
- [.NET Aspire Community Toolkit GitHub repo](https:/CommunityToolkit/Aspire)
95 changes: 95 additions & 0 deletions docs/community-toolkit/hosting-nodejs-extensions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
title: Node.js hosting extensions
description: Learn about the .NET Aspire Community Toolkit Node.js hosting extensions package which provides extra functionality to the .NET Aspire NodeJS hosting package.
ms.date: 10/11/2024
---

# .NET Aspire Community Toolkit Node.js hosting extensions

[!INCLUDE [includes-hosting](../includes/includes-hosting.md)]

[!INCLUDE [banner](includes/banner.md)]

In this article, you learn about the .NET Aspire Community Toolkit Node.js hosting extensions package which provides extra functionality to the .NET Aspire [NodeJS hosting package](https://nuget.org/packages/Aspire.Hosting.NodeJS). The extensions package brings the following features:

- Running [Vite](https://vitejs.dev/) applications
- Running Node.js applications using [Yarn](https://yarnpkg.com/) and [pnpm](https://pnpm.io/)
- Ensuring that the packages are installed before running the application (using the specified package manager)

## Hosting integration

To get started with the .NET Aspire Community Toolkit Node.js hosting extensions, install the [📦 Aspire.CommunityToolkit.Hosting.NodeJS.Extensions](https:/orgs/CommunityToolkit/packages/nuget/package/Aspire.CommunityToolkit.Hosting.NodeJS.Extensions) NuGet package in the AppHost project.

### [.NET CLI](#tab/dotnet-cli)

```dotnetcli
dotnet add package Aspire.CommunityToolkit.Hosting.NodeJS.Extensions
```

### [PackageReference](#tab/package-reference)

```xml
<PackageReference Include="Aspire.CommunityToolkit.Hosting.NodeJS.Extensions"
Version="*" />
```

---

For more information, see [dotnet add package](/dotnet/core/tools/dotnet-add-package) or [Manage package dependencies in .NET applications](/dotnet/core/tools/dependencies).

## Example usage

The following sections detail various usages, from running Vite applications to using specific package managers.

### Run specific package managers

This integration extension adds support for running Node.js applications using Yarn or pnpm as the package manager.

# [yarn](#tab/yarn)

```csharp
var builder = DistributedApplication.CreateBuilder(args);

builder.AddYarnApp("yarn-demo")
.WithExternalHttpEndpoints();
```

# [pnpm](#tab/pnpm)

```csharp
var builder = DistributedApplication.CreateBuilder(args);

builder.AddPnpmApp("pnpm-demo")
.WithExternalHttpEndpoints();
```

---

### Run Vite apps

This integration extension adds support for running the development server for Vite applications. By default, it uses the `npm` package manager to launch, but this can be overridden with the `packageManager` argument.

```csharp
var builder = DistributedApplication.CreateBuilder(args);

builder.AddViteApp("vite-demo")
.WithExternalHttpEndpoints();

builder.AddViteApp("yarn-demo", packageManager: "yarn")
.WithExternalHttpEndpoints();

builder.AddViteApp("pnpm-demo", packageManager: "pnpm")
.WithExternalHttpEndpoints();

builder.Build().Run();
```

### Install packages

When using the `WithNpmPackageInstallation`, `WithYarnPackageInstallation` or `WithPnpmPackageInstallation` methods, the package manager is used to install the packages before starting the application. These methods are useful to ensure that packages are installed before the application starts, similar to how a .NET application would restore NuGet packages before running.

## See also

- [Orchestrate Node.js apps in .NET Aspire](../get-started/build-aspire-apps-with-nodejs.md)
- [.NET Aspire Community Toolkit GitHub repo](https:/CommunityToolkit/Aspire)
- [Sample Node.js apps](https:/CommunityToolkit/Aspire/tree/main/examples/nodejs-ext)
6 changes: 6 additions & 0 deletions docs/community-toolkit/includes/banner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
ms.topic: include
---

> [!NOTE]
> This integration is part of the [.NET Aspire Community Toolkit](https:/CommunityToolkit/Aspire) and _isn't_ officially supported by the .NET Aspire team.
Loading

0 comments on commit c91f8a3

Please sign in to comment.