Skip to content

Latest commit

 

History

History
33 lines (22 loc) · 1.08 KB

valkey-app-host.md

File metadata and controls

33 lines (22 loc) · 1.08 KB

To model the Valkey resource (ValkeyResource) in the app host, install the Aspire.Hosting.Valkey NuGet package in the app host project.

dotnet add package Aspire.Hosting.Valkey
<PackageReference Include="Aspire.Hosting.Valkey"
                  Version="*" />

In your app host project, register the .NET Aspire Valkey as a resource using the AddValkey method and consume the service using the following methods:

var builder = DistributedApplication.CreateBuilder(args);

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

builder.AddProject<Projects.ExampleProject>()
       .WithReference(cache)

The xref:Aspire.Hosting.ResourceBuilderExtensions.WithReference%2A method configures a connection in the ExampleProject project named cache. In the :::no-loc text="Program.cs"::: file of ExampleProject, the Valkey connection can be consumed using:

builder.AddValkey("cache");