Skip to content
Docs Try Aspire

YarpResourceExtensions Methods

Class Methods 7 members
Provides extension methods for adding YARP resources to the application model.
AddYarp(IDistributedApplicationBuilder, string) Section titled AddYarp(IDistributedApplicationBuilder, string) extension IResourceBuilder<YarpResource>
Adds a YARP container to the application model.
public static class YarpResourceExtensions
{
public static IResourceBuilder<YarpResource> AddYarp(
this IDistributedApplicationBuilder builder,
string name)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder.
name string The name of the resource. This name will be used as the connection string name when referenced in a dependency.
IResourceBuilder<YarpResource> A reference to the ApplicationModel.IResourceBuilder`1.
PublishWithStaticFiles(IResourceBuilder<YarpResource>, IResourceBuilder<IResourceWithContainerFiles>) Section titled PublishWithStaticFiles(IResourceBuilder<YarpResource>, IResourceBuilder<IResourceWithContainerFiles>) extension IResourceBuilder<YarpResource>
In publish mode, generates a Dockerfile that copies static files from the specified resource into /app/wwwroot.
public static class YarpResourceExtensions
{
public static IResourceBuilder<YarpResource> PublishWithStaticFiles(
this IResourceBuilder<YarpResource> builder,
IResourceBuilder<IResourceWithContainerFiles> resourceWithFiles)
{
// ...
}
}
builder IResourceBuilder<YarpResource> The resource builder for YARP.
resourceWithFiles IResourceBuilder<IResourceWithContainerFiles> The resource with container files.
IResourceBuilder<YarpResource> The updated resource builder.
WithConfiguration(IResourceBuilder<YarpResource>, Action<IYarpConfigurationBuilder>) Section titled WithConfiguration(IResourceBuilder<YarpResource>, Action<IYarpConfigurationBuilder>) extension IResourceBuilder<YarpResource>
Configure the YARP resource.
public static class YarpResourceExtensions
{
public static IResourceBuilder<YarpResource> WithConfiguration(
this IResourceBuilder<YarpResource> builder,
Action<IYarpConfigurationBuilder> configurationBuilder)
{
// ...
}
}
builder IResourceBuilder<YarpResource> The YARP resource to configure.
configurationBuilder Action<IYarpConfigurationBuilder> The delegate to configure YARP.
WithHostHttpsPort(IResourceBuilder<YarpResource>, int?) Section titled WithHostHttpsPort(IResourceBuilder<YarpResource>, int?) extension IResourceBuilder<YarpResource>
Configures the host HTTPS port that the YARP resource is exposed on instead of using randomly assigned port. This will only have effect if an HTTPS endpoint is configured on the YARP resource due to TLS termination being enabled.
public static class YarpResourceExtensions
{
public static IResourceBuilder<YarpResource> WithHostHttpsPort(
this IResourceBuilder<YarpResource> builder,
int? port)
{
// ...
}
}
builder IResourceBuilder<YarpResource> The resource builder for YARP.
port int? The port to bind on the host. If null is used random port will be assigned.
IResourceBuilder<YarpResource> The updated resource builder.
WithHostPort(IResourceBuilder<YarpResource>, int?) Section titled WithHostPort(IResourceBuilder<YarpResource>, int?) extension IResourceBuilder<YarpResource>
Configures the host port that the YARP resource is exposed on instead of using randomly assigned port.
public static class YarpResourceExtensions
{
public static IResourceBuilder<YarpResource> WithHostPort(
this IResourceBuilder<YarpResource> builder,
int? port)
{
// ...
}
}
builder IResourceBuilder<YarpResource> The resource builder for YARP.
port int? The port to bind on the host. If null is used random port will be assigned.
WithStaticFiles(IResourceBuilder<YarpResource>) Section titled WithStaticFiles(IResourceBuilder<YarpResource>) extension IResourceBuilder<YarpResource>
Enables static file serving in the YARP resource. Static files are served from the wwwroot folder.
public static class YarpResourceExtensions
{
public static IResourceBuilder<YarpResource> WithStaticFiles(
this IResourceBuilder<YarpResource> builder)
{
// ...
}
}
builder IResourceBuilder<YarpResource> The resource builder for YARP.
IResourceBuilder<YarpResource> The ApplicationModel.IResourceBuilder`1.
WithStaticFiles(IResourceBuilder<YarpResource>, string) Section titled WithStaticFiles(IResourceBuilder<YarpResource>, string) extension IResourceBuilder<YarpResource>
Enables static file serving. In run mode: bind mounts sourcePath to /wwwroot. In publish mode: generates a Dockerfile whose build context is sourcePath and copies its contents into /app/wwwroot baked into the image.
public static class YarpResourceExtensions
{
public static IResourceBuilder<YarpResource> WithStaticFiles(
this IResourceBuilder<YarpResource> builder,
string sourcePath)
{
// ...
}
}
builder IResourceBuilder<YarpResource> The resource builder for YARP.
sourcePath string The source path containing static files to serve.
IResourceBuilder<YarpResource> The ApplicationModel.IResourceBuilder`1.