Skip to content

✅ Merge main into live #887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 14, 2024
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
88 changes: 66 additions & 22 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ updates:
dotnet:
patterns:
- "*" # Prefer a single PR per solution update.
- package-ecosystem: "nuget"
directory: "/docs/frameworks/snippets/Orleans" #OrleansClientServer.sln
schedule:
interval: "weekly"
day: "wednesday"
open-pull-requests-limit: 5
groups:
# Group .NET updates together for solutions.
dotnet:
patterns:
- "*" # Prefer a single PR per solution update.
- package-ecosystem: "nuget"
directory: "/docs/fundamentals/snippets/components/AspireApp" #AspireApp.sln
schedule:
Expand Down Expand Up @@ -261,6 +272,61 @@ updates:
dotnet:
patterns:
- "*" # Prefer a single PR per project update.
- package-ecosystem: "nuget"
directory: "/docs/frameworks/snippets/Orleans/OrleansAppHost" #OrleansAppHost.csproj
schedule:
interval: "weekly"
day: "wednesday"
open-pull-requests-limit: 5
groups:
# Group .NET updates together for projects.
dotnet:
patterns:
- "*" # Prefer a single PR per project update.
- package-ecosystem: "nuget"
directory: "/docs/frameworks/snippets/Orleans/OrleansClient" #OrleansClient.csproj
schedule:
interval: "weekly"
day: "wednesday"
open-pull-requests-limit: 5
groups:
# Group .NET updates together for projects.
dotnet:
patterns:
- "*" # Prefer a single PR per project update.
- package-ecosystem: "nuget"
directory: "/docs/frameworks/snippets/Orleans/OrleansContracts" #OrleansContracts.csproj
schedule:
interval: "weekly"
day: "wednesday"
open-pull-requests-limit: 5
groups:
# Group .NET updates together for projects.
dotnet:
patterns:
- "*" # Prefer a single PR per project update.
- package-ecosystem: "nuget"
directory: "/docs/frameworks/snippets/Orleans/OrleansServer" #OrleansServer.csproj
schedule:
interval: "weekly"
day: "wednesday"
open-pull-requests-limit: 5
groups:
# Group .NET updates together for projects.
dotnet:
patterns:
- "*" # Prefer a single PR per project update.
- package-ecosystem: "nuget"
directory: "/docs/frameworks/snippets/Orleans/OrleansServiceDefaults" #OrleansServiceDefaults.csproj
schedule:
interval: "weekly"
day: "wednesday"
open-pull-requests-limit: 5
groups:
# Group .NET updates together for projects.
dotnet:
patterns:
- "*" # Prefer a single PR per project update.
- package-ecosystem: "nuget"
directory: "/docs/fundamentals/snippets/components/AspireApp/AspireApp.AppHost" #AspireApp.AppHost.csproj
schedule:
Expand Down Expand Up @@ -492,28 +558,6 @@ updates:
dotnet:
patterns:
- "*" # Prefer a single PR per project update.
- package-ecosystem: "nuget"
directory: "/docs/real-time/snippets/signalr/SignalR.AppHost" #SignalR.AppHost.csproj
schedule:
interval: "weekly"
day: "wednesday"
open-pull-requests-limit: 5
groups:
# Group .NET updates together for projects.
dotnet:
patterns:
- "*" # Prefer a single PR per project update.
- package-ecosystem: "nuget"
directory: "/docs/real-time/snippets/signalr/SignalR.ServiceDefaults" #SignalR.ServiceDefaults.csproj
schedule:
interval: "weekly"
day: "wednesday"
open-pull-requests-limit: 5
groups:
# Group .NET updates together for projects.
dotnet:
patterns:
- "*" # Prefer a single PR per project update.
- package-ecosystem: "nuget"
directory: "/docs/real-time/snippets/signalr/SignalR.Web" #SignalR.Web.csproj
schedule:
Expand Down
157 changes: 157 additions & 0 deletions docs/caching/caching-components-deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
---
title: Deploy a .NET Aspire app that connects to Redis Cache to Azure
description: Learn how to deploy a .NET Aspire app that connects to Redis Cache to Azure
ms.date: 05/12/2024
ms.topic: how-to
---

# Tutorial: Deploy a .NET Aspire app with a Redis Cache to Azure

In this tutorial, you learn to configure a .NET Aspire app with a Redis Cache for deployment to Azure. .NET Aspire provides multiple caching component configurations that provision different Redis services in Azure. You'll learn how to:

> [!div class="checklist"]
>
> - Configure the app to provision an Azure Cache for Redis
> - Configure the app to provision a containerized Redis Cache

> [!NOTE]
> This document focuses specifically on .NET Aspire configurations to provision and deploy Redis Cache resources in Azure. For more information and to learn more about the full .NET Aspire deployment process, see the [Azure Container Apps deployment](/dotnet/aspire/deployment/azure/aca-deployment?pivots=azure-azd) tutorial.

[!INCLUDE [aspire-prereqs](../includes/aspire-prereqs.md)]

## Create the sample solution

Follow the [Tutorial: Implement caching with .NET Aspire components](./caching-components.md) to create the sample project.

## Configure the app for Redis cache deployment

.NET Aspire provides two built-in configuration options to streamline Redis Cache deployment on Azure:

- Provision a containerized Redis Cache using Azure Container Apps
- Provision an Azure Cache for Redis instance

### Add the .NET Aspire component to the app

Add the appropriate .NET Aspire component to the _AspireRedis.AppHost_ project for your desired hosting service.

# [Azure Cache for Redis](#tab/azure-redis)

Add the [Aspire.Hosting.Azure.Redis](https://www.nuget.org/packages/Aspire.Hosting.Azure.Redis) package to the _AspireRedis.AppHost_ project:

```dotnetcli
dotnet add package Aspire.Hosting.Azure.Redis --prerelease
```

## [Redis Container](#tab/redis-container)

Add the [Aspire.Hosting.Redis](https://www.nuget.org/packages/Aspire.Hosting.Redis) package to the _AspireRedis.AppHost_ project:

```dotnetcli
dotnet add package Aspire.Hosting.Redis --prerelease
```

---

### Configure the AppHost project

Configure the _AspireRedis.AppHost_ project for your desired Redis service.

# [Azure Cache for Redis](#tab/azure-redis)

Replace the contents of the _Program.cs_ file in the _AspireRedis.AppHost_ project with the following code:

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

var cache = builder.AddRedis("cache")
.PublishAsAzureRedis();

var apiService = builder.AddProject<Projects.AspireRedis_ApiService>("apiservice")
.WithReference(cache);

builder.AddProject<Projects.AspireRedis_Web>("webfrontend")
.WithExternalHttpEndpoints()
.WithReference(cache)
.WithReference(apiService);

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

The preceding code adds an Azure Cache for Redis resource to your app and configures a connection called `cache`. The `PublishAsAzureRedis` method ensures that tools such as the Azure Developer CLI or Visual Studio create an Azure Cache for Redis resource during the deployment process.

## [Redis Container](#tab/redis-container)

Replace the contents of the _Program.cs_ file in the _AspireRedis.AppHost_ project with the following code:

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

var cache = builder.AddRedis("cache");

var apiService = builder.AddProject<Projects.RedisSample_ApiService>("apiservice")
.WithReference(cache);

builder.AddProject<Projects.RedisSample_Web>("webfrontend")
.WithExternalHttpEndpoints()
.WithReference(cache)
.WithReference(apiService);

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

The preceding code adds a Redis Container resource to your app and configures a connection called `cache`. This configuration also ensures that tools such as the Azure Developer CLI or Visual Studio create a containerized Redis instance during the deployment process.

---

## Deploy the app

Tools such as the [Azure Developer CLI](/azure/developer/azure-developer-cli/overview) (`azd`) support .NET Aspire Redis component configurations to streamline deployments. `azd` consumes these settings and provisions properly configured resources for you.

> [!NOTE]
> You can also use the [Azure CLI](/dotnet/aspire/deployment/azure/aca-deployment?pivots=azure-cli) or [Bicep](/dotnet/aspire/deployment/azure/aca-deployment?pivots=azure-bicep) to provision and deploy .NET Aspire app resources. These options require more manual steps, but provide more granular control over your deployments. .NET Aspire apps can also connect to an existing Redis instance through manual configurations.

1. Open a terminal window in the root of your .NET Aspire project.

1. Run the `azd init` command to initialize the project with `azd`.

```azdeveloper
azd init
```

1. When prompted for an environment name, enter *docs-aspireredis*.

1. Run the `azd up` command to begin the deployment process:

```azdeveloper
azd up
```

1. Select the Azure subscription that should host your app resources.

1. Select the Azure location to use.

The Azure Developer CLI provisions and deploys your app resources. The process may take a few minutes to complete.

1. When the deployment finishes, click the resource group link in the output to view the created resources in the Azure portal.

## [Azure Cache for Redis](#tab/azure-redis)

The deployment process provisioned an Azure Cache for Redis resource due to the **.AppHost** configuration you provided.

:::image type="content" source="media/resources-azure-redis.png" alt-text="A screenshot showing the deployed Azure Cache for Redis.":::

## [Redis Container](#tab/redis-container)

The deployment process created a Redis app container due to the **.AppHost** configuration you provided.

:::image type="content" source="media/resources-azure-redis-container.png" alt-text="A screenshot showing the containerized Redis.":::

---

[!INCLUDE [clean-up-resources](../includes/clean-up-resources.md)]

## See also

- [.NET Aspire deployment via Azure Container Apps](../deployment/azure/aca-deployment.md)
- [.NET Aspire Azure Container Apps deployment deep dive](../deployment/azure/aca-deployment-azd-in-depth.md)
- [Deploy a .NET Aspire app using GitHub Actions](../deployment/azure/aca-deployment-github-actions.md)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/caching/media/resources-azure-redis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/fundamentals/components-overview.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: .NET Aspire components overview
description: Explore the fundamental concepts of .NET Aspire components and learn how to integrate them into your apps.
ms.date: 12/20/2023
ms.date: 05/09/2024
ms.topic: conceptual
---

Expand Down Expand Up @@ -42,7 +42,7 @@ For more information on working with .NET Aspire components in Visual Studio, se

## Explore a sample component workflow

.NET Aspire components streamline the process of consuming popular services and platforms. For example, consider the **.NET Aspire Application** template. With this template, you get the [AppHost](app-host-overview.md) and [ServiceDefaults](service-defaults.md) projects. Imagine that you have a need for a worker service to perform some database processing. You could use the [.NET Aspire PostgreSQL component](../database/postgresql-component.md) to connect to and utilize a PostgreSQL database. The database could be hosted on-prem or in a cloud service such as Azure, AWS, or GCP. The following steps demonstrate how to integrate this component into your app:
.NET Aspire components streamline the process of consuming popular services and platforms. For example, consider the **.NET Aspire Application** template. With this template, you get the [AppHost](app-host-overview.md) and [ServiceDefaults](service-defaults.md) projects. Imagine that you have a need for a worker service to perform some database processing. You could use the [.NET Aspire PostgreSQL component](../database/postgresql-component.md) to connect to and utilize a PostgreSQL database. The database could be hosted on-prem or in a cloud service such as Azure, AWS, or GCP. The following steps demonstrate how to integrate this component into your app:

1. In the component consuming (worker service) project, install the [Aspire.Npgsql](https://www.nuget.org/packages/Aspire.Npgsql) NuGet package.

Expand Down Expand Up @@ -73,7 +73,7 @@ For more information on working with .NET Aspire components in Visual Studio, se

1. In your app host project (the project with the _*.AppHost_ suffix), add a reference to the worker service project. If you're using Visual Studio, you can use the [**Add .NET Aspire Orchestrator Support**](setup-tooling.md#add-orchestration-projects) project context menu item to add the reference automatically. The following code snippet shows the project reference of the _AspireApp.AppHost.csproj_:

:::code language="xml" source="snippets/components/AspireApp/AspireApp.AppHost/AspireApp.AppHost.csproj" highlight="16":::
:::code language="xml" source="snippets/components/AspireApp/AspireApp.AppHost/AspireApp.AppHost.csproj" highlight="17":::

After the worker service is referenced by the orchestrator project, the worker service project has its _Program.cs_ file updated to call the `AddServiceDefaults` method. For more information on service defaults, see [Service defaults](service-defaults.md).

Expand Down
12 changes: 6 additions & 6 deletions docs/fundamentals/dashboard/standalone.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
title: Standalone .NET Aspire dashboard
description: How to use the .NET Aspire dashboard standalone.
ms.date: 04/30/2024
ms.date: 05/09/2024
ms.topic: reference
---

# Standalone .NET Aspire dashboard

The [.NET Aspire dashboard](overview.md) provides a great UI for viewing telemetry. The dashboard:

- Ships as a Docker image that can be used with any OpenTelemetry enabled app.
- Ships as a container image that can be used with any OpenTelemetry enabled app.
- Can be used standalone, without the rest of .NET Aspire.

:::image type="content" source="media/explore/trace.png" lightbox="media/explore/trace.png" alt-text="A screenshot of the .NET Aspire dashboard Trace details page.":::
Expand All @@ -20,12 +20,12 @@ The dashboard is started using the Docker command line.

```bash
docker run --rm -it -p 18888:18888 -p 4317:18889 -d --name aspire-dashboard \
mcr.microsoft.com/dotnet/nightly/aspire-dashboard:8.0.0-preview.6
mcr.microsoft.com/dotnet/nightly/aspire-dashboard:8.0.0-preview.7
```

The preceding Docker command:

- Starts a container from the `mcr.microsoft.com/dotnet/nightly/aspire-dashboard:8.0.0-preview.6` image.
- Starts a container from the `mcr.microsoft.com/dotnet/nightly/aspire-dashboard:8.0.0-preview.7` image.
- The container has two ports:
- Port `4317` receives OpenTelemetry data from apps. Apps send data using [OpenTelemetry Protocol (OTLP)](https://opentelemetry.io/docs/specs/otlp/).
- Port `18888` has the dashboard UI. Navigate to `http://localhost:18888` in the browser to view the dashboard.
Expand All @@ -48,7 +48,7 @@ The dashboard offers a UI for viewing telemetry. Refer to the documentation to e
- [Traces page](explore.md#traces-page)
- [Metrics page](explore.md#metrics-page)

Although there is no restriction on where the dashboard is run, the dashboard is designed as a development and short-term diagnosic tool. The dashboard persists telemetry in-memory which creates some limitations:
Although there is no restriction on where the dashboard is run, the dashboard is designed as a development and short-term diagnostic tool. The dashboard persists telemetry in-memory which creates some limitations:

- Telemetry is automatically removed if [telemetry limits](configuration.md#telemetry-limits) are exceeded.
- No telemetry is persisted when the dashboard is restarted.
Expand All @@ -67,7 +67,7 @@ Apps collect and send telemetry using [their language's OpenTelemetry SDK](https

Important OpenTelemetry SDK options to configure:

- OTLP endpoint, which should match the dashboard's configuration, e.g., `http://localhost:4317`.
- OTLP endpoint, which should match the dashboard's configuration, for example, `http://localhost:4317`.
- OTLP protocol, with the dashboard currently supporting only the [OTLP/gRPC protocol](https://opentelemetry.io/docs/specs/otlp/#otlpgrpc). Configure applications to use the `grpc` protocol.

To configure applications:
Expand Down
9 changes: 5 additions & 4 deletions docs/get-started/build-your-first-aspire-app.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Build your first .NET Aspire app
description: Learn how to build your first .NET Aspire app using the .NET Aspire Started Application template.
ms.date: 12/07/2023
ms.date: 05/13/2024
ms.topic: quickstart
---

Expand Down Expand Up @@ -119,7 +119,7 @@ Finally, the app is built and run. The <xref:Aspire.Hosting.DistributedApplicati

The _*.ServiceDefaults_ project is a shared project that's used to manage configurations that are reused across the projects in your solution. This project ensures that all dependent services share the same resilience, service discovery, and OpenTelemetry configuration. A shared .NET Aspire project file contains the `IsAspireSharedProject` property set as `true`:

:::code language="xml" source="snippets/quickstart/AspireSample/AspireSample.ServiceDefaults/AspireSample.ServiceDefaults.csproj" highlight="8":::
:::code language="xml" source="snippets/quickstart/AspireSample/AspireSample.ServiceDefaults/AspireSample.ServiceDefaults.csproj" highlight="7":::

The service defaults project exposes an extension method on the <xref:Microsoft.Extensions.Hosting.IHostApplicationBuilder> type, named `AddServiceDefaults`. The service defaults project from the template is a starting point, and you can customize it to meet your needs. For more information, see [.NET Aspire service defaults](../fundamentals/service-defaults.md).

Expand All @@ -133,20 +133,21 @@ The front end app defines a typed <xref:System.Net.Http.HttpClient> that's used

The `HttpClient` is configured to use service discovery, consider the following code from the _Program.cs_ file of the _AspireSample.Web_ project:

:::code source="snippets/quickstart/AspireSample/AspireSample.Web/Program.cs" highlight="7-8,14-15":::
:::code source="snippets/quickstart/AspireSample/AspireSample.Web/Program.cs" highlight="7-8,14-19":::

The preceding code:

- Calls `AddServiceDefaults`, configuring the shared defaults for the app.
- Calls <xref:Microsoft.Extensions.Hosting.AspireRedisOutputCacheExtensions.AddRedisOutputCache%2A> with the same `connectionName` that was used when adding the Redis container `"cache"` to the application model. This configures the app to use Redis for output caching.
- Calls <xref:Microsoft.Extensions.DependencyInjection.HttpClientFactoryServiceCollectionExtensions.AddHttpClient%2A> and configures the <xref:System.Net.Http.HttpClient.BaseAddress?displayProperty=nameWithType> to be `"http://apiservice"`. This is the name that was used when adding the API project to the application model, and with service discovery configured, it will automatically resolve to the correct address to the API project.
- Calls <xref:Microsoft.Extensions.DependencyInjection.HttpClientFactoryServiceCollectionExtensions.AddHttpClient%2A> and configures the <xref:System.Net.Http.HttpClient.BaseAddress?displayProperty=nameWithType> to be `"https+http://apiservice"`. This is the name that was used when adding the API project to the application model, and with service discovery configured, it will automatically resolve to the correct address to the API project.

For more information, see [Make HTTP requests with the `HttpClient`](/dotnet/fundamentals/networking/http/httpclient) class.

## Next steps

- [.NET Aspire components overview](../fundamentals/components-overview.md)
- [Service discovery in .NET Aspire](../service-discovery/overview.md)
- [Service discovery in .NET](/dotnet/core/extensions/service-discovery)
- [.NET Aspire service defaults](../fundamentals/service-defaults.md)
- [Health checks in .NET Aspire](../fundamentals/health-checks.md)
- [.NET Aspire telemetry](../fundamentals/telemetry.md)
Binary file modified docs/get-started/media/aspire-dashboard-trace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/get-started/media/aspire-dashboard-webfrontend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/get-started/media/aspire-dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
Loading
Loading