Skip to content

Commit

Permalink
Add all xref possible and cleanup (#56)
Browse files Browse the repository at this point in the history
* Add all xref possible and cleanup

* Fix link

* Add missing xref
  • Loading branch information
IEvangelist authored Nov 15, 2023
1 parent 8e47102 commit 6e1516a
Show file tree
Hide file tree
Showing 30 changed files with 224 additions and 215 deletions.
3 changes: 1 addition & 2 deletions docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
"resource": [
{
"files": [
"docs/media/**",
"**/media/**",
"**/docs/media/dotnet-aspire-logo.png",
"**/*.png",
"**/*.svg",
"**/*.jpg",
Expand Down
53 changes: 26 additions & 27 deletions docs/app-host-overview.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
title: .NET Aspire orchestration overview
description: Learn the fundamental concepts of .NET Aspire orchestration and explore the various APIs to express resource references.
ms.date: 11/13/2023
ms.date: 11/15/2023
ms.topic: overview
ms.prod: dotnet
---

# .NET Aspire orchestration overview
Expand All @@ -19,7 +18,7 @@ Before continuing, consider some common terminology used in .NET Aspire:

## Define the app model

.NET Aspire empowers you to seamlessly build, provision, deploy, configure, test, run, and observe your cloud application. This is achieved through the utilization of an _app model_ that outlines the resources in your app and their relationships. These resources encompass projects, executables, containers, as well as external services and cloud resources that your app depends on. Within every .NET Aspire app, there is a designated [App host project](#app-host-project), where the app model is precisely defined using methods available on the `IDistributedApplicationBuilder`. This builder is obtained by invoking `DistributedApplication.CreateBuilder(args)`.
.NET Aspire empowers you to seamlessly build, provision, deploy, configure, test, run, and observe your cloud application. This is achieved through the utilization of an _app model_ that outlines the resources in your app and their relationships. These resources encompass projects, executables, containers, as well as external services and cloud resources that your app depends on. Within every .NET Aspire app, there is a designated [App host project](#app-host-project), where the app model is precisely defined using methods available on the <xref:Aspire.Hosting.IDistributedApplicationBuilder>. This builder is obtained by invoking <xref:Aspire.Hosting.DistributedApplication.CreateBuilder%2A?displayProperty=nameWithType>.

## App host project

Expand Down Expand Up @@ -51,13 +50,13 @@ Each resource must be uniquely named. This diagram shows each resource and the r

| Method | Resource type | Description |
|--|--|--|
| `AddProject` | `ProjectResource` | A .NET project, for example ASP.NET Core web apps. |
| `AddContainer` | `ContainerResource` | A container image, such as a Docker image. |
| `AddExecutable` | `ExecutableResource` | An executable file. |
| <xref:Aspire.Hosting.ProjectResourceBuilderExtensions.AddProject%2A> | <xref:Aspire.Hosting.ApplicationModel.ProjectResource> | A .NET project, for example ASP.NET Core web apps. |
| <xref:Aspire.Hosting.ContainerResourceBuilderExtensions.AddContainer%2A> | <xref:Aspire.Hosting.ApplicationModel.ContainerResource> | A container image, such as a Docker image. |
| <xref:Aspire.Hosting.ExecutableResourceBuilderExtensions.AddExecutable%2A> | <xref:Aspire.Hosting.ApplicationModel.ExecutableResource> | An executable file. |

Project resources are .NET projects that are part of the app model. When you add a project reference to the app host project, the app host generates a type in the `Projects` namespace for each referenced project.

To add a project to the app model, use the `AddProject` method:
To add a project to the app model, use the <xref:Aspire.Hosting.ProjectResourceBuilderExtensions.AddProject%2A> method:

```csharp
// Adds the project "apiservice" of type "Projects.AspireApp_ApiService".
Expand All @@ -75,7 +74,7 @@ builder.AddProject<Projects.AspireApp_Web>("webfrontend")
.WithReference(cache);
```

The "webfrontend" project resource uses `WithReference` to add a dependency on the "cache" container resource. These dependencies can represent connection strings or service discovery information. In the preceding example, an environment variable is injected into the "webfronend" resource with the name `ConnectionStrings__cache`. This environment variable contains a connection string that the webfrontend can use to connect to redis via the .NET Aspire Redis component, for example, `ConnectionStrings__cache="localhost:6379"`.
The "webfrontend" project resource uses <xref:Aspire.Hosting.ResourceBuilderExtensions.WithReference%2A> to add a dependency on the "cache" container resource. These dependencies can represent connection strings or service discovery information. In the preceding example, an environment variable is injected into the "webfronend" resource with the name `ConnectionStrings__cache`. This environment variable contains a connection string that the webfrontend can use to connect to redis via the .NET Aspire Redis component, for example, `ConnectionStrings__cache="localhost:6379"`.

### Connection string and endpoint references

Expand All @@ -100,7 +99,7 @@ Project-to-project references are handled differently than resources that have w

Adding a reference to the "apiservice" project results in service discovery environment variables being added to the front-end. This is because typically, project to project communication occurs over HTTP/gRPC. For more information, see [.NET Aspire service discovery](service-discovery/overview.md).

It's possible to get specific endpoints from a container or executable using the `GetEndpoint` method:
It's possible to get specific endpoints from a container or executable using the <xref:Aspire.Hosting.ResourceBuilderExtensions.WithServiceBinding%2A> and calling the <xref:Aspire.Hosting.ApplicationModel.IResourceWithBindings.GetEndpoint%2A>:

```csharp
var customContainer = builder.AddContainer("myapp", "mycustomcontainer")
Expand All @@ -118,34 +117,34 @@ var apiservice = builder.AddProject<Projects.AspireApp_ApiService>("apiservice")

### APIs for adding and expressing resources

Beyond the base resource types, `ProjectResource`, `ContainerResource`, and `ExecutableResource`, .NET Aspire provides extension methods to add common resources to your app model. The following table lists the methods and their corresponding resource types:
Beyond the base resource types, <xref:Aspire.Hosting.ApplicationModel.ProjectResource>, <xref:Aspire.Hosting.ApplicationModel.ContainerResource>, and <xref:Aspire.Hosting.ApplicationModel.ExecutableResource>, .NET Aspire provides extension methods to add common resources to your app model. The following table lists the methods and their corresponding resource types:

**Cloud-agnostic resources available in the [📦 Aspire.Hosting](https://www.nuget.org/packages/Aspire.Hosting) NuGet package (available by default in .NET Aspire templates with the AppHost project):**

| Method | Resource type | Description |
|--|--|--|
| `AddPostgresConnection` | `PostgresConnectionResource` | Adds a Postgres connection resource. |
| `AddPostgresContainer` | `PostgresContainerResource` | Adds a Postgres container resource. |
| `AddPostgresContainer(...).AddDatabase` | `PostgresDatabaseResource` | Adds a Postgres database resource. |
| `AddRabbitMQConnection` | `RabbitMQConnectionResource` | Adds a RabbitMQ connection resource. |
| `AddRabbitMQContainer` | `RabbitMQContainerResource` | Adds a RabbitMQ container resource. |
| `AddRedisContainer` | `RedisContainerResource` | Adds a Redis container resource. |
| `AddSqlServerConnection` | `SqlServerConnectionResource` | Adds a SQL Server connection resource. |
| `AddSqlServerContainer` | `SqlServerContainerResource` | Adds a SQL Server container resource. |
| `AddSqlServerContainer(...).AddDatabase` | `SqlServerDatabaseResource` | Adds a SQL Server database resource. |
| <xref:Aspire.Hosting.PostgresBuilderExtensions.AddPostgresConnection%2A> | <xref:Aspire.Hosting.ApplicationModel.PostgresConnectionResource> | Adds a Postgres connection resource. |
| <xref:Aspire.Hosting.PostgresBuilderExtensions.AddPostgresContainer%2A> | <xref:Aspire.Hosting.ApplicationModel.PostgresContainerResource> | Adds a Postgres container resource. |
| `AddPostgresContainer(...).`<xref:Aspire.Hosting.PostgresBuilderExtensions.AddDatabase%2A> | <xref:Aspire.Hosting.ApplicationModel.PostgresDatabaseResource> | Adds a Postgres database resource. |
| <xref:Aspire.Hosting.RabbitMQBuilderExtensions.AddRabbitMQConnection%2A> | <xref:Aspire.Hosting.ApplicationModel.RabbitMQConnectionResource> | Adds a RabbitMQ connection resource. |
| <xref:Aspire.Hosting.RabbitMQBuilderExtensions.AddRabbitMQContainer%2A> | <xref:Aspire.Hosting.ApplicationModel.RabbitMQContainerResource> | Adds a RabbitMQ container resource. |
| <xref:Aspire.Hosting.RedisBuilderExtensions.AddRedisContainer%2A> | <xref:Aspire.Hosting.ApplicationModel.RedisContainerResource> | Adds a Redis container resource. |
| <xref:Aspire.Hosting.SqlServerBuilderExtensions.AddSqlServerConnection%2A> | <xref:Aspire.Hosting.ApplicationModel.SqlServerConnectionResource> | Adds a SQL Server connection resource. |
| <xref:Aspire.Hosting.SqlServerBuilderExtensions.AddSqlServerContainer%2A> | <xref:Aspire.Hosting.ApplicationModel.SqlServerContainerResource> | Adds a SQL Server container resource. |
| `AddSqlServerContainer(...).`<xref:Aspire.Hosting.SqlServerBuilderExtensions.AddDatabase%2A> | <xref:Aspire.Hosting.ApplicationModel.SqlServerDatabaseResource> | Adds a SQL Server database resource. |

**Azure specific resources available in the [📦 Aspire.Hosting.Azure](https://www.nuget.org/packages/Aspire.Hosting.Azure) NuGet package:**

| Method | Resource type | Description |
|--|--|--|
| `AddAzureStorage` | `AzureStorageResource` | Adds an Azure Storage resource. |
| `AddAzureStorage(...).AddBlobs` | `AzureBlobStorageResource` | Adds an Azure Blob Storage resource. |
| `AddAzureStorage(...).AddQueues` | `AzureQueueStorageResource` | Adds an Azure Queue Storage resource. |
| `AddAzureStorage(...).AddTables` | `AzureTableStorageResource` | Adds an Azure Table Storage resource. |
| `AddAzureCosmosDB` | `AzureCosmosDBResource` | Adds an Azure Cosmos DB resource. |
| `AddAzureKeyVault` | `AzureKeyVaultResource` | Adds an Azure Key Vault resource. |
| `AddAzureRedisResource` | `AzureRedisResource` | Adds an Azure Redis resource. |
| `AddAzureServiceBus` | `AzureServiceBusResource` | Adds an Azure Service Bus resource. |
| <xref:Aspire.Hosting.AzureResourceExtensions.AddAzureStorage%2A> | <xref:Aspire.Hosting.ApplicationModel.AzureStorageResource> | Adds an Azure Storage resource. |
| `AddAzureStorage(...).`<xref:Aspire.Hosting.AzureResourceExtensions.AddBlobs%2A> | <xref:Aspire.Hosting.ApplicationModel.AzureBlobStorageResource> | Adds an Azure Blob Storage resource. |
| `AddAzureStorage(...).`<xref:Aspire.Hosting.AzureResourceExtensions.AddQueues%2A> | <xref:Aspire.Hosting.ApplicationModel.AzureQueueStorageResource> | Adds an Azure Queue Storage resource. |
| `AddAzureStorage(...).`<xref:Aspire.Hosting.AzureResourceExtensions.AddTables%2A> | <xref:Aspire.Hosting.ApplicationModel.AzureTableStorageResource> | Adds an Azure Table Storage resource. |
| <xref:Aspire.Hosting.AzureCosmosDBCloudApplicationBuilderExtensions.AddAzureCosmosDB%2A> | <xref:Aspire.Hosting.Azure.Data.Cosmos.AzureCosmosDBResource> | Adds an Azure Cosmos DB resource. |
| <xref:Aspire.Hosting.AzureResourceExtensions.AddAzureKeyVault%2A> | <xref:Aspire.Hosting.ApplicationModel.AzureKeyVaultResource> | Adds an Azure Key Vault resource. |
| <xref:Aspire.Hosting.AzureResourceExtensions.AddAzureRedis%2A> | <xref:Aspire.Hosting.ApplicationModel.AzureRedisResource> | Adds an Azure Redis resource. |
| <xref:Aspire.Hosting.AzureResourceExtensions.AddAzureServiceBus%2A> | <xref:Aspire.Hosting.ApplicationModel.AzureServiceBusResource> | Adds an Azure Service Bus resource. |

## See also

Expand Down
9 changes: 4 additions & 5 deletions docs/caching/quickstart-caching.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
title: Implement caching with .NET Aspire components
description: Learn how to connect to Redis and cache data using .NET Aspire components.
ms.date: 11/11/2023
ms.date: 11/15/2023
ms.topic: quickstart
ms.prod: dotnet
---

# Quickstart: Implement caching with .NET Aspire components
Expand Down Expand Up @@ -50,7 +49,7 @@ Visual Studio creates a new .NET Aspire solution that consists of the following
dotnet add package Aspire.StackExchange.Redis.OutputCaching --prerelease
```

1. In the _Program.cs_ file of the `AspireRedis.Web` Blazor project, immediately after the line `var builder = WebApplication.CreateBuilder(args);`, add a call to the `AddRedisOutputCache` extension method:
1. In the _Program.cs_ file of the `AspireRedis.Web` Blazor project, immediately after the line `var builder = WebApplication.CreateBuilder(args);`, add a call to the <xref:Microsoft.Extensions.Hosting.AspireRedisOutputCacheExtensions.AddRedisOutputCache%2A> extension method:

```csharp
builder.AddRedisOutputCache("cache");
Expand Down Expand Up @@ -86,13 +85,13 @@ dotnet add package Aspire.StackExchange.Redis.OutputCaching --prerelease

## Configure the API with distributed caching

1. Add the [.NET Aspire StackExchange Redis distributed caching](/aspire/caching/stackexchange-redis-distributed-caching-component) component packages to your `AspireStorage` app:
1. Add the [.NET Aspire StackExchange Redis distributed caching](/aspire/caching/stackexchange-redis-distributed-caching-component) component packages to your `AspireRedis` app:

```dotnetcli
dotnet add package Aspire.StackExchange.Redis.DistributedCaching --prerelease
```

1. Towards the top of the _Program.cs_ file, add a call to `AddRedisDistributedCache`:
1. Towards the top of the _Program.cs_ file, add a call to <xref:Microsoft.Extensions.Hosting.AspireRedisDistributedCacheExtensions.AddRedisDistributedCache%2A>:

```csharp
builder.AddRedisDistributedCache("cache");
Expand Down
8 changes: 4 additions & 4 deletions docs/caching/stackexchange-redis-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: .NET Aspire StackExchange Redis component
description: This article describes the .NET Aspire StackExchange Redis component features and capabilities
ms.topic: how-to
ms.date: 11/11/2023
ms.date: 11/15/2023
---

# .NET Aspire StackExchange Redis component
Expand Down Expand Up @@ -32,7 +32,7 @@ For more information, see [dotnet add package](/dotnet/core/tools/dotnet-add-pac

## Example usage

In the _Program.cs_ file of your project, call the `AddRedis` extension to register a `IConnectionMultiplexer` for use via the dependency injection container.
In the _Program.cs_ file of your project, call the <xref:Aspire.Hosting.RedisBuilderExtensions.AddRedis%2A> extension to register a `IConnectionMultiplexer` for use via the dependency injection container.

```csharp
builder.AddRedis("cache");
Expand Down Expand Up @@ -73,7 +73,7 @@ For more information on how to format this connection string, see the [StackExch

### Use configuration providers

The .NET Aspire StackExchange Redis component supports <xref:Microsoft.Extensions.Configuration?displayProperty=fullName>. It loads the `StackExchangeRedisSettings` from configuration by using the `Aspire:StackExchange:Redis` key. Example `appsettings.json` that configures some of the options:
The .NET Aspire StackExchange Redis component supports <xref:Microsoft.Extensions.Configuration?displayProperty=fullName>. It loads the <xref:Aspire.StackExchange.Redis.StackExchangeRedisSettings> from configuration by using the `Aspire:StackExchange:Redis` key. Example `appsettings.json` that configures some of the options:

```json
{
Expand Down Expand Up @@ -115,7 +115,7 @@ builder.AddProject<Projects.ExampleProject>()
.WithReference(redis)
```

The `WithReference` method configures a connection in the `ExampleProject` project named `redis`. In the _Program.cs_ file of `ExampleProject`, the Redis connection can be consumed using:
The <xref:Aspire.Hosting.ResourceBuilderExtensions.WithReference%2A> method configures a connection in the `ExampleProject` project named `redis`. In the _Program.cs_ file of `ExampleProject`, the Redis connection can be consumed using:

```csharp
builder.AddRedis("cache");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
title: .NET Aspire StackExchange Redis distributed caching component
description: This article describes the .NET Aspire StackExchange Redis distributed caching component features and capabilities
ms.topic: how-to
ms.date: 11/10/2023
ms.date: 11/15/2023
---

# .NET Aspire StackExchange Redis distributed caching component

In this article, you learn how to use the .NET Aspire StackExchange Redis distributed caching component. The `Aspire.StackExchange.Redis.DistributedCaching` library is used to register an [IDistributedCache]<https://stackexchange.github.io/StackExchange.Redis/Basics>)provider for connecting to [Redis](https://redis.io/) server. It enables corresponding health checks, logging and telemetry.
In this article, you learn how to use the .NET Aspire StackExchange Redis distributed caching component. The `Aspire.StackExchange.Redis.DistributedCaching` library is used to register an [IDistributedCache]<https://stackexchange.github.io/StackExchange.Redis/Basics>) provider for connecting to [Redis](https://redis.io/) server. It enables corresponding health checks, logging and telemetry.

## Get started

Expand All @@ -32,7 +32,7 @@ For more information, see [dotnet add package](/dotnet/core/tools/dotnet-add-pac

## Example usage

In the _Program.cs_ file of your project, call the `AddRedisDistributedCache` extension to register the required services for distributed caching and add a <xref:Microsoft.Extensions.Caching.Distributed.IDistributedCache> for use via the dependency injection container.
In the _Program.cs_ file of your project, call the <xref:Microsoft.Extensions.Hosting.AspireRedisDistributedCacheExtensions.AddRedisDistributedCache%2A> extension to register the required services for distributed caching and add a <xref:Microsoft.Extensions.Caching.Distributed.IDistributedCache> for use via the dependency injection container.

```csharp
builder.AddRedisDistributedCache("cache");
Expand Down Expand Up @@ -73,7 +73,7 @@ For more information on how to format this connection string, see the [StackExch

### Use configuration providers

The .NET Aspire StackExchange Redis distributed caching component supports <xref:Microsoft.Extensions.Configuration?displayProperty=fullName>. It loads the `StackExchangeRedisSettings` from configuration by using the `Aspire:StackExchange:Redis` key. Example `appsettings.json` that configures some of the options:
The .NET Aspire StackExchange Redis distributed caching component supports <xref:Microsoft.Extensions.Configuration?displayProperty=fullName>. It loads the <xref:Aspire.StackExchange.Redis.StackExchangeRedisSettings> from configuration by using the `Aspire:StackExchange:Redis` key. Example `appsettings.json` that configures some of the options:

```json
{
Expand Down Expand Up @@ -112,7 +112,7 @@ builder.AddRedisDistributedCache(

## Orchestration

In your orchestrator project, register the .NET Aspire Stack Exchange Redis component and consume the service using the following methods:
In your orchestrator project, register the .NET Aspire Stack Exchange Redis component and consume the service using the following methods, such as <xref:Aspire.Hosting.RedisBuilderExtensions.AddRedisContainer%2A>:

```csharp
// Service registration
Expand All @@ -123,7 +123,7 @@ builder.AddProject<Projects.ExampleProject>()
.WithReference(redis)
```

The `WithReference` method configures a connection in the `ExampleProject` project named `redis`. In the _Program.cs_ file of `ExampleProject`, the Redis connection can be consumed using:
The <xref:Aspire.Hosting.ResourceBuilderExtensions.WithReference%2A> method configures a connection in the `ExampleProject` project named `redis`. In the _Program.cs_ file of `ExampleProject`, the Redis connection can be consumed using:

```csharp
builder.AddRedisDistributedCache("cache");
Expand Down
Loading

0 comments on commit 6e1516a

Please sign in to comment.