共用方式為


IResourceBuilder<T> Interface

Definition

Defines a builder for creating resources of type T.

public interface IResourceBuilder<out T> where T : IResource
type IResourceBuilder<'T (requires 'T :> IResource)> = interface
Public Interface IResourceBuilder(Of Out T)

Type Parameters

T

The type of resource to build.

This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.

Properties

ApplicationBuilder

Gets the distributed application builder associated with this resource builder.

Resource

Gets the resource of type T that is being built.

Methods

WithAnnotation<TAnnotation>(ResourceAnnotationMutationBehavior)

Adds an annotation to the resource being built.

WithAnnotation<TAnnotation>(TAnnotation, ResourceAnnotationMutationBehavior)

Adds an annotation to the resource being built.

Extension Methods

WithEnvironment<T>(IResourceBuilder<T>, String, BicepOutputReference)

Adds an environment variable to the resource with the value of the output from the bicep template.

WithEnvironment<T>(IResourceBuilder<T>, String, BicepSecretOutputReference)

Adds an environment variable to the resource with the value of the secret output from the bicep template.

WithParameter<T>(IResourceBuilder<T>, String, EndpointReference)

Adds a parameter to the bicep template.

WithParameter<T>(IResourceBuilder<T>, String, IResourceBuilder<IResourceWithConnectionString>)

Adds a parameter to the bicep template.

WithParameter<T>(IResourceBuilder<T>, String, IResourceBuilder<ParameterResource>)

Adds a parameter to the bicep template.

WithParameter<T>(IResourceBuilder<T>, String, ParameterResource)

Adds a parameter to the bicep template.

WithParameter<T>(IResourceBuilder<T>, String, ReferenceExpression)

Adds a parameter to the bicep template.

WithParameter<T>(IResourceBuilder<T>, String, BicepOutputReference)

Adds a parameter to the bicep template.

WithParameter<T>(IResourceBuilder<T>, String, IEnumerable<String>)

Adds a parameter to the bicep template.

WithParameter<T>(IResourceBuilder<T>, String, Func<Object>)

Adds a parameter to the bicep template.

WithParameter<T>(IResourceBuilder<T>, String, String)

Adds a parameter to the bicep template.

WithParameter<T>(IResourceBuilder<T>, String, JsonNode)

Adds a parameter to the bicep template.

WithParameter<T>(IResourceBuilder<T>, String)

Adds a parameter to the bicep template.

ConfigureConstruct<T>(IResourceBuilder<T>, Action<ResourceModuleConstruct>)

Configures the Azure construct resource.

PublishAsAzureContainerApp<T>(IResourceBuilder<T>, Action<AzureResourceInfrastructure,ContainerApp>)

Publishes the specified container resource as a container app.

PublishAsAzureContainerApp<T>(IResourceBuilder<T>, Action<AzureResourceInfrastructure,ContainerApp>)

Allows configuring the specified project resource as a container app.

ConfigureInfrastructure<T>(IResourceBuilder<T>, Action<AzureResourceInfrastructure>)

Configures the Azure provisioning resource Infrastructure.

PublishAsConnectionString<T>(IResourceBuilder<T>)

Changes the resource to be published as a connection string reference in the manifest.

WithEnvironment<TDestination,TConstruct>(IResourceBuilder<TDestination>, String, IResourceBuilder<IResourceWithConstruct<TConstruct>>, ConstructOutputDelegate<TConstruct>, String)

Add an environment variable with a reference of a AWS CDK construct to a project. The output parameters of the CloudFormation stack are added to the project IConfiguration.

WithReference<TDestination,TConstruct>(IResourceBuilder<TDestination>, IResourceBuilder<IResourceWithConstruct<TConstruct>>, ConstructOutputDelegate<TConstruct>, String, String)

Adds a reference of an AWS CDK construct to a project.The output parameters of the construct are added to the project IConfiguration.

WithEnvironment<T>(IResourceBuilder<T>, String, StackOutputReference)

Adds an environment variable to the resource with the value of the output from the CloudFormation stack.

WithReference<TDestination>(IResourceBuilder<TDestination>, IAmazonCloudFormation)

Override the CloudFormation service client the ICloudFormationStackResource would create to interact with the CloudFormation service. This can be used for pointing the CloudFormation service client to a non-standard CloudFormation endpoint like an emulator.

WithReference<TDestination>(IResourceBuilder<TDestination>, IResourceBuilder<ICloudFormationResource>, String)

Add a reference of a CloudFormations stack to a project. The output parameters of the CloudFormation stack are added to the project IConfiguration.

WithReference<TDestination>(IResourceBuilder<TDestination>, IAWSSDKConfig)

The AWS SDK service client configuration used to create the CloudFormation service client.

WithReference<TDestination>(IResourceBuilder<TDestination>, IResourceBuilder<IConstructResource<UserPool>>, String)

Adds a reference of an Amazon Cognito user pool to a project. The output parameters of the user pool are added to the project IConfiguration.

PublishAsContainer<T>(IResourceBuilder<T>)

Changes the resource to be published as a container in the manifest.

WithBindMount<T>(IResourceBuilder<T>, String, String, Boolean)

Adds a bind mount to a container resource.

WithBuildArg<T>(IResourceBuilder<T>, String, IResourceBuilder<ParameterResource>)

Adds a build argument when the container is built from a Dockerfile.

WithBuildArg<T>(IResourceBuilder<T>, String, Object)

Adds a build argument when the container is build from a Dockerfile.

WithBuildSecret<T>(IResourceBuilder<T>, String, IResourceBuilder<ParameterResource>)

Adds a secret build argument when the container is built from a Dockerfile.

WithContainerName<T>(IResourceBuilder<T>, String)

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.

WithContainerRuntimeArgs<T>(IResourceBuilder<T>, Action<ContainerRuntimeArgsCallbackContext>)

Adds a callback to be executed with a list of arguments to add to the container runtime run command when a container resource is started.

WithContainerRuntimeArgs<T>(IResourceBuilder<T>, Func<ContainerRuntimeArgsCallbackContext,Task>)

Adds a callback to be executed with a list of arguments to add to the container runtime run command when a container resource is started.

WithContainerRuntimeArgs<T>(IResourceBuilder<T>, String[])

Adds a callback to be executed with a list of arguments to add to the container runtime run command when a container resource is started.

WithDockerfile<T>(IResourceBuilder<T>, String, String, String)

Causes .NET Aspire to build the specified container image from a Dockerfile.

WithEntrypoint<T>(IResourceBuilder<T>, String)

Sets the Entrypoint for the container.

WithImage<T>(IResourceBuilder<T>, String, String)

Allows overriding the image on a container.

WithImageRegistry<T>(IResourceBuilder<T>, String)

Allows overriding the image registry on a container.

WithImageSHA256<T>(IResourceBuilder<T>, String)

Allows setting the image to a specific sha256 on a container.

WithImageTag<T>(IResourceBuilder<T>, String)

Allows overriding the image tag on a container.

WithLifetime<T>(IResourceBuilder<T>, ContainerLifetime)

Sets the lifetime behavior of the container resource.

WithVolume<T>(IResourceBuilder<T>, String, String, Boolean)

Adds a volume to a container resource.

WithVolume<T>(IResourceBuilder<T>, String)

Adds an anonymous volume to a container resource.

WithInitialState<TResource>(IResourceBuilder<TResource>, CustomResourceSnapshot)

Initializes the resource with the initial snapshot.

WithReference<TDestination>(IResourceBuilder<TDestination>, IResourceBuilder<IConstructResource<Table>>, String)

Adds a reference of an Amazon DynamoDB table to a project. The output parameters of the table are added to the project IConfiguration.

PublishAsDockerFile<T>(IResourceBuilder<T>, IEnumerable<DockerBuildArg>)

Adds annotation to ExecutableResource to support containerization during deployment. The resulting container image is built, and when the optional buildArgs are provided they're used with docker build --build-arg.

WithDaprSidecar<T>(IResourceBuilder<T>, DaprSidecarOptions)

Ensures that a Dapr sidecar is started for the resource.

WithDaprSidecar<T>(IResourceBuilder<T>, Action<IResourceBuilder<IDaprSidecarResource>>)

Ensures that a Dapr sidecar is started for the resource.

WithDaprSidecar<T>(IResourceBuilder<T>, String)

Ensures that a Dapr sidecar is started for the resource.

WithReference<TDestination>(IResourceBuilder<TDestination>, IResourceBuilder<IDaprComponentResource>)

Associates a Dapr component with the Dapr sidecar started for the resource.

WithReference<TDestination>(IResourceBuilder<TDestination>, IResourceBuilder<IConstructResource<Stream>>, String)

Adds a reference of an Amazon Kinesis stream to a project. The output parameters of the stream are added to the project IConfiguration.

WithAttu<T>(IResourceBuilder<T>, Action<IResourceBuilder<AttuResource>>, String)

Adds an administration and development platform for Milvus to the application model using Attu.

WithMongoExpress<T>(IResourceBuilder<T>, Action<IResourceBuilder<MongoExpressContainerResource>>, String)

Adds a MongoExpress administration and development platform for MongoDB to the application model.

WithPhpMyAdmin<T>(IResourceBuilder<T>, Action<IResourceBuilder<PhpMyAdminContainerResource>>, String)

Adds a phpMyAdmin administration and development platform for MySql to the application model.

WithReference<T>(IResourceBuilder<T>, OrleansServiceClient)

Adds an Orleans client to the resource.

WithReference<T>(IResourceBuilder<T>, OrleansService)

Adds Orleans to the resource.

WithOtlpExporter<T>(IResourceBuilder<T>)

Injects the appropriate environment variables to allow the resource to enable sending telemetry to the dashboard.

  1. It sets the OTLP endpoint to the value of the DOTNET_DASHBOARD_OTLP_ENDPOINT_URL environment variable.
  2. It sets the service name and instance id to the resource name and UID. Values are injected by the orchestrator.
  3. It sets a small batch schedule delay in development. This reduces the delay that OTLP exporter waits to sends telemetry and makes the dashboard telemetry pages responsive.
PublishAsConnectionString<T>(IResourceBuilder<T>)

Changes the resource to be published as a connection string reference in the manifest.

WithPgAdmin<T>(IResourceBuilder<T>, Action<IResourceBuilder<PgAdminContainerResource>>, String)

Adds a pgAdmin 4 administration and development platform for PostgreSQL to the application model.

WithReference<TDestination>(IResourceBuilder<TDestination>, IResourceBuilder<QdrantServerResource>)

Add a reference to a Qdrant server to the resource.

AsHttp2Service<T>(IResourceBuilder<T>)

Configures a resource to mark all endpoints' transport as HTTP/2. This is useful for HTTP/2 services that need prior knowledge.

ExcludeFromManifest<T>(IResourceBuilder<T>)

Excludes a resource from being published to the manifest.

GetEndpoint<T>(IResourceBuilder<T>, String)

Gets an EndpointReference by name from the resource. These endpoints are declared either using WithEndpoint<T>(IResourceBuilder<T>, Nullable<Int32>, Nullable<Int32>, String, String, String, Boolean, Nullable<Boolean>) or by launch settings (for project resources). The EndpointReference can be used to resolve the address of the endpoint in WithEnvironment<T>(IResourceBuilder<T>, Action<EnvironmentCallbackContext>).

WaitFor<T>(IResourceBuilder<T>, IResourceBuilder<IResource>)

Waits for the dependency resource to enter the Running state before starting the resource.

WaitForCompletion<T>(IResourceBuilder<T>, IResourceBuilder<IResource>, Int32)

Waits for the dependency resource to enter the Exited or Finished state before starting the resource.

WithArgs<T>(IResourceBuilder<T>, Action<CommandLineArgsCallbackContext>)

Adds a callback to be executed with a list of command-line arguments when a container resource is started.

WithArgs<T>(IResourceBuilder<T>, Func<CommandLineArgsCallbackContext,Task>)

Adds a callback to be executed with a list of command-line arguments when a container resource is started.

WithArgs<T>(IResourceBuilder<T>, Object[])

Adds the arguments to be passed to a container resource when the container is started.

WithArgs<T>(IResourceBuilder<T>, String[])

Adds the arguments to be passed to a container resource when the container is started.

WithCommand<T>(IResourceBuilder<T>, String, String, Func<ExecuteCommandContext, Task<ExecuteCommandResult>>, Func<UpdateCommandStateContext,ResourceCommandState>, String, Object, String, String, Nullable<IconVariant>, Boolean)

Adds a ResourceCommandAnnotation to the resource annotations to add a resource command.

WithConnectionStringRedirection<T>(IResourceBuilder<T>, IResourceWithConnectionString)

Registers a callback which is invoked when a connection string is requested for a resource.

WithEndpoint<T>(IResourceBuilder<T>, Nullable<Int32>, Nullable<Int32>, String, String, String, Boolean, Nullable<Boolean>)

Exposes an endpoint on a resource. This endpoint reference can be retrieved using GetEndpoint<T>(IResourceBuilder<T>, String). The endpoint name will be the scheme name if not specified.

WithEndpoint<T>(IResourceBuilder<T>, String, Action<EndpointAnnotation>, Boolean)

Changes an existing creates a new endpoint if it doesn't exist and invokes callback to modify the defaults.

WithEnvironment<T>(IResourceBuilder<T>, Action<EnvironmentCallbackContext>)

Allows for the population of environment variables on a resource.

WithEnvironment<T>(IResourceBuilder<T>, Func<EnvironmentCallbackContext,Task>)

Allows for the population of environment variables on a resource.

WithEnvironment<T>(IResourceBuilder<T>, String, EndpointReference)

Adds an environment variable to the resource with the endpoint for endpointReference.

WithEnvironment<T>(IResourceBuilder<T>, String, IResourceBuilder<IResourceWithConnectionString>)

Adds an environment variable to the resource with the connection string from the referenced resource.

WithEnvironment<T>(IResourceBuilder<T>, String, IResourceBuilder<ParameterResource>)

Adds an environment variable to the resource with the value from parameter.

WithEnvironment<T>(IResourceBuilder<T>, String, ReferenceExpression+ExpressionInterpolatedStringHandler)

Adds an environment variable to the resource.

WithEnvironment<T>(IResourceBuilder<T>, String, ReferenceExpression)

Adds an environment variable to the resource.

WithEnvironment<T>(IResourceBuilder<T>, String, Func<String>)

Adds an environment variable to the resource.

WithEnvironment<T>(IResourceBuilder<T>, String, String)

Adds an environment variable to the resource.

WithExternalHttpEndpoints<T>(IResourceBuilder<T>)

Marks existing http or https endpoints on a resource as external.

WithHealthCheck<T>(IResourceBuilder<T>, String)

Adds a HealthCheckAnnotation to the resource annotations to associate a resource with a named health check managed by the health check service.

WithHttpEndpoint<T>(IResourceBuilder<T>, Nullable<Int32>, Nullable<Int32>, String, String, Boolean)

Exposes an HTTP endpoint on a resource. This endpoint reference can be retrieved using GetEndpoint<T>(IResourceBuilder<T>, String). The endpoint name will be "http" if not specified.

WithHttpHealthCheck<T>(IResourceBuilder<T>, String, Nullable<Int32>, String)

Adds a health check to the resource which is mapped to a specific endpoint.

WithHttpsEndpoint<T>(IResourceBuilder<T>, Nullable<Int32>, Nullable<Int32>, String, String, Boolean)

Exposes an HTTPS endpoint on a resource. This endpoint reference can be retrieved using GetEndpoint<T>(IResourceBuilder<T>, String). The endpoint name will be "https" if not specified.

WithHttpsHealthCheck<T>(IResourceBuilder<T>, String, Nullable<Int32>, String)

Adds a health check to the resource which is mapped to a specific endpoint.

WithManifestPublishingCallback<T>(IResourceBuilder<T>, Action<ManifestPublishingContext>)

Registers a callback which is invoked when manifest is generated for the app model.

WithManifestPublishingCallback<T>(IResourceBuilder<T>, Func<ManifestPublishingContext,Task>)

Registers an async callback which is invoked when manifest is generated for the app model.

WithReference<TDestination>(IResourceBuilder<TDestination>, EndpointReference)

Injects service discovery information from the specified endpoint into the project resource using the source resource's name as the service name. Each endpoint will be injected using the format "services__{sourceResourceName}{endpointName}{endpointIndex}={uriString}."

WithReference<TDestination>(IResourceBuilder<TDestination>, IResourceBuilder<IResourceWithConnectionString>, String, Boolean)

Injects a connection string as an environment variable from the source resource into the destination resource, using the source resource's name as the connection string name (if not overridden). The format of the environment variable will be "ConnectionStrings__{sourceResourceName}={connectionString}."

Each resource defines the format of the connection string value. The underlying connection string value can be retrieved using GetConnectionStringAsync(CancellationToken).

Connection strings are also resolved by the configuration system (appSettings.json in the AppHost project, or environment variables). If a connection string is not found on the resource, the configuration system will be queried for a connection string using the resource's name.

WithReference<TDestination>(IResourceBuilder<TDestination>, IResourceBuilder<IResourceWithServiceDiscovery>)

Injects service discovery information as environment variables from the project resource into the destination resource, using the source resource's name as the service name. Each endpoint defined on the project resource will be injected using the format "services__{sourceResourceName}{endpointName}{endpointIndex}={uriString}."

WithReference<TDestination>(IResourceBuilder<TDestination>, String, Uri)

Injects service discovery information as environment variables from the uri into the destination resource, using the name as the service name. The uri will be injected using the format "services__{name}__default__0={uri}."

WithReference<TDestination>(IResourceBuilder<TDestination>, IResourceBuilder<IConstructResource<Bucket>>, String)

Adds a reference of an Amazon S3 bucket to a project. The output parameters of the bucket are added to the project IConfiguration.

WithReference<TDestination>(IResourceBuilder<TDestination>, IAWSSDKConfig)

Add a reference to an AWS SDK configuration to the resource.

WithReference<TDestination>(IResourceBuilder<TDestination>, IResourceBuilder<IConstructResource<Topic>>, String)

Adds a reference of an Amazon SNS topic to a project. The output parameters of the topic are added to the project IConfiguration.

WithReference<TDestination>(IResourceBuilder<TDestination>, IResourceBuilder<IConstructResource<Queue>>, String)

Adds a reference of an Amazon SQS queue to a project. The output parameters of the queue are added to the project IConfiguration.

Applies to