Module com.azure.runtime.host
Interface ResourceWithEnvironment<T extends Resource<T> & ResourceWithEnvironment<T>>
- All Superinterfaces:
ResourceTrait<T>
,SelfAware<T>
- All Known Implementing Classes:
Container
,DockerFile
,EurekaServiceDiscovery
,Executable
,MicronautProject
,MicroserviceProject
,QuarkusProject
,SpringProject
public interface ResourceWithEnvironment<T extends Resource<T> & ResourceWithEnvironment<T>>
extends ResourceTrait<T>
-
Method Summary
Modifier and TypeMethodDescriptiondefault T
withEnvironment
(String key, String value) default T
withEnvironment
(Consumer<EnvironmentCallbackContext> callback) default T
withEnvironment
(Map<String, String> environment) default <R extends Resource<?> & ResourceWithEnvironment<?>>
TwithReference
(EndpointReference<?> endpointReference) Injects service discovery information from the specified endpoint into the resource using the source resource's name as the service name.default T
withReference
(String name, String url) Injects service discovery information as environment variables from the URI into the destination resource, using the name as the service name.default <R extends Resource<?> & ResourceWithConnectionString<?>>
TwithReference
(R source, String connectionName, boolean optional) 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).
-
Method Details
-
withEnvironment
-
withEnvironment
-
withReference
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}."- Parameters:
name
- The name of the service.url
- The URL of the service.- Returns:
- The resource configured with the specified reference.
- Throws:
MalformedURLException
- If the URI is not absolute or if the absolute path is not "/".
-
withReference
default <R extends Resource<?> & ResourceWithEnvironment<?>> T withReference(EndpointReference<?> endpointReference) Injects service discovery information from the specified endpoint into the resource using the source resource's name as the service name. Each endpoint will be injected using the format "services__{sourceResourceName}__{endpointName}__{endpointIndex}={uriString}."- Parameters:
endpointReference
- The endpoint from which to extract the URL.- Returns:
- The resource configured with the specified reference.
-
withReference
default <R extends Resource<?> & ResourceWithConnectionString<?>> T withReference(R source, String connectionName, boolean optional) 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
ResourceWithConnectionString.getConnectionString()
.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.
- Parameters:
source
- The resource from which to extract the connection string.connectionName
- An override of the source resource's name for the connection string. The resulting connection string will be "ConnectionStrings__connectionName" if this is not null.optional
- true to allow a missing connection string; false to throw an exception if the connection string is not found.- Returns:
- The resource configured with the specified reference.
-
withEnvironment
-