共用方式為


ContainerResourceBuilderExtensions.WithContainerName<T> Method

Definition

Overrides the default container name for this resource. By default Aspire generates a unique container name based on the resource name and a random postfix (or a postfix based on a hash of the AppHost project path for persistent container resources). This method allows you to override that behavior with a custom name, but could lead to naming conflicts if the specified name is not unique.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<T> WithContainerName<T> (this Aspire.Hosting.ApplicationModel.IResourceBuilder<T> builder, string name) where T : Aspire.Hosting.ApplicationModel.ContainerResource;
static member WithContainerName : Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.ContainerResource)> * string -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.ContainerResource)> (requires 'T :> Aspire.Hosting.ApplicationModel.ContainerResource)
<Extension()>
Public Function WithContainerName(Of T As ContainerResource) (builder As IResourceBuilder(Of T), name As String) As IResourceBuilder(Of T)

Type Parameters

T

The type of container resource.

Parameters

builder
IResourceBuilder<T>

The resource builder for the container resource.

name
String

The desired container name. Must be a valid container name or your runtime will report an error.

Returns

The resource bulder for the container resource.

Remarks

Combining this with Persistent will allow Aspire to re-use an existing container that was not created by an Aspire AppHost.

Applies to