ResourceBuilderExtensions.WithEnvironment Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
WithEnvironment<T>(IResourceBuilder<T>, String, ReferenceExpression+ExpressionInterpolatedStringHandler)
- 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.
The value of the environment variable.
Returns
A resource configured with the specified environment variable.
Applies to
WithEnvironment<T>(IResourceBuilder<T>, String, String)
- 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
A resource configured with the specified environment variable.
Applies to
WithEnvironment<T>(IResourceBuilder<T>, String, Func<String>)
- 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.
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
A resource configured with the specified environment variable.
Applies to
WithEnvironment<T>(IResourceBuilder<T>, String, ReferenceExpression)
- 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
A resource configured with the specified environment variable.
Applies to
WithEnvironment<T>(IResourceBuilder<T>, String, IResourceBuilder<IResourceWithConnectionString>)
- 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.
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, EndpointReference)
- 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
A resource configured with the environment variable callback.
Applies to
WithEnvironment<T>(IResourceBuilder<T>, Func<EnvironmentCallbackContext,Task>)
- 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
A resource configured with the environment variable callback.
Applies to
WithEnvironment<T>(IResourceBuilder<T>, Action<EnvironmentCallbackContext>)
- 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
A resource configured with the environment variable callback.
Applies to
WithEnvironment<T>(IResourceBuilder<T>, String, IResourceBuilder<ParameterResource>)
- 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
A resource configured with the environment variable callback.