Configuration Class

  • java.lang.Object
    • com.azure.core.util.Configuration

Implements

public class Configuration
implements Cloneable

Contains configuration information that is used during construction of client libraries.

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 Type Field and Description
static final Configuration NONE

No-op Configuration object used to opt out of using global configurations when constructing client libraries.

static final String PROPERTY_AZURE_AUTHORITY_HOST

The Azure Active Directory endpoint to connect to.

static final String PROPERTY_AZURE_CLIENT_CERTIFICATE_PASSWORD

Password for a PFX/PEM certificate used when performing service principal authentication with Azure.

static final String PROPERTY_AZURE_CLIENT_CERTIFICATE_PATH

Path of a PFX/PEM certificate file to use when performing service principal authentication with Azure.

static final String PROPERTY_AZURE_CLIENT_ID

Client id to use when performing service principal authentication with Azure.

static final String PROPERTY_AZURE_CLIENT_SECRET

Client secret to use when performing service principal authentication with Azure.

static final String PROPERTY_AZURE_CLIENT_SEND_CERTIFICATE_CHAIN

Flag to enable sending the certificate chain in x5c header to support subject name / issuer based authentication.

static final String PROPERTY_AZURE_CLOUD

Name of the Azure cloud to connect to.

static final String PROPERTY_AZURE_HTTP_CLIENT_IMPLEMENTATION

Sets the name of the HttpClientProvider implementation that should be used to construct instances of HttpClient.

static final String PROPERTY_AZURE_HTTP_LOG_DETAIL_LEVEL

Enables HTTP request/response logging by setting an HTTP log detail level.

static final String PROPERTY_AZURE_IDENTITY_DISABLE_CP1

Flag to disable the CP1 client capabilities in Azure Identity Token credentials.

static final String PROPERTY_AZURE_LOG_LEVEL

Enables logging by setting a log level.

static final String PROPERTY_AZURE_METRICS_DISABLED

Disables metrics.

static final String PROPERTY_AZURE_METRICS_IMPLEMENTATION

Sets the name of the MeterProvider implementation that should be used to construct instances of Meter.

static final String PROPERTY_AZURE_PASSWORD

Username to use when performing username/password authentication with Azure.

static final String PROPERTY_AZURE_POD_IDENTITY_TOKEN_URL

URL used by Bridge To Kubernetes to redirect IMDS calls in the development environment.

static final String PROPERTY_AZURE_REGIONAL_AUTHORITY_NAME

Name of Azure AAD regional authority.

static final String PROPERTY_AZURE_REQUEST_CONNECT_TIMEOUT

Sets the default timeout, in milliseconds, for a request to connect to the remote host.

static final String PROPERTY_AZURE_REQUEST_READ_TIMEOUT

Sets the default timeout interval, in milliseconds, allowed between each byte read in a response.

static final String PROPERTY_AZURE_REQUEST_RESPONSE_TIMEOUT

Sets the default timeout, in milliseconds, for a request to receive a response from the remote host.

static final String 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.

static final String PROPERTY_AZURE_REQUEST_WRITE_TIMEOUT

Sets the default timeout interval, in milliseconds, allowed between each byte written by a request.

static final String PROPERTY_AZURE_RESOURCE_GROUP

Name of the Azure resource group.

static final String PROPERTY_AZURE_SUBSCRIPTION_ID

Subscription id to use when connecting to Azure resources.

static final String PROPERTY_AZURE_TELEMETRY_DISABLED

Disables telemetry collection.

static final String PROPERTY_AZURE_TENANT_ID

Tenant id for the Azure resources.

static final String PROPERTY_AZURE_TRACING_DISABLED

Disables tracing.

static final String PROPERTY_AZURE_TRACING_IMPLEMENTATION

Sets the name of the TracerProvider implementation that should be used to construct instances of Tracer.

static final String PROPERTY_AZURE_USERNAME

Username to use when performing username/password authentication with Azure.

static final String PROPERTY_HTTPS_PROXY

URL of the proxy for HTTPS connections.

static final String PROPERTY_HTTP_PROXY

URL of the proxy for HTTP connections.

static final String PROPERTY_IDENTITY_ENDPOINT

Endpoint to connect to when using Azure Active Directory managed service identity (MSI).

static final String PROPERTY_IDENTITY_HEADER

Header when connecting to Azure Active Directory using managed service identity (MSI).

static final String PROPERTY_MSI_ENDPOINT

Endpoint to connect to when using Azure Active Directory managed service identity (MSI).

static final String PROPERTY_MSI_SECRET

Secret when connecting to Azure Active Directory using managed service identity (MSI).

static final String PROPERTY_NO_PROXY

A list of hosts or CIDR to not use proxy HTTP/HTTPS connections through.

Constructor Summary

Constructor Description
Configuration()

Deprecated

Use ConfigurationBuilder and ConfigurationSource that allow to provide all properties before creating configuration and keep it immutable.

Constructs a configuration containing the known Azure properties constants.

Method Summary

Modifier and Type Method and Description
T get(ConfigurationProperty<T> property)

Gets property value from all available sources in the following order:

T get(String name, T defaultValue)

Gets the value of system property or environment variable converted to given primitive T using corresponding parse method on this type.

T get(String name, Function<String,T> converter)

Gets the value of system property or environment variable and converts it with the converter.

Configuration clone()

Deprecated

Use ConfigurationBuilder and ConfigurationSource to create configuration.

Clones this Configuration object.

boolean contains(ConfigurationProperty<?> property)

Checks if configuration contains the property.

boolean contains(String name)

Determines if the system property or environment variable is defined.

String get(String name)

Gets the value of system property or environment variable.

static Configuration getGlobalConfiguration()

Gets the global configuration store shared by all client libraries.

Configuration put(String name, String value)

Deprecated

Use ConfigurationBuilder and ConfigurationSource to provide all properties before creating configuration.

Adds a configuration with the given value.

String remove(String name)

Deprecated

Use ConfigurationBuilder and ConfigurationSource to provide all properties before creating configuration.

Removes the configuration.

Methods inherited from java.lang.Object

Field Details

NONE

public static final Configuration NONE

No-op Configuration object used to opt out of using global configurations when constructing client libraries.

PROPERTY_AZURE_AUTHORITY_HOST

public static final String PROPERTY_AZURE_AUTHORITY_HOST

The Azure Active Directory endpoint to connect to.

PROPERTY_AZURE_CLIENT_CERTIFICATE_PASSWORD

public static final String PROPERTY_AZURE_CLIENT_CERTIFICATE_PASSWORD

Password for a PFX/PEM certificate used when performing service principal authentication with Azure.

PROPERTY_AZURE_CLIENT_CERTIFICATE_PATH

public static final String PROPERTY_AZURE_CLIENT_CERTIFICATE_PATH

Path of a PFX/PEM certificate file to use when performing service principal authentication with Azure.

PROPERTY_AZURE_CLIENT_ID

public static final String PROPERTY_AZURE_CLIENT_ID

Client id to use when performing service principal authentication with Azure.

PROPERTY_AZURE_CLIENT_SECRET

public static final String PROPERTY_AZURE_CLIENT_SECRET

Client secret to use when performing service principal authentication with Azure.

PROPERTY_AZURE_CLIENT_SEND_CERTIFICATE_CHAIN

public static final String PROPERTY_AZURE_CLIENT_SEND_CERTIFICATE_CHAIN

Flag to enable sending the certificate chain in x5c header to support subject name / issuer based authentication.

PROPERTY_AZURE_CLOUD

public static final String PROPERTY_AZURE_CLOUD

Name of the Azure cloud to connect to.

PROPERTY_AZURE_HTTP_CLIENT_IMPLEMENTATION

public static final String PROPERTY_AZURE_HTTP_CLIENT_IMPLEMENTATION

Sets the name of the HttpClientProvider implementation that should be used to construct instances of HttpClient.

The name must be the full class name, ex com.azure.core.http.netty.NettyAsyncHttpClientProvider and not NettyAsyncHttpClientProvider, 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 resolved by ServiceLoader will be used to create an instance of HttpClient. If the value is set and doesn't match any HttpClientProvider resolved by ServiceLoader an IllegalStateException will be thrown when attempting to create an instance of HttpClient.

PROPERTY_AZURE_HTTP_LOG_DETAIL_LEVEL

public static final String PROPERTY_AZURE_HTTP_LOG_DETAIL_LEVEL

Enables HTTP request/response logging by setting an HTTP log detail level.

PROPERTY_AZURE_IDENTITY_DISABLE_CP1

public static final String PROPERTY_AZURE_IDENTITY_DISABLE_CP1

Flag to disable the CP1 client capabilities in Azure Identity Token credentials.

PROPERTY_AZURE_LOG_LEVEL

public static final String PROPERTY_AZURE_LOG_LEVEL

Enables logging by setting a log level.

PROPERTY_AZURE_METRICS_DISABLED

public static final String PROPERTY_AZURE_METRICS_DISABLED

Disables metrics.

PROPERTY_AZURE_METRICS_IMPLEMENTATION

public static final String PROPERTY_AZURE_METRICS_IMPLEMENTATION

Sets the name of the MeterProvider implementation that should be used to construct instances of Meter.

The name must be the full class name, e.g. com.azure.core.tracing.opentelemetry.OpenTelemetryMeterProvider and not OpenTelemetryMeterProvider.

If the value isn't set or is an empty string the first MeterProvider resolved by ServiceLoader will be used to create an instance of Meter. If the value is set and doesn't match any MeterProvider resolved by ServiceLoader an IllegalStateException will be thrown when attempting to create an instance of MeterProvider.

PROPERTY_AZURE_PASSWORD

public static final String PROPERTY_AZURE_PASSWORD

Username to use when performing username/password authentication with Azure.

PROPERTY_AZURE_POD_IDENTITY_TOKEN_URL

public static final String PROPERTY_AZURE_POD_IDENTITY_TOKEN_URL

URL used by Bridge To Kubernetes to redirect IMDS calls in the development environment.

PROPERTY_AZURE_REGIONAL_AUTHORITY_NAME

public static final String PROPERTY_AZURE_REGIONAL_AUTHORITY_NAME

Name of Azure AAD regional authority.

PROPERTY_AZURE_REQUEST_CONNECT_TIMEOUT

public static final String 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.

PROPERTY_AZURE_REQUEST_READ_TIMEOUT

public static final String 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.

PROPERTY_AZURE_REQUEST_RESPONSE_TIMEOUT

public static final String 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.

PROPERTY_AZURE_REQUEST_RETRY_COUNT

public static final String 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.

PROPERTY_AZURE_REQUEST_WRITE_TIMEOUT

public static final String 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.

PROPERTY_AZURE_RESOURCE_GROUP

public static final String PROPERTY_AZURE_RESOURCE_GROUP

Name of the Azure resource group.

PROPERTY_AZURE_SUBSCRIPTION_ID

public static final String PROPERTY_AZURE_SUBSCRIPTION_ID

Subscription id to use when connecting to Azure resources.

PROPERTY_AZURE_TELEMETRY_DISABLED

public static final String PROPERTY_AZURE_TELEMETRY_DISABLED

Disables telemetry collection.

PROPERTY_AZURE_TENANT_ID

public static final String PROPERTY_AZURE_TENANT_ID

Tenant id for the Azure resources.

PROPERTY_AZURE_TRACING_DISABLED

public static final String PROPERTY_AZURE_TRACING_DISABLED

Disables tracing.

PROPERTY_AZURE_TRACING_IMPLEMENTATION

public static final String PROPERTY_AZURE_TRACING_IMPLEMENTATION

Sets the name of the TracerProvider implementation that should be used to construct instances of Tracer.

The name must be the full class name, e.g. com.azure.core.tracing.opentelemetry.OpenTelemetryTracerProvider and not OpenTelemetryTracerProvider.

If the value isn't set or is an empty string the first TracerProvider resolved by ServiceLoader will be used to create an instance of Tracer. If the value is set and doesn't match any TracerProvider resolved by ServiceLoader an IllegalStateException will be thrown when attempting to create an instance of TracerProvider.

PROPERTY_AZURE_USERNAME

public static final String PROPERTY_AZURE_USERNAME

Username to use when performing username/password authentication with Azure.

PROPERTY_HTTPS_PROXY

public static final String PROPERTY_HTTPS_PROXY

URL of the proxy for HTTPS connections.

PROPERTY_HTTP_PROXY

public static final String PROPERTY_HTTP_PROXY

URL of the proxy for HTTP connections.

PROPERTY_IDENTITY_ENDPOINT

public static final String PROPERTY_IDENTITY_ENDPOINT

Endpoint to connect to when using Azure Active Directory managed service identity (MSI).

PROPERTY_IDENTITY_HEADER

public static final String PROPERTY_IDENTITY_HEADER

Header when connecting to Azure Active Directory using managed service identity (MSI).

PROPERTY_MSI_ENDPOINT

public static final String PROPERTY_MSI_ENDPOINT

Endpoint to connect to when using Azure Active Directory managed service identity (MSI).

PROPERTY_MSI_SECRET

public static final String PROPERTY_MSI_SECRET

Secret when connecting to Azure Active Directory using managed service identity (MSI).

PROPERTY_NO_PROXY

public static final String PROPERTY_NO_PROXY

A list of hosts or CIDR to not use proxy HTTP/HTTPS connections through.

Constructor Details

Configuration

@Deprecated
public Configuration()

Deprecated

Use ConfigurationBuilder and ConfigurationSource that allow to provide all properties before creating configuration and keep it immutable.

Constructs a configuration containing the known Azure properties constants.

Method Details

get

public T get(ConfigurationProperty property)

Gets property value from all available sources in the following order:

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));

Parameters:

property - instance.

Returns:

The value of the property if it exists, otherwise the default value of the property.

get

public T get(String name, T defaultValue)

Gets the value of system property or environment variable converted to given primitive T using corresponding parse method on this type. Use get(ConfigurationProperty<T> property) 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:

  • Byte
  • Short
  • Integer
  • Long
  • Float
  • Double
  • Boolean

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

public T get(String name, Function converter)

Gets the value of system property or environment variable and converts it with the converter.

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.

Parameters:

name - Name of the configuration.
converter - Converter used to map the configuration to T.

Returns:

The converted configuration if found, otherwise null.

clone

@Deprecated
public Configuration clone()

Deprecated

Use ConfigurationBuilder and ConfigurationSource to create configuration.

Clones this Configuration object.

Overrides:

Configuration.clone()

Returns:

A clone of the Configuration object.

contains

public boolean contains(ConfigurationProperty property)

Checks if configuration contains the property. If property can be shared between clients, checks this Configuration 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.

contains

public boolean contains(String name)

Determines if the system property or environment variable is defined.

Use contains(ConfigurationProperty<?> property) 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.

get

public String get(String name)

Gets the value of system property or environment variable. Use get(ConfigurationProperty<T> property) 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.

getGlobalConfiguration

public static Configuration getGlobalConfiguration()

Gets the global configuration store shared by all client libraries.

Returns:

The global configuration store.

put

@Deprecated
public Configuration put(String name, String value)

Deprecated

Use ConfigurationBuilder and ConfigurationSource 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
public String remove(String name)

Deprecated

Use ConfigurationBuilder and ConfigurationSource 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.

Applies to