Share via


ResourceBuilderExtensions.WithEnvironment Method

Definition

Overloads

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

Adds an environment variable to the resource with a value that implements both IValueProvider and IManifestExpressionProvider.

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, IResourceBuilder<ExternalServiceResource>)

Adds an environment variable to the resource with the URL from the ExternalServiceResource.

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

Adds an environment variable to the resource.

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

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.

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

Source:
ResourceBuilderExtensions.cs

Adds an environment variable to the resource with a value that implements both IValueProvider and IManifestExpressionProvider.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<T> WithEnvironment<T,TValue>(this Aspire.Hosting.ApplicationModel.IResourceBuilder<T> builder, string name, TValue value) where T : Aspire.Hosting.ApplicationModel.IResourceWithEnvironment where TValue : Aspire.Hosting.ApplicationModel.IValueProvider, Aspire.Hosting.ApplicationModel.IManifestExpressionProvider;
static member WithEnvironment : Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)> * string * 'Value -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)> (requires 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment and 'Value :> Aspire.Hosting.ApplicationModel.IValueProvider and 'Value :> Aspire.Hosting.ApplicationModel.IManifestExpressionProvider)
<Extension()>
Public Function WithEnvironment(Of T As IResourceWithEnvironment, TValue As IResourceWithEnvironment) (builder As IResourceBuilder(Of T), name As String, value As TValue) As IResourceBuilder(Of T)

Type Parameters

T

The resource type.

TValue

The value type that implements both IValueProvider and IManifestExpressionProvider.

Parameters

builder
IResourceBuilder<T>

The resource builder.

name
String

The name of the environment variable.

value
TValue

The value that provides both runtime values and manifest expressions.

Returns

The IResourceBuilder<T>.

Applies to

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

Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs

Allows for the population of environment variables on a resource.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<T> WithEnvironment<T>(this Aspire.Hosting.ApplicationModel.IResourceBuilder<T> builder, Action<Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext> callback) where T : Aspire.Hosting.ApplicationModel.IResourceWithEnvironment;
static member WithEnvironment : Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)> * Action<Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext> -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)> (requires 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)
<Extension()>
Public Function WithEnvironment(Of T As IResourceWithEnvironment) (builder As IResourceBuilder(Of T), callback As Action(Of EnvironmentCallbackContext)) As IResourceBuilder(Of T)

Type Parameters

T

The resource type.

Parameters

builder
IResourceBuilder<T>

The resource builder.

callback
Action<EnvironmentCallbackContext>

A callback that allows for deferred execution for computing many environment variables. This runs after resources have been allocated by the orchestrator and allows access to other resources to resolve computed data, e.g. connection strings, ports.

Returns

The IResourceBuilder<T>.

Applies to

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

Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs

Allows for the population of environment variables on a resource.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<T> WithEnvironment<T>(this Aspire.Hosting.ApplicationModel.IResourceBuilder<T> builder, Func<Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext,System.Threading.Tasks.Task> callback) where T : Aspire.Hosting.ApplicationModel.IResourceWithEnvironment;
static member WithEnvironment : Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)> * Func<Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext, System.Threading.Tasks.Task> -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)> (requires 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)
<Extension()>
Public Function WithEnvironment(Of T As IResourceWithEnvironment) (builder As IResourceBuilder(Of T), callback As Func(Of EnvironmentCallbackContext, Task)) As IResourceBuilder(Of T)

Type Parameters

T

The resource type.

Parameters

builder
IResourceBuilder<T>

The resource builder.

callback
Func<EnvironmentCallbackContext,Task>

A callback that allows for deferred execution for computing many environment variables. This runs after resources have been allocated by the orchestrator and allows access to other resources to resolve computed data, e.g. connection strings, ports.

Returns

The IResourceBuilder<T>.

Applies to

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

Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs

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

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

Type Parameters

T

The resource type.

Parameters

builder
IResourceBuilder<T>

The resource builder.

name
String

The name of the environment variable.

endpointReference
EndpointReference

The endpoint from which to extract the url.

Returns

The IResourceBuilder<T>.

Applies to

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

Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs

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

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<T> WithEnvironment<T>(this Aspire.Hosting.ApplicationModel.IResourceBuilder<T> builder, string envVarName, Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.IResourceWithConnectionString> resource) where T : Aspire.Hosting.ApplicationModel.IResourceWithEnvironment;
static member WithEnvironment : Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)> * string * Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.IResourceWithConnectionString> -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)> (requires 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)
<Extension()>
Public Function WithEnvironment(Of T As IResourceWithEnvironment) (builder As IResourceBuilder(Of T), envVarName As String, resource As IResourceBuilder(Of IResourceWithConnectionString)) As IResourceBuilder(Of T)

Type Parameters

T

The destination resource type.

Parameters

builder
IResourceBuilder<T>

The destination resource builder to which the environment variable will be added.

envVarName
String

The name of the environment variable under which the connection string will be set.

resource
IResourceBuilder<IResourceWithConnectionString>

The resource builder of the referenced service from which to pull the connection string.

Returns

The IResourceBuilder<T>.

Applies to

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

Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs

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

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

Type Parameters

T

The resource type.

Parameters

builder
IResourceBuilder<T>

The resource builder.

name
String

Name of environment variable.

parameter
IResourceBuilder<ParameterResource>

Resource builder for the parameter resource.

Returns

The IResourceBuilder<T>.

Applies to

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

Source:
ResourceBuilderExtensions.cs

Adds an environment variable to the resource with the URL from the ExternalServiceResource.

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

Type Parameters

T

The resource type.

Parameters

builder
IResourceBuilder<T>

The resource builder.

name
String

The name of the environment variable.

externalService
IResourceBuilder<ExternalServiceResource>

The external service.

Returns

The IResourceBuilder<T>.

Applies to

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

Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs

Adds an environment variable to the resource.

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

Type Parameters

T

The resource type.

Parameters

builder
IResourceBuilder<T>

The resource builder.

name
String

The name of the environment variable.

value
ReferenceExpression

The value of the environment variable.

Returns

The IResourceBuilder<T>.

Applies to

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

Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs

Adds an environment variable to the resource.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<T> WithEnvironment<T>(this Aspire.Hosting.ApplicationModel.IResourceBuilder<T> builder, string name, in Aspire.Hosting.ApplicationModel.ReferenceExpression.ExpressionInterpolatedStringHandler value) where T : Aspire.Hosting.ApplicationModel.IResourceWithEnvironment;
static member WithEnvironment : Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)> * string * ExpressionInterpolatedStringHandler -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)> (requires 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)
<Extension()>
Public Function WithEnvironment(Of T As IResourceWithEnvironment) (builder As IResourceBuilder(Of T), name As String, ByRef value As ReferenceExpression.ExpressionInterpolatedStringHandler) As IResourceBuilder(Of T)

Type Parameters

T

The resource type.

Parameters

builder
IResourceBuilder<T>

The resource builder.

name
String

The name of the environment variable.

value
ReferenceExpression.ExpressionInterpolatedStringHandler

The value of the environment variable.

Returns

The IResourceBuilder<T>.

Applies to

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

Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs

Adds an environment variable to the resource.

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

Type Parameters

T

The resource type.

Parameters

builder
IResourceBuilder<T>

The resource builder.

name
String

The name of the environment variable.

callback
Func<String>

A callback that allows for deferred execution of a specific environment variable. This runs after resources have been allocated by the orchestrator and allows access to other resources to resolve computed data, e.g. connection strings, ports.

Returns

The IResourceBuilder<T>.

Applies to

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

Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs
Source:
ResourceBuilderExtensions.cs

Adds an environment variable to the resource.

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

Type Parameters

T

The resource type.

Parameters

builder
IResourceBuilder<T>

The resource builder.

name
String

The name of the environment variable.

value
String

The value of the environment variable.

Returns

The IResourceBuilder<T>.

Applies to