Class Configuration
- All Implemented Interfaces:
Cloneable
Configuration configuration = new ConfigurationBuilder(new SampleSource(properties)) .root("azure.sdk") .buildSection("client-name"); ConfigurationProperty<String> proxyHostnameProperty = ConfigurationPropertyBuilder.ofString("http.proxy.hostname") .shared(true) .build(); System.out.println(configuration.get(proxyHostnameProperty));
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Configuration
No-opConfiguration
object used to opt out of using global configurations when constructing client libraries.static final String
The Azure Active Directory endpoint to connect to.static final String
Password for a PFX/PEM certificate used when performing service principal authentication with Azure.static final String
Path of a PFX/PEM certificate file to use when performing service principal authentication with Azure.static final String
Client id to use when performing service principal authentication with Azure.static final String
Client secret to use when performing service principal authentication with Azure.static final String
Name of the Azure cloud to connect to.static final String
Sets the name of theHttpClientProvider
implementation that should be used to construct instances ofHttpClient
.static final String
Enables HTTP request/response logging by setting an HTTP log detail level.static final String
Flag to disable the CP1 client capabilities in Azure Identity Token credentials.static final String
Enables logging by setting a log level.static final String
Disables metrics.static final String
Username to use when performing username/password authentication with Azure.static final String
URL used by Bridge To Kubernetes to redirect IMDS calls in the development environment.static final String
Name of Azure AAD regional authority.static final String
Sets the default timeout, in milliseconds, for a request to connect to the remote host.static final String
Sets the default timeout interval, in milliseconds, allowed between each byte read in a response.static final String
Sets the default timeout, in milliseconds, for a request to receive a response from the remote host.static final String
Sets the default number of times a request will be retried, if it passes the conditions for retrying, before it fails.static final String
Sets the default timeout interval, in milliseconds, allowed between each byte written by a request.static final String
Name of the Azure resource group.static final String
Subscription id to use when connecting to Azure resources.static final String
Disables telemetry collection.static final String
Tenant id for the Azure resources.static final String
Disables tracing.static final String
Username to use when performing username/password authentication with Azure.static final String
URL of the proxy for HTTP connections.static final String
URL of the proxy for HTTPS connections.static final String
Endpoint to connect to when using Azure Active Directory managed service identity (MSI).static final String
Header when connecting to Azure Active Directory using managed service identity (MSI).static final String
Endpoint to connect to when using Azure Active Directory managed service identity (MSI).static final String
Secret when connecting to Azure Active Directory using managed service identity (MSI).static final String
A list of hosts or CIDR to not use proxy HTTP/HTTPS connections through. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Deprecated.UseConfigurationBuilder
andConfigurationSource
to create configuration.boolean
contains
(ConfigurationProperty<?> property) Checks if configuration contains the property.boolean
Determines if the system property or environment variable is defined.<T> T
get
(ConfigurationProperty<T> property) Gets property value from all available sources in the following order: Explicit configuration from givenConfigurationSource
by property name Explicit configuration by property aliases in the order they were provided inConfigurationProperty
Explicit configuration by property name in the shared section (ifConfigurationProperty
is shared) Explicit configuration by property aliases in the shared section (ifConfigurationProperty
is shared) System property (if set) Environment variable (if set)Gets the value of system property or environment variable.<T> T
Gets the value of system property or environment variable and converts it with theconverter
.<T> T
Gets the value of system property or environment variable converted to given primitiveT
using correspondingparse
method on this type.static Configuration
Gets the global configuration store shared by all client libraries.Deprecated.UseConfigurationBuilder
andConfigurationSource
to provide all properties before creating configuration.Deprecated.UseConfigurationBuilder
andConfigurationSource
to provide all properties before creating configuration.
-
Field Details
-
PROPERTY_HTTP_PROXY
URL of the proxy for HTTP connections.- See Also:
-
PROPERTY_HTTPS_PROXY
URL of the proxy for HTTPS connections.- See Also:
-
PROPERTY_IDENTITY_ENDPOINT
Endpoint to connect to when using Azure Active Directory managed service identity (MSI).- See Also:
-
PROPERTY_IDENTITY_HEADER
Header when connecting to Azure Active Directory using managed service identity (MSI).- See Also:
-
PROPERTY_NO_PROXY
A list of hosts or CIDR to not use proxy HTTP/HTTPS connections through.- See Also:
-
PROPERTY_MSI_ENDPOINT
Endpoint to connect to when using Azure Active Directory managed service identity (MSI).- See Also:
-
PROPERTY_MSI_SECRET
Secret when connecting to Azure Active Directory using managed service identity (MSI).- See Also:
-
PROPERTY_AZURE_SUBSCRIPTION_ID
Subscription id to use when connecting to Azure resources.- See Also:
-
PROPERTY_AZURE_USERNAME
Username to use when performing username/password authentication with Azure.- See Also:
-
PROPERTY_AZURE_PASSWORD
Username to use when performing username/password authentication with Azure.- See Also:
-
PROPERTY_AZURE_CLIENT_ID
Client id to use when performing service principal authentication with Azure.- See Also:
-
PROPERTY_AZURE_CLIENT_SECRET
Client secret to use when performing service principal authentication with Azure.- See Also:
-
PROPERTY_AZURE_TENANT_ID
Tenant id for the Azure resources.- See Also:
-
PROPERTY_AZURE_CLIENT_CERTIFICATE_PATH
Path of a PFX/PEM certificate file to use when performing service principal authentication with Azure.- See Also:
-
PROPERTY_AZURE_CLIENT_CERTIFICATE_PASSWORD
Password for a PFX/PEM certificate used when performing service principal authentication with Azure.- See Also:
-
PROPERTY_AZURE_IDENTITY_DISABLE_CP1
Flag to disable the CP1 client capabilities in Azure Identity Token credentials.- See Also:
-
PROPERTY_AZURE_POD_IDENTITY_TOKEN_URL
URL used by Bridge To Kubernetes to redirect IMDS calls in the development environment.- See Also:
-
PROPERTY_AZURE_REGIONAL_AUTHORITY_NAME
Name of Azure AAD regional authority.- See Also:
-
PROPERTY_AZURE_RESOURCE_GROUP
Name of the Azure resource group.- See Also:
-
PROPERTY_AZURE_CLOUD
Name of the Azure cloud to connect to.- See Also:
-
PROPERTY_AZURE_AUTHORITY_HOST
The Azure Active Directory endpoint to connect to.- See Also:
-
PROPERTY_AZURE_TELEMETRY_DISABLED
Disables telemetry collection.- See Also:
-
PROPERTY_AZURE_LOG_LEVEL
Enables logging by setting a log level.- See Also:
-
PROPERTY_AZURE_HTTP_LOG_DETAIL_LEVEL
Enables HTTP request/response logging by setting an HTTP log detail level.- See Also:
-
PROPERTY_AZURE_TRACING_DISABLED
Disables tracing.- See Also:
-
PROPERTY_AZURE_METRICS_DISABLED
Disables metrics.- See Also:
-
PROPERTY_AZURE_REQUEST_RETRY_COUNT
Sets the default number of times a request will be retried, if it passes the conditions for retrying, before it fails.- See Also:
-
PROPERTY_AZURE_REQUEST_CONNECT_TIMEOUT
Sets the default timeout, in milliseconds, for a request to connect to the remote host.If the configured value is equal to or less than 0 no timeout will be applied.
- See Also:
-
PROPERTY_AZURE_REQUEST_WRITE_TIMEOUT
Sets the default timeout interval, in milliseconds, allowed between each byte written by a request.If the configured value is equal to or less than 0 no timeout will be applied.
- See Also:
-
PROPERTY_AZURE_REQUEST_RESPONSE_TIMEOUT
Sets the default timeout, in milliseconds, for a request to receive a response from the remote host.If the configured value is equal to or less than 0 no timeout will be applied.
- See Also:
-
PROPERTY_AZURE_REQUEST_READ_TIMEOUT
Sets the default timeout interval, in milliseconds, allowed between each byte read in a response.If the configured value is equal to or less than 0 no timeout will be applied.
- See Also:
-
PROPERTY_AZURE_HTTP_CLIENT_IMPLEMENTATION
Sets the name of theHttpClientProvider
implementation that should be used to construct instances ofHttpClient
.The name must be the full class name, ex
com.azure.core.http.netty.NettyAsyncHttpClientProvider
and notNettyAsyncHttpClientProvider
, to disambiguate multiple providers with the same name but from different packages.If the value isn't set or is an empty string the first
HttpClientProvider
found on the class path will be used to create an instance ofHttpClient
. If the value is set and doesn't match anyHttpClientProvider
found on the class path anIllegalStateException
will be thrown when attempting to create an instance ofHttpClient
.- See Also:
-
NONE
No-opConfiguration
object used to opt out of using global configurations when constructing client libraries.
-
-
Constructor Details
-
Configuration
Deprecated.UseConfigurationBuilder
andConfigurationSource
that allow to provide all properties before creating configuration and keep it immutable.Constructs a configuration containing the known Azure properties constants.
-
-
Method Details
-
getGlobalConfiguration
Gets the global configuration store shared by all client libraries.- Returns:
- The global configuration store.
-
get
Gets the value of system property or environment variable. Useget(ConfigurationProperty)
overload to get explicit configuration or environment configuration from specific source.This method first checks the values previously loaded from the environment, if the configuration is found there it will be returned. Otherwise, this will attempt to load the value from the environment.
- Parameters:
name
- Name of the configuration.- Returns:
- Value of the configuration if found, otherwise null.
-
get
Gets the value of system property or environment variable converted to given primitiveT
using correspondingparse
method on this type. Useget(ConfigurationProperty)
overload to get explicit configuration or environment configuration from specific source.This method first checks the values previously loaded from the environment, if the configuration is found there it will be returned. Otherwise, this will attempt to load the value from the environment.
If no configuration is found, the
defaultValue
is returned.Following types are supported:
- Type Parameters:
T
- Type that the configuration is converted to if found.- Parameters:
name
- Name of the configuration.defaultValue
- Value to return if the configuration isn't found.- Returns:
- The converted configuration if found, otherwise the default value is returned.
-
get
Gets the value of system property or environment variable and converts it with theconverter
.This method first checks the values previously loaded from the environment, if the configuration is found there it will be returned. Otherwise, this will attempt to load the value from the environment.
If no configuration is found the
converter
won't be called and null will be returned.- Type Parameters:
T
- Type that the configuration is converted to if found.- Parameters:
name
- Name of the configuration.converter
- Converter used to map the configuration toT
.- Returns:
- The converted configuration if found, otherwise null.
-
put
Deprecated.UseConfigurationBuilder
andConfigurationSource
to provide all properties before creating configuration.Adds a configuration with the given value.This will overwrite the previous configuration value if it existed.
- Parameters:
name
- Name of the configuration.value
- Value of the configuration.- Returns:
- The updated Configuration object.
-
remove
Deprecated.UseConfigurationBuilder
andConfigurationSource
to provide all properties before creating configuration.Removes the configuration.This returns the value of the configuration if it previously existed.
- Parameters:
name
- Name of the configuration.- Returns:
- The configuration if it previously existed, otherwise null.
-
contains
Determines if the system property or environment variable is defined.Use
contains(ConfigurationProperty)
overload to get explicit configuration or environment configuration from specific source.This only checks against values previously loaded into the Configuration object, this won't inspect the environment for containing the value.
- Parameters:
name
- Name of the configuration.- Returns:
- True if the configuration exists, otherwise false.
-
clone
Deprecated.UseConfigurationBuilder
andConfigurationSource
to create configuration.Clones this Configuration object. -
contains
Checks if configuration contains the property. If property can be shared between clients, checks thisConfiguration
and falls back to shared section. If property has aliases, system property or environment variable defined, checks them as well.Value is not validated.
- Parameters:
property
- instance.- Returns:
- true if property is available, false otherwise.
-
get
Gets property value from all available sources in the following order:- Explicit configuration from given
ConfigurationSource
by property name - Explicit configuration by property aliases in the order they were provided in
ConfigurationProperty
- Explicit configuration by property name in the shared section (if
ConfigurationProperty
is shared) - Explicit configuration by property aliases in the shared section (if
ConfigurationProperty
is shared) - System property (if set)
- Environment variable (if set)
Property value is converted to specified type. If property value is missing and not required, default value is returned.
ConfigurationProperty<String> property = ConfigurationPropertyBuilder.ofString("http.proxy.hostname") .shared(true) .logValue(true) .systemPropertyName("http.proxyHost") .build(); // attempts to get local `azure.sdk.<client-name>.http.proxy.host` property and falls back to // shared azure.sdk.http.proxy.port System.out.println(configuration.get(property));
- Type Parameters:
T
- Type that the configuration is converted to if found.- Parameters:
property
- instance.- Returns:
- The value of the property if it exists, otherwise the default value of the property.
- Throws:
NullPointerException
- when property instance is null.IllegalArgumentException
- when required property is missing.RuntimeException
- when property value conversion (and validation) throws.
- Explicit configuration from given
-
ConfigurationBuilder
andConfigurationSource
that allow to provide all properties before creating configuration and keep it immutable.