Skip to content
DocsTry Aspire
DocsTry

YarpResourceExtensions Methods

ClassMethods7 members
Provides extension methods for adding YARP resources to the application model.
AddYarp(IDistributedApplicationBuilder, string)Section titled AddYarp(IDistributedApplicationBuilder, string)extensionIResourceBuilder<YarpResource>
Adds a YARP container to the application model.
public static class YarpResourceExtensions
{
public static IResourceBuilder<YarpResource> AddYarp(
this IDistributedApplicationBuilder builder,
string name)
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder.
namestringThe 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>)extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<YarpResource>The resource builder for YARP.
resourceWithFilesIResourceBuilder<IResourceWithContainerFiles>The resource with container files.
IResourceBuilder<YarpResource>The updated resource builder.
WithConfiguration(IResourceBuilder<YarpResource>, Action<IYarpConfigurationBuilder>)Section titled WithConfiguration(IResourceBuilder<YarpResource>, Action<IYarpConfigurationBuilder>)extensionIResourceBuilder<YarpResource>
Configure the YARP resource.
public static class YarpResourceExtensions
{
public static IResourceBuilder<YarpResource> WithConfiguration(
this IResourceBuilder<YarpResource> builder,
Action<IYarpConfigurationBuilder> configurationBuilder)
{
// ...
}
}
builderIResourceBuilder<YarpResource>The YARP resource to configure.
configurationBuilderAction<IYarpConfigurationBuilder>The delegate to configure YARP.
WithHostHttpsPort(IResourceBuilder<YarpResource>, int?)Section titled WithHostHttpsPort(IResourceBuilder<YarpResource>, int?)extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<YarpResource>The resource builder for YARP.
portint?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?)extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<YarpResource>The resource builder for YARP.
portint?The port to bind on the host. If null is used random port will be assigned.
WithStaticFiles(IResourceBuilder<YarpResource>)Section titled WithStaticFiles(IResourceBuilder<YarpResource>)extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<YarpResource>The resource builder for YARP.
IResourceBuilder<YarpResource>The ApplicationModel.IResourceBuilder`1.
WithStaticFiles(IResourceBuilder<YarpResource>, string)Section titled WithStaticFiles(IResourceBuilder<YarpResource>, string)extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<YarpResource>The resource builder for YARP.
sourcePathstringThe source path containing static files to serve.
IResourceBuilder<YarpResource>The ApplicationModel.IResourceBuilder`1.