Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ description: Configure HTTPS endpoints and certificate trust for Aspire resource

import { Aside, Tabs, TabItem } from '@astrojs/starlight/components';
import OsAwareTabs from '@components/OsAwareTabs.astro';
import ApiReference from '@components/ApiReference.astro';

Aspire provides two complementary sets of certificate APIs:

1. **HTTPS endpoint APIs**: Configure the certificates that resources use for their own HTTPS endpoints (server authentication)
2. **Certificate trust APIs**: Configure which certificates resources trust when making outbound HTTPS connections (client authentication)

Both sets of APIs work together to enable secure HTTPS communication during local development. For example, a Vite frontend might use `WithHttpsDeveloperCertificate` to serve HTTPS traffic, while also using `WithDeveloperCertificateTrust` to trust the dashboard's <abbr title="OpenTelemetry Protocol" data-tooltip-placement="top">OTLP</abbr> endpoint certificate.
Both sets of APIs work together to enable secure HTTPS communication during local development. For example, a Vite frontend might use <ApiReference name="Aspire.Hosting.ResourceBuilderExtensions.WithHttpsDeveloperCertificate" /> to serve HTTPS traffic, while also using <ApiReference name="Aspire.Hosting.ResourceBuilderExtensions.WithDeveloperCertificateTrust" /> to trust the dashboard's <abbr title="OpenTelemetry Protocol" data-tooltip-placement="top">OTLP</abbr> endpoint certificate.

<Aside type="caution">
Certificate customization only applies at run time. Custom certificates aren't
Expand Down Expand Up @@ -151,7 +152,7 @@ HTTPS endpoint configuration determines which certificate a resource presents wh

### Default behavior

For resources that have a certificate configuration defined with `WithHttpsCertificateConfiguration`, Aspire attempts to configure it to use the development certificate if available. This automatic configuration works for many common resource types including YARP, Redis, and Keycloak containers; Vite based JavaScript apps; and Python apps using Uvicorn.
For resources that have a certificate configuration defined with <ApiReference name="Aspire.Hosting.ResourceBuilderExtensions.WithHttpsCertificateConfiguration" />, Aspire attempts to configure it to use the development certificate if available. This automatic configuration works for many common resource types including YARP, Redis, and Keycloak containers; Vite based JavaScript apps; and Python apps using Uvicorn.

You can control this behavior using the HTTPS endpoint APIs described below.

Expand Down Expand Up @@ -291,7 +292,7 @@ await builder.build().run();
</TabItem>
</Tabs>

Use `WithoutHttpsCertificate` when:
Use <ApiReference name="Aspire.Hosting.ResourceBuilderExtensions.WithoutHttpsCertificate" /> when:

- The resource doesn't support HTTPS
- You want to manually configure certificates
Expand Down Expand Up @@ -480,7 +481,7 @@ In the preceding example, the certificate bundle is created with custom certific

Certificate trust scopes control how custom certificates interact with a resource's default trusted certificates. Different scopes provide flexibility in managing certificate trust based on your application's requirements.

The `WithCertificateTrustScope` API accepts a `CertificateTrustScope` value to specify the trust behavior.
The <ApiReference name="Aspire.Hosting.ResourceBuilderExtensions.WithCertificateTrustScope" /> API accepts a `CertificateTrustScope` value to specify the trust behavior.

#### Available trust scopes

Expand Down Expand Up @@ -677,7 +678,7 @@ Default implementations are provided for Node.js, Python, and container resource

#### Configure container certificate paths

For container resources, you can customize where certificates are stored and accessed using `WithContainerCertificatePaths`:
For container resources, you can customize where certificates are stored and accessed using <ApiReference name="Aspire.Hosting.ContainerResourceBuilderExtensions.WithContainerCertificatePaths" />:

```csharp title="AppHost.cs"
var builder = DistributedApplication.CreateBuilder(args);
Expand Down
9 changes: 5 additions & 4 deletions src/frontend/src/content/docs/app-host/container-files.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ description: Inject files and directories into Aspire container resources at dev
---

import { Aside, Tabs, TabItem } from '@astrojs/starlight/components';
import ApiReference from '@components/ApiReference.astro';

Aspire provides APIs to inject files and directories into containers, enabling you to configure containerized resources with custom configuration files, scripts, certificates, and other assets. There are two complementary APIs:

- **`WithContainerFiles`**: Injects files into containers at development time when they start during `aspire run`.
- **`PublishWithContainerFiles`**: Copies files from one resource's container into another resource's container as build artifacts at publish time during `aspire publish`.
- <ApiReference name="Aspire.Hosting.ContainerResourceBuilderExtensions.WithContainerFiles" />: Injects files into containers at development time when they start during `aspire run`.
- <ApiReference name="Aspire.Hosting.ResourceBuilderExtensions.PublishWithContainerFiles" />: Copies files from one resource's container into another resource's container as build artifacts at publish time during `aspire publish`.

## Inject files at development time

Expand Down Expand Up @@ -417,7 +418,7 @@ This produces a self-contained Nginx container that serves the frontend applicat

### Customize the source path

By default, the source resource exports files from its container based on its configured output paths. Use `WithContainerFilesSource` to specify which path inside the source container to copy from:
By default, the source resource exports files from its container based on its configured output paths. Use <ApiReference name="Aspire.Hosting.ResourceBuilderExtensions.WithContainerFilesSource" /> to specify which path inside the source container to copy from:

<Tabs syncKey='aspire-lang'>
<TabItem id='csharp' label='C#'>
Expand All @@ -436,7 +437,7 @@ The `withContainerFiles` API is not yet available in the TypeScript AppHost SDK.
</TabItem>
</Tabs>

Use `ClearContainerFilesSources` to remove any previously configured source paths before adding new ones.
Use <ApiReference name="Aspire.Hosting.ResourceBuilderExtensions.ClearContainerFilesSources" /> to remove any previously configured source paths before adding new ones.

## See also

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ description: Configure container registries for Aspire — generic registries, D

import { Aside, Steps, Tabs, TabItem } from '@astrojs/starlight/components';
import LearnMore from '@components/LearnMore.astro';
import ApiReference from '@components/ApiReference.astro';

Aspire 13.1 introduced explicit container registry configuration, giving developers control over where and when container images are pushed during deployment. This article explains how to configure container registries for your Aspire applications.

Expand All @@ -24,7 +25,7 @@ When deploying Aspire applications to production environments, your containerize
This API is experimental and may change in future releases. Use diagnostic code `ASPIRECOMPUTE003` to suppress the experimental warning. For more information, see [ASPIRECOMPUTE003](/diagnostics/aspirecompute003/).
</Aside>

Use the `AddContainerRegistry` method to configure a generic container registry for your application. This works with any Docker-compatible registry including DockerHub, GitHub Container Registry, Harbor, and private registries.
Use the <ApiReference name="Aspire.Hosting.ContainerRegistryResourceBuilderExtensions.AddContainerRegistry" /> method to configure a generic container registry for your application. This works with any Docker-compatible registry including DockerHub, GitHub Container Registry, Harbor, and private registries.

### Basic usage

Expand Down Expand Up @@ -303,7 +304,7 @@ In the preceding example:

### Using an existing ACR

To use an existing Azure Container Registry, call the `PublishAsExisting` method when you add the ACR:
To use an existing Azure Container Registry, call the <ApiReference name="Aspire.Hosting.ExistingAzureResourceExtensions.PublishAsExisting" /> method when you add the ACR:

<Tabs syncKey='aspire-lang'>
<TabItem id='csharp' label='C#'>
Expand Down
13 changes: 7 additions & 6 deletions src/frontend/src/content/docs/app-host/eventing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ description: Use the Aspire AppHost eventing APIs for lifecycle events, custom e

import { Aside, Steps, Tabs, TabItem } from '@astrojs/starlight/components';
import LearnMore from '@components/LearnMore.astro';
import ApiReference from '@components/ApiReference.astro';

In Aspire, eventing allows you to publish and subscribe to events during various AppHost life cycles. Eventing is more flexible than life cycle events. Both let you run arbitrary code during event callbacks, but eventing offers finer control of event timing, publishing, and provides supports for custom events.

Expand Down Expand Up @@ -110,7 +111,7 @@ builder.Eventing.Subscribe<AfterResourcesCreatedEvent>(
`builder.Eventing.Subscribe<TEvent>()` API. Use the named callback APIs
generated for each supported event, such as `subscribeBeforeStart`,
`subscribeAfterResourcesCreated`, `addEventingSubscriber`, and resource
callbacks like `onResourceReady`.
callbacks like <ApiReference name="Aspire.Hosting.DistributedApplicationEventingExtensions.OnResourceReady" />.
</Aside>

<Aside type="caution">
Expand Down Expand Up @@ -278,12 +279,12 @@ The preceding code subscribes to the `InitializeResourceEvent`, `ResourceReadyEv
and `await event.services()` when you need the resource or service provider.
</Aside>

- `OnInitializeResource` / `onInitializeResource`: Subscribes to the `InitializeResourceEvent`.
- `OnResourceEndpointsAllocated` / `onResourceEndpointsAllocated`: Subscribes to the `ResourceEndpointsAllocatedEvent` event.
- `OnConnectionStringAvailable` / `onConnectionStringAvailable`: Subscribes to the `ConnectionStringAvailableEvent` event.
- `OnBeforeResourceStarted` / `onBeforeResourceStarted`: Subscribes to the `BeforeResourceStartedEvent` event.
- <ApiReference name="Aspire.Hosting.DistributedApplicationEventingExtensions.OnInitializeResource" />: Subscribes to the `InitializeResourceEvent`.
- <ApiReference name="Aspire.Hosting.DistributedApplicationEventingExtensions.OnResourceEndpointsAllocated" />: Subscribes to the `ResourceEndpointsAllocatedEvent` event.
- <ApiReference name="Aspire.Hosting.DistributedApplicationEventingExtensions.OnConnectionStringAvailable" />: Subscribes to the `ConnectionStringAvailableEvent` event.
- <ApiReference name="Aspire.Hosting.DistributedApplicationEventingExtensions.OnBeforeResourceStarted" />: Subscribes to the `BeforeResourceStartedEvent` event.
- `OnResourceReady` / `onResourceReady`: Subscribes to the `ResourceReadyEvent` event.
- `OnResourceStopped` / `onResourceStopped`: Subscribes to the `ResourceStoppedEvent` event.
- <ApiReference name="Aspire.Hosting.DistributedApplicationEventingExtensions.OnResourceStopped" />: Subscribes to the `ResourceStoppedEvent` event.

When the AppHost is run, by the time the Aspire dashboard is displayed, you should see the following log output in the console:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ description: Host external executable applications in your Aspire AppHost using
---

import { Aside, Steps, Tabs, TabItem } from '@astrojs/starlight/components';
import ApiReference from '@components/ApiReference.astro';

In Aspire, you can host external executable applications alongside your projects using the `AddExecutable` method. This capability is useful when you need to integrate executable applications or tools into your distributed application, such as Node.js applications, Python scripts, or specialized CLI tools.
In Aspire, you can host external executable applications alongside your projects using the <ApiReference name="Aspire.Hosting.ExecutableResourceBuilderExtensions.AddExecutable" /> method. This capability is useful when you need to integrate executable applications or tools into your distributed application, such as Node.js applications, Python scripts, or specialized CLI tools.

## When to use executable resources

Expand Down Expand Up @@ -122,7 +123,7 @@ const app = await builder.addExecutable("worker", "python", ".", ["worker.py"])
</TabItem>
</Tabs>

When one resource depends on another, `WithReference` passes along environment variables containing the dependent resource's connection details. For example, the `worker` executable's reference to `redis` and `postgres` provides it with the `ConnectionStrings__cache` and `ConnectionStrings__appdb` environment variables, which contain connection strings to these resources.
When one resource depends on another, <ApiReference name="Aspire.Hosting.ResourceBuilderExtensions.WithReference" /> passes along environment variables containing the dependent resource's connection details. For example, the `worker` executable's reference to `redis` and `postgres` provides it with the `ConnectionStrings__cache` and `ConnectionStrings__appdb` environment variables, which contain connection strings to these resources.

### Access specific endpoint information

Expand Down Expand Up @@ -282,7 +283,7 @@ When upgrading to Aspire 13.3, replace every earlier per-kind environment helper

## Publishing with PublishAsDockerFile

For production deployment, executable resources need to be containerized. Use the `PublishAsDockerFile` method to specify how the executable should be packaged:
For production deployment, executable resources need to be containerized. Use the <ApiReference name="Aspire.Hosting.ExecutableResourceBuilderExtensions.PublishAsDockerFile" /> method to specify how the executable should be packaged:

<Tabs syncKey='aspire-lang'>
<TabItem id='csharp' label='C#'>
Expand Down Expand Up @@ -353,7 +354,7 @@ When working with executable resources:

1. **Use explicit paths**: For better reliability, use full paths to executables when possible.
1. **Handle dependencies**: Use `WithReference` to establish proper dependency relationships.
1. **Configure explicit start**: Use `WithExplicitStart()` for executables that shouldn't start automatically.
1. **Configure explicit start**: Use <ApiReference name="Aspire.Hosting.ResourceBuilderExtensions.WithExplicitStart" /> for executables that shouldn't start automatically.
1. **Prepare for deployment**: Always use `PublishAsDockerFile()` for production scenarios.
1. **Environment isolation**: Use environment variables rather than command-line arguments for sensitive configuration.
1. **Resource naming**: Use descriptive names that clearly identify the executable's purpose.
Expand Down
Loading
Loading