Class ConfigurationAsyncClient
This class provides a client that contains all the operations for ConfigurationSettings,
FeatureFlagConfigurationSetting or
SecretReferenceConfigurationSetting in Azure App Configuration Store.
Operations allowed by the client are adding, retrieving, deleting, set read-only status ConfigurationSettings, and
listing settings or revision of a setting based on a filter.
Additionally, this class allows to add an external synchronization token to ensure service requests receive
up-to-date values. Use the updateSyncToken method.
Getting Started
In order to interact with the App Configuration service you'll need to create an instance of the
ConfigurationAsyncClient class. To make this possible you'll need the
connection string of the configuration store. Alternatively, you can use AAD authentication via
Azure Identity
to connect to the service.
- Connection string, see
connectionString. - Azure Active Directory, see
TokenCredential.
Instantiating an asynchronous Configuration Client
ConfigurationAsyncClient configurationAsyncClient = new ConfigurationClientBuilder()
.connectionString(connectionString)
.buildAsyncClient();
View this for additional ways to construct the client.
App Configuration support multiple operations, such as create, update, retrieve, and delete a configuration setting. See methods in client level class below to explore all capabilities that library provides.
For more configuration setting types, see
FeatureFlagConfigurationSetting and
SecretReferenceConfigurationSetting.
Add Configuration Setting
The addConfigurationSetting(ConfigurationSetting)
method can be used to add a configuration setting in the Azure App Configuration.
The sample below shows how to add a setting with the key "prodDBConnection", label "westUS" and value
"db_connection" using ConfigurationAsyncClient.
client.addConfigurationSetting(new ConfigurationSetting()
.setKey("prodDBConnection")
.setLabel("westUS")
.setValue("db_connection"))
.subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
response.getKey(), response.getLabel(), response.getValue()));
Note: For synchronous sample, refer to ConfigurationClient.
Update Configuration Setting
The setConfigurationSetting(ConfigurationSetting)
method can be used to update a configuration setting in the Azure App Configuration.
The sample below shows how to update setting's value "db_connection" to "updated_db_connection"
client.setConfigurationSetting(new ConfigurationSetting()
.setKey("prodDBConnection")
.setLabel("westUS"))
.subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
response.getKey(), response.getLabel(), response.getValue()));
// Update the value of the setting to "updated_db_connection"
client.setConfigurationSetting(new ConfigurationSetting()
.setKey("prodDBConnection")
.setLabel("westUS")
.setValue("updated_db_connection"))
.subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
response.getKey(), response.getLabel(), response.getValue()));
Note: For synchronous sample, refer to ConfigurationClient.
Get Configuration Setting
The getConfigurationSetting(ConfigurationSetting)
method can be used to get a configuration setting in the Azure App Configuration.
The sample below shows how to retrieve the setting with the key "prodDBConnection".
client.getConfigurationSetting(new ConfigurationSetting()
.setKey("prodDBConnection")
.setLabel("westUS"))
.subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
response.getKey(), response.getLabel(), response.getValue()));
Note: For synchronous sample, refer to ConfigurationClient.
Delete Configuration Setting
The deleteConfigurationSetting(ConfigurationSetting)
method can be used to delete a configuration setting in the Azure App Configuration.
The sample below shows how to delete the setting with the key "prodDBConnection".
client.deleteConfigurationSetting(new ConfigurationSetting()
.setKey("prodDBConnection")
.setLabel("westUS"))
.subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
response.getKey(), response.getValue()));
Note: For synchronous sample, refer to ConfigurationClient.
Set the Configuration Setting to read-only
The setReadOnly(ConfigurationSetting, boolean)
method can be used to conditionally set a configuration setting to read-only in the Azure App Configuration.
The sample below shows how to conditionally set the setting to read-only with the key "prodDBConnection".
client.setReadOnly(new ConfigurationSetting()
.setKey("prodDBConnection")
.setLabel("westUS"),
true)
.subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
response.getKey(), response.getLabel(), response.getValue()));
Note: For synchronous sample, refer to ConfigurationClient.
Clear read-only of the Configuration Setting
The setReadOnly(ConfigurationSetting, boolean)
method can be used to conditionally clear read-only of the setting in the Azure App Configuration.
The sample below shows how to conditionally clear read-only of the setting with the key "prodDBConnection".
client.setReadOnly(new ConfigurationSetting()
.setKey("prodDBConnection")
.setLabel("westUS"),
false)
.subscribe(response -> System.out.printf("Key: %s, Value: %s", response.getKey(), response.getValue()));
Note: For synchronous sample, refer to ConfigurationClient.
List Configuration Settings
The listConfigurationSettings(SettingSelector)
method can be used to list configuration settings in the Azure App Configuration.
The sample below shows how to list all settings that use the key "prodDBConnection".
client.listConfigurationSettings(new SettingSelector().setKeyFilter("prodDBConnection"))
.contextWrite(Context.of(key1, value1, key2, value2))
.subscribe(setting ->
System.out.printf("Key: %s, Value: %s", setting.getKey(), setting.getValue()));
Note: For synchronous sample, refer to ConfigurationClient.
List revisions of a Configuration Setting
The listRevisions(SettingSelector)
method can be used to list all revisions of a configuration setting in the Azure App Configuration.
The sample below shows how to list all revision of a setting that use the key "prodDBConnection".
client.listRevisions(new SettingSelector().setKeyFilter("prodDBConnection"))
.contextWrite(Context.of(key1, value1, key2, value2))
.subscribe(setting ->
System.out.printf("Key: %s, Value: %s", setting.getKey(), setting.getValue()));
Note: For synchronous sample, refer to ConfigurationClient.
-
Method Summary
Modifier and TypeMethodDescriptionAdds a configuration value in the service if that key and label does not exist.addConfigurationSetting(String key, String label, String value) Adds a configuration value in the service if that key does not exist.Mono<com.azure.core.http.rest.Response<ConfigurationSetting>>Adds a configuration value in the service if that key and label does not exist.archiveSnapshot(String snapshotName) Update a snapshot status fromConfigurationSnapshotStatus.READYtoConfigurationSnapshotStatus.ARCHIVED.Mono<com.azure.core.http.rest.Response<ConfigurationSnapshot>>archiveSnapshotWithResponse(String snapshotName, com.azure.core.http.MatchConditions matchConditions) Update a snapshot status fromConfigurationSnapshotStatus.READYtoConfigurationSnapshotStatus.ARCHIVED.com.azure.core.util.polling.PollerFlux<com.azure.core.util.polling.PollOperationDetails,ConfigurationSnapshot> beginCreateSnapshot(String snapshotName, ConfigurationSnapshot snapshot) Create aConfigurationSnapshotby providing a snapshot name and aConfigurationSnapshot.Deletes theConfigurationSettingwith a matchingkey, and optionallabeland optional ETag combination from the service.deleteConfigurationSetting(String key, String label) Deletes the ConfigurationSetting with a matchingkeyand optionallabelcombination.Mono<com.azure.core.http.rest.Response<ConfigurationSetting>>deleteConfigurationSettingWithResponse(ConfigurationSetting setting, boolean ifUnchanged) Deletes theConfigurationSettingwith a matchingkey, and optionallabeland optional ETag combination from the service.getConfigurationSetting(String key, String label) Attempts to get a ConfigurationSetting that matches thekey, and the optionallabelcombination.getConfigurationSetting(String key, String label, OffsetDateTime acceptDateTime) Attempts to get a ConfigurationSetting that matches thekey, the optionallabel, and the optionalacceptDateTimecombination.Mono<com.azure.core.http.rest.Response<ConfigurationSetting>>getConfigurationSettingWithResponse(ConfigurationSetting setting, OffsetDateTime acceptDateTime, boolean ifChanged) Gets the service endpoint for the Azure App Configuration instance.getSnapshot(String snapshotName) Get aConfigurationSnapshotby given the snapshot name.Mono<com.azure.core.http.rest.Response<ConfigurationSnapshot>>getSnapshotWithResponse(String snapshotName, List<SnapshotFields> fields) Get aConfigurationSnapshotby given the snapshot name.com.azure.core.http.rest.PagedFlux<ConfigurationSetting>listConfigurationSettings(SettingSelector selector) Fetches the configuration settings that match theselector.com.azure.core.http.rest.PagedFlux<ConfigurationSetting>listConfigurationSettingsForSnapshot(String snapshotName) Fetches the configuration settings in a snapshot that matches thesnapshotName.com.azure.core.http.rest.PagedFlux<ConfigurationSetting>listConfigurationSettingsForSnapshot(String snapshotName, List<SettingFields> fields) Fetches the configuration settings in a snapshot that matches thesnapshotName.com.azure.core.http.rest.PagedFlux<ConfigurationSetting>listRevisions(SettingSelector selector) Lists chronological/historical representation ofConfigurationSettingresource(s).com.azure.core.http.rest.PagedFlux<ConfigurationSnapshot>listSnapshots(SnapshotSelector selector) List snapshots by givenSnapshotSelector.recoverSnapshot(String snapshotName) Update a snapshot status fromConfigurationSnapshotStatus.ARCHIVEDtoConfigurationSnapshotStatus.READY.Mono<com.azure.core.http.rest.Response<ConfigurationSnapshot>>recoverSnapshotWithResponse(String snapshotName, com.azure.core.http.MatchConditions matchConditions) Update a snapshot status fromConfigurationSnapshotStatus.ARCHIVEDtoConfigurationSnapshotStatus.READY.Creates or updates a configuration value in the service.setConfigurationSetting(String key, String label, String value) Creates or updates a configuration value in the service with the given key.Mono<com.azure.core.http.rest.Response<ConfigurationSetting>>setConfigurationSettingWithResponse(ConfigurationSetting setting, boolean ifUnchanged) Creates or updates a configuration value in the service.setReadOnly(ConfigurationSetting setting, boolean isReadOnly) Sets the read-only status for theConfigurationSetting.setReadOnly(String key, String label, boolean isReadOnly) Mono<com.azure.core.http.rest.Response<ConfigurationSetting>>setReadOnlyWithResponse(ConfigurationSetting setting, boolean isReadOnly) Sets the read-only status for theConfigurationSetting.voidupdateSyncToken(String token) Adds an external synchronization token to ensure service requests receive up-to-date values.
-
Method Details
-
getEndpoint
Gets the service endpoint for the Azure App Configuration instance.- Returns:
- the service endpoint for the Azure App Configuration instance.
-
addConfigurationSetting
Adds a configuration value in the service if that key does not exist. Thelabelis optional.Code Samples
Add a setting with the key "prodDBConnection", label "westUS" and value "db_connection".
client.addConfigurationSetting("prodDBConnection", "westUS", "db_connection") .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s", response.getKey(), response.getLabel(), response.getValue()));- Parameters:
key- The key of the configuration setting to add.label- The label of the configuration setting to add. Ifnullno label will be used.value- The value associated with this configuration setting key.- Returns:
- The
ConfigurationSettingthat was created, ornullif a key collision occurs or the key is an invalid value (which will also throw HttpResponseException described below). - Throws:
IllegalArgumentException- Ifkeyisnull.com.azure.core.exception.ResourceModifiedException- If a ConfigurationSetting with the same key exists.com.azure.core.exception.HttpResponseException- Ifkeyis an empty string.
-
addConfigurationSetting
Adds a configuration value in the service if that key and label does not exist. The label value of the ConfigurationSetting is optional. For more configuration setting types, seeFeatureFlagConfigurationSettingandSecretReferenceConfigurationSetting.Code Samples
Add a setting with the key "prodDBConnection", label "westUS", and value "db_connection".
client.addConfigurationSetting(new ConfigurationSetting() .setKey("prodDBConnection") .setLabel("westUS") .setValue("db_connection")) .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s", response.getKey(), response.getLabel(), response.getValue()));- Parameters:
setting- The setting to add based on its key and optional label combination.- Returns:
- The
ConfigurationSettingthat was created, ornullif a key collision occurs or the key is an invalid value (which will also throw HttpResponseException described below). - Throws:
NullPointerException- Ifsettingisnull.IllegalArgumentException- Ifkeyisnull.com.azure.core.exception.ResourceModifiedException- If a ConfigurationSetting with the same key and label exists.com.azure.core.exception.HttpResponseException- Ifkeyis an empty string.
-
addConfigurationSettingWithResponse
public Mono<com.azure.core.http.rest.Response<ConfigurationSetting>> addConfigurationSettingWithResponse(ConfigurationSetting setting) Adds a configuration value in the service if that key and label does not exist. The label value of the ConfigurationSetting is optional. For more configuration setting types, seeFeatureFlagConfigurationSettingandSecretReferenceConfigurationSetting.Code Samples
Add a setting with the key "prodDBConnection", label "westUS", and value "db_connection".
client.addConfigurationSettingWithResponse(new ConfigurationSetting() .setKey("prodDBConnection") .setLabel("westUS") .setValue("db_connection")) .subscribe(response -> { ConfigurationSetting responseSetting = response.getValue(); System.out.printf("Key: %s, Label: %s, Value: %s", responseSetting.getKey(), responseSetting.getLabel(), responseSetting.getValue()); });- Parameters:
setting- The setting to add based on its key and optional label combination.- Returns:
- A REST response containing the
ConfigurationSettingthat was created, if a key collision occurs or the key is an invalid value (which will also throw HttpResponseException described below). - Throws:
NullPointerException- Ifsettingisnull.IllegalArgumentException- Ifkeyisnull.com.azure.core.exception.ResourceModifiedException- If a ConfigurationSetting with the same key and label exists.com.azure.core.exception.HttpResponseException- Ifkeyis an empty string.
-
setConfigurationSetting
Creates or updates a configuration value in the service with the given key. thelabelis optional.Code Samples
Add a setting with the key "prodDBConnection", "westUS" and value "db_connection"
Update setting's value "db_connection" to "updated_db_connection"
client.setConfigurationSetting("prodDBConnection", "westUS", "db_connection") .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s", response.getKey(), response.getLabel(), response.getValue())); // Update the value of the setting to "updated_db_connection" client.setConfigurationSetting("prodDBConnection", "westUS", "updated_db_connection") .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s", response.getKey(), response.getLabel(), response.getValue()));- Parameters:
key- The key of the configuration setting to create or update.label- The label of the configuration setting to create or update, Ifnullno label will be used.value- The value of this configuration setting.- Returns:
- The
ConfigurationSettingthat was created or updated, or an empty Mono if the key is an invalid value (which will also throw HttpResponseException described below). - Throws:
IllegalArgumentException- Ifkeyisnull.com.azure.core.exception.ResourceModifiedException- If the setting exists and is read-only.com.azure.core.exception.HttpResponseException- Ifkeyis an empty string.
-
setConfigurationSetting
Creates or updates a configuration value in the service. Partial updates are not supported and the entire configuration setting is updated. For more configuration setting types, seeFeatureFlagConfigurationSettingandSecretReferenceConfigurationSetting.Code Samples
Add a setting with the key "prodDBConnection", "westUS" and value "db_connection"
Update setting's value "db_connection" to "updated_db_connection"
client.setConfigurationSetting(new ConfigurationSetting() .setKey("prodDBConnection") .setLabel("westUS")) .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s", response.getKey(), response.getLabel(), response.getValue())); // Update the value of the setting to "updated_db_connection" client.setConfigurationSetting(new ConfigurationSetting() .setKey("prodDBConnection") .setLabel("westUS") .setValue("updated_db_connection")) .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s", response.getKey(), response.getLabel(), response.getValue()));- Parameters:
setting- The setting to add based on its key and optional label combination.- Returns:
- The
ConfigurationSettingthat was created or updated, or an empty Mono if the key is an invalid value (which will also throw HttpResponseException described below). - Throws:
NullPointerException- Ifsettingisnull.IllegalArgumentException- Ifkeyisnull.com.azure.core.exception.ResourceModifiedException- If the setting exists and is read-only.com.azure.core.exception.HttpResponseException- Ifkeyis an empty string.
-
setConfigurationSettingWithResponse
public Mono<com.azure.core.http.rest.Response<ConfigurationSetting>> setConfigurationSettingWithResponse(ConfigurationSetting setting, boolean ifUnchanged) Creates or updates a configuration value in the service. Partial updates are not supported and the entire configuration setting is updated. For more configuration setting types, seeFeatureFlagConfigurationSettingandSecretReferenceConfigurationSetting. IfETagis specified, the configuration value is updated if the current setting's ETag matches. If the ETag's value is equal to the wildcard character ("*"), the setting will always be updated.Code Samples
Add a setting with the key "prodDBConnection", label "westUS", and value "db_connection".
Update setting's value "db_connection" to "updated_db_connection"
client.setConfigurationSettingWithResponse(new ConfigurationSetting() .setKey("prodDBConnection") .setLabel("westUS") .setValue("db_connection"), false) .subscribe(response -> { final ConfigurationSetting result = response.getValue(); System.out.printf("Key: %s, Label: %s, Value: %s", result.getKey(), result.getLabel(), result.getValue()); }); // Update the value of the setting to "updated_db_connection" client.setConfigurationSettingWithResponse(new ConfigurationSetting() .setKey("prodDBConnection") .setLabel("westUS") .setValue("updated_db_connection"), false) .subscribe(response -> { final ConfigurationSetting responseSetting = response.getValue(); System.out.printf("Key: %s, Label: %s, Value: %s", responseSetting.getKey(), responseSetting.getLabel(), responseSetting.getValue()); });- Parameters:
setting- The setting to create or update based on its key, optional label and optional ETag combination.ifUnchanged- Flag indicating if thesettingETagis used as a IF-MATCH header.- Returns:
- A REST response containing the
ConfigurationSettingthat was created or updated, if the key is an invalid value, the setting is read-only, or an ETag was provided but does not match the service's current ETag value (which will also throw HttpResponseException described below). - Throws:
NullPointerException- Ifsettingisnull.IllegalArgumentException- Ifkeyisnull.com.azure.core.exception.ResourceModifiedException- If theETagwas specified, is not the wildcard character, and the current configuration value's ETag does not match, or the setting exists and is read-only.com.azure.core.exception.HttpResponseException- Ifkeyis an empty string.
-
getConfigurationSetting
Attempts to get a ConfigurationSetting that matches thekey, and the optionallabelcombination.Code Samples
Retrieve the setting with the key "prodDBConnection".
client.getConfigurationSetting("prodDBConnection", "westUS") .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s", response.getKey(), response.getLabel(), response.getValue()));- Parameters:
key- The key of the setting to retrieve.label- The label of the configuration setting to retrieve. Ifnullno label will be used.- Returns:
- The
ConfigurationSettingstored in the service, or an empty Mono if the configuration value does not exist or the key is an invalid value (which will also throw HttpResponseException described below). - Throws:
IllegalArgumentException- Ifkeyisnull.com.azure.core.exception.ResourceNotFoundException- If a ConfigurationSetting withkeydoes not exist.com.azure.core.exception.HttpResponseException- Ifkeyis an empty string.
-
getConfigurationSetting
public Mono<ConfigurationSetting> getConfigurationSetting(String key, String label, OffsetDateTime acceptDateTime) Attempts to get a ConfigurationSetting that matches thekey, the optionallabel, and the optionalacceptDateTimecombination.Code Samples
Retrieve the setting with the key "prodDBConnection" and a time that one minute before now at UTC-Zone
client.getConfigurationSetting( "prodDBConnection", "westUS", OffsetDateTime.now(ZoneOffset.UTC).minusMinutes(1)) .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s", response.getKey(), response.getLabel(), response.getValue()));- Parameters:
key- The key of the setting to retrieve.label- The label of the configuration setting to retrieve. Ifnullno label will be used.acceptDateTime- Datetime to access a past state of the configuration setting. Ifnullthen the current state of the configuration setting will be returned.- Returns:
- The
ConfigurationSettingstored in the service, or an empty Mono if the configuration value does not exist or the key is an invalid value (which will also throw HttpResponseException described below). - Throws:
IllegalArgumentException- Ifkeyisnull.com.azure.core.exception.ResourceNotFoundException- If a ConfigurationSetting withkeydoes not exist.com.azure.core.exception.HttpResponseException- Ifkeyis an empty string.
-
getConfigurationSetting
Attempts to get the ConfigurationSetting with a matchingkey, and optionallabel, optionalacceptDateTimeand optional ETag combination. For more configuration setting types, seeFeatureFlagConfigurationSettingandSecretReferenceConfigurationSetting.Code Samples
Retrieve the setting with the key "prodDBConnection" and a time that one minute before now at UTC-Zone
client.getConfigurationSetting(new ConfigurationSetting() .setKey("prodDBConnection") .setLabel("westUS")) .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s", response.getKey(), response.getLabel(), response.getValue()));- Parameters:
setting- The setting to retrieve.- Returns:
- The
ConfigurationSettingstored in the service, or an empty Mono if the configuration value does not exist or the key is an invalid value (which will also throw HttpResponseException described below). - Throws:
NullPointerException- Ifsettingisnull.IllegalArgumentException- Ifkeyisnull.com.azure.core.exception.ResourceNotFoundException- If a ConfigurationSetting with the same key and label does not exist.com.azure.core.exception.HttpResponseException- If thekeyis an empty string.
-
getConfigurationSettingWithResponse
public Mono<com.azure.core.http.rest.Response<ConfigurationSetting>> getConfigurationSettingWithResponse(ConfigurationSetting setting, OffsetDateTime acceptDateTime, boolean ifChanged) Attempts to get the ConfigurationSetting with a matchingkey, and optionallabel, optionalacceptDateTimeand optional ETag combination. For more configuration setting types, seeFeatureFlagConfigurationSettingandSecretReferenceConfigurationSetting.Code Samples
Retrieve the setting with the key-label "prodDBConnection"-"westUS".
client.getConfigurationSettingWithResponse(new ConfigurationSetting() .setKey("prodDBConnection") .setLabel("westUS"), null, false) .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(response -> { ConfigurationSetting result = response.getValue(); System.out.printf("Key: %s, Label: %s, Value: %s", result.getKey(), result.getLabel(), result.getValue()); });- Parameters:
setting- The setting to retrieve.acceptDateTime- Datetime to access a past state of the configuration setting. Ifnullthen the current state of the configuration setting will be returned.ifChanged- Flag indicating if thesettingETagis used as a If-None-Match header.- Returns:
- A REST response containing the
ConfigurationSettingstored in the service, ornullif didn't exist.nullis also returned if the configuration value does not exist or the key is an invalid value (which will also throw HttpResponseException described below). - Throws:
NullPointerException- Ifsettingisnull.IllegalArgumentException- Ifkeyisnull.com.azure.core.exception.ResourceNotFoundException- If a ConfigurationSetting with the same key and label does not exist.com.azure.core.exception.HttpResponseException- If thekeyis an empty string.
-
deleteConfigurationSetting
Deletes the ConfigurationSetting with a matchingkeyand optionallabelcombination.Code Samples
Delete the setting with the key "prodDBConnection".
client.deleteConfigurationSetting("prodDBConnection", "westUS") .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s", response.getKey(), response.getLabel(), response.getValue()));- Parameters:
key- The key of configuration setting to delete.label- The label of configuration setting to delete. Ifnullno label will be used.- Returns:
- The deleted ConfigurationSetting or an empty Mono is also returned if the
keyis an invalid value (which will also throw HttpResponseException described below). - Throws:
IllegalArgumentException- Ifkeyisnull.com.azure.core.exception.ResourceModifiedException- Ifsettingis read-only.com.azure.core.exception.HttpResponseException- Ifkeyis an empty string.
-
deleteConfigurationSetting
Deletes theConfigurationSettingwith a matchingkey, and optionallabeland optional ETag combination from the service. For more configuration setting types, seeFeatureFlagConfigurationSettingandSecretReferenceConfigurationSetting. IfETagis specified and is not the wildcard character ("*"), then the setting is only deleted if the ETag matches the current ETag; this means that no one has updated the ConfigurationSetting yet.Code Samples
Delete the setting with the key "prodDBConnection".
client.deleteConfigurationSetting(new ConfigurationSetting() .setKey("prodDBConnection") .setLabel("westUS")) .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s", response.getKey(), response.getValue()));- Parameters:
setting- The setting to delete based on its key, optional label and optional ETag combination.- Returns:
- The deleted ConfigurationSetting or an empty Mono is also returned if the
keyis an invalid value (which will also throw HttpResponseException described below). - Throws:
IllegalArgumentException- Ifkeyisnull.NullPointerException- Whensettingisnull.com.azure.core.exception.ResourceModifiedException- Ifsettingis read-only.com.azure.core.exception.ResourceNotFoundException- IfETagis specified, not the wildcard character, and does not match the current ETag value.com.azure.core.exception.HttpResponseException- Ifkeyis an empty string.
-
deleteConfigurationSettingWithResponse
public Mono<com.azure.core.http.rest.Response<ConfigurationSetting>> deleteConfigurationSettingWithResponse(ConfigurationSetting setting, boolean ifUnchanged) Deletes theConfigurationSettingwith a matchingkey, and optionallabeland optional ETag combination from the service. For more configuration setting types, seeFeatureFlagConfigurationSettingandSecretReferenceConfigurationSetting. IfETagis specified and is not the wildcard character ("*"), then the setting is only deleted if the ETag matches the current ETag; this means that no one has updated the ConfigurationSetting yet.Code Samples
Delete the setting with the key-label "prodDBConnection"-"westUS"
client.deleteConfigurationSettingWithResponse(new ConfigurationSetting() .setKey("prodDBConnection") .setLabel("westUS"), false) .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(response -> { ConfigurationSetting responseSetting = response.getValue(); System.out.printf("Key: %s, Label: %s, Value: %s", responseSetting.getKey(), responseSetting.getLabel(), responseSetting.getValue()); });- Parameters:
setting- The setting to delete based on its key, optional label and optional ETag combination.ifUnchanged- Flag indicating if thesettingETagis used as a IF-MATCH header.- Returns:
- A REST response containing the deleted ConfigurationSetting or
nullif didn't exist.nullis also returned if thekeyis an invalid value orETagis set but does not match the current ETag (which will also throw HttpResponseException described below). - Throws:
IllegalArgumentException- Ifkeyisnull.NullPointerException- Whensettingisnull.com.azure.core.exception.ResourceModifiedException- Ifsettingis read-only.com.azure.core.exception.ResourceNotFoundException- IfETagis specified, not the wildcard character, and does not match the current ETag value.com.azure.core.exception.HttpResponseException- Ifkeyis an empty string.
-
setReadOnly
Sets the read-only status for theConfigurationSettingthat matches thekey, the optionallabel.Code Samples
Set the setting to read-only with the key-label "prodDBConnection"-"westUS".
client.setReadOnly("prodDBConnection", "westUS", true) .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s", response.getKey(), response.getLabel(), response.getValue()));Clear read-only of the setting with the key-label "prodDBConnection"-"westUS".
client.setReadOnly("prodDBConnection", "westUS", false) .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(response -> System.out.printf("Key: %s, Value: %s", response.getKey(), response.getValue()));- Parameters:
key- The key of configuration setting to set to be read-only.label- The label of configuration setting to read-only. Ifnullno label will be used.isReadOnly- Flag used to set the read-only status of the configuration.truewill put the configuration into a read-only state,falsewill clear the state.- Returns:
- The
ConfigurationSettingthat is read-only, or an empty Mono if a key collision occurs or the key is an invalid value (which will also throw HttpResponseException described below). - Throws:
IllegalArgumentException- Ifkeyisnull.com.azure.core.exception.HttpResponseException- Ifkeyis an empty string.
-
setReadOnly
Sets the read-only status for theConfigurationSetting. For more configuration setting types, seeFeatureFlagConfigurationSettingandSecretReferenceConfigurationSetting.Code Samples
Set the setting to read-only with the key-label "prodDBConnection"-"westUS".
client.setReadOnly(new ConfigurationSetting() .setKey("prodDBConnection") .setLabel("westUS"), true) .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s", response.getKey(), response.getLabel(), response.getValue()));Clear read-only of the setting with the key-label "prodDBConnection"-"westUS".
client.setReadOnly(new ConfigurationSetting() .setKey("prodDBConnection") .setLabel("westUS"), false) .subscribe(response -> System.out.printf("Key: %s, Value: %s", response.getKey(), response.getValue()));- Parameters:
setting- The configuration setting to set to read-only or not read-only based on theisReadOnly.isReadOnly- Flag used to set the read-only status of the configuration.truewill put the configuration into a read-only state,falsewill clear the state.- Returns:
- The
ConfigurationSettingthat is read-only, or an empty Mono if a key collision occurs or the key is an invalid value (which will also throw HttpResponseException described below). - Throws:
IllegalArgumentException- Ifkeyisnull.com.azure.core.exception.HttpResponseException- Ifkeyis an empty string.
-
setReadOnlyWithResponse
public Mono<com.azure.core.http.rest.Response<ConfigurationSetting>> setReadOnlyWithResponse(ConfigurationSetting setting, boolean isReadOnly) Sets the read-only status for theConfigurationSetting. For more configuration setting types, seeFeatureFlagConfigurationSettingandSecretReferenceConfigurationSetting.Code Samples
Set the setting to read-only with the key-label "prodDBConnection"-"westUS".
client.setReadOnlyWithResponse(new ConfigurationSetting() .setKey("prodDBConnection") .setLabel("westUS"), true) .subscribe(response -> { ConfigurationSetting result = response.getValue(); System.out.printf("Key: %s, Label: %s, Value: %s", result.getKey(), result.getLabel(), result.getValue()); });Clear read-only of the setting with the key-label "prodDBConnection"-"westUS".
client.setReadOnlyWithResponse(new ConfigurationSetting() .setKey("prodDBConnection") .setLabel("westUS"), false) .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(response -> { ConfigurationSetting result = response.getValue(); System.out.printf("Key: %s, Value: %s", result.getKey(), result.getValue()); });- Parameters:
setting- The configuration setting to set to read-only or not read-only based on theisReadOnly.isReadOnly- Flag used to set the read-only status of the configuration.truewill put the configuration into a read-only state,falsewill clear the state.- Returns:
- A REST response containing the read-only or not read-only ConfigurationSetting if
isReadOnlyis true or null, or false respectively. Or returnnullif the setting didn't exist.nullis also returned if thekeyis an invalid value. (which will also throw HttpResponseException described below). - Throws:
IllegalArgumentException- Ifkeyisnull.com.azure.core.exception.HttpResponseException- Ifkeyis an empty string.
-
listConfigurationSettings
public com.azure.core.http.rest.PagedFlux<ConfigurationSetting> listConfigurationSettings(SettingSelector selector) Fetches the configuration settings that match theselector. Ifselectorisnull, then all theconfiguration settingsare fetched with their current values.Code Samples
Retrieve all settings that use the key "prodDBConnection".
client.listConfigurationSettings(new SettingSelector().setKeyFilter("prodDBConnection")) .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(setting -> System.out.printf("Key: %s, Value: %s", setting.getKey(), setting.getValue()));- Parameters:
selector- Optional. Selector to filter configuration setting results from the service.- Returns:
- A Flux of ConfigurationSettings that matches the
selector. If no options were provided, the Flux contains all of the current settings in the service. - Throws:
com.azure.core.exception.HttpResponseException- If a client or service error occurs, such as a 404, 409, 429 or 500.
-
listConfigurationSettingsForSnapshot
public com.azure.core.http.rest.PagedFlux<ConfigurationSetting> listConfigurationSettingsForSnapshot(String snapshotName) Fetches the configuration settings in a snapshot that matches thesnapshotName. IfsnapshotNameisnull, then all theconfiguration settingsare fetched with their current values.Code Samples
String snapshotName = "{snapshotName}"; client.listConfigurationSettingsForSnapshot(snapshotName) .subscribe(setting -> System.out.printf("Key: %s, Value: %s", setting.getKey(), setting.getValue()));- Parameters:
snapshotName- Optional. A filter used getConfigurationSettings for a snapshot. The value should be the name of the snapshot.- Returns:
- A Flux of ConfigurationSettings that matches the
selector. If no options were provided, the Flux contains all of the current settings in the service. - Throws:
com.azure.core.exception.HttpResponseException- If a client or service error occurs, such as a 404, 409, 429 or 500.
-
listConfigurationSettingsForSnapshot
public com.azure.core.http.rest.PagedFlux<ConfigurationSetting> listConfigurationSettingsForSnapshot(String snapshotName, List<SettingFields> fields) Fetches the configuration settings in a snapshot that matches thesnapshotName. IfsnapshotNameisnull, then all theconfiguration settingsare fetched with their current values.Code Samples
String snapshotName = "{snapshotName}"; List<SettingFields> fields = Arrays.asList(SettingFields.KEY); client.listConfigurationSettingsForSnapshot(snapshotName, fields) .subscribe(setting -> System.out.printf("Key: %s, Value: %s", setting.getKey(), setting.getValue()));- Parameters:
snapshotName- Optional. A filter used getConfigurationSettings for a snapshot. The value should be the name of the snapshot.fields- Optional. The fields to select for the query response. If none are set, the service will return the ConfigurationSettings with a default set of properties.- Returns:
- A Flux of ConfigurationSettings that matches the
selector. If no options were provided, the Flux contains all of the current settings in the service. - Throws:
com.azure.core.exception.HttpResponseException- If a client or service error occurs, such as a 404, 409, 429 or 500.
-
listRevisions
public com.azure.core.http.rest.PagedFlux<ConfigurationSetting> listRevisions(SettingSelector selector) Lists chronological/historical representation ofConfigurationSettingresource(s). Revisions are provided in descending order from theirlastModifieddate. Revisions expire after a period of time, see Pricing for more information. Ifselectorisnull, then all theConfigurationSettingsare fetched in their current state. Otherwise, the results returned match the parameters given inselector.Code Samples
Retrieve all revisions of the setting that has the key "prodDBConnection".
client.listRevisions(new SettingSelector().setKeyFilter("prodDBConnection")) .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(setting -> System.out.printf("Key: %s, Value: %s", setting.getKey(), setting.getValue()));- Parameters:
selector- Optional. Used to filter configuration setting revisions from the service.- Returns:
- Revisions of the ConfigurationSetting
- Throws:
com.azure.core.exception.HttpResponseException- If a client or service error occurs, such as a 404, 409, 429 or 500.
-
beginCreateSnapshot
public com.azure.core.util.polling.PollerFlux<com.azure.core.util.polling.PollOperationDetails,ConfigurationSnapshot> beginCreateSnapshot(String snapshotName, ConfigurationSnapshot snapshot) Create aConfigurationSnapshotby providing a snapshot name and aConfigurationSnapshot.Code Samples
List<ConfigurationSettingsFilter> filters = new ArrayList<>(); // Key Name also supports RegExp but only support prefix end with "*", such as "k*" and is case-sensitive. filters.add(new ConfigurationSettingsFilter("{keyName}")); String snapshotName = "{snapshotName}"; client.beginCreateSnapshot(snapshotName, new ConfigurationSnapshot(filters) .setRetentionPeriod(Duration.ofHours(1))) .flatMap(result -> result.getFinalResult()) .subscribe( snapshot -> System.out.printf("Snapshot name=%s is created at %s%n", snapshot.getName(), snapshot.getCreatedAt()), ex -> System.out.printf("Error on creating a snapshot=%s, with error=%s.%n", snapshotName, ex.getMessage()), () -> System.out.println("Successfully created a snapshot."));- Parameters:
snapshotName- The name of theConfigurationSnapshotto create.snapshot- TheConfigurationSnapshotto create.- Returns:
- A
PollerFluxthat polls the creating snapshot operation until it has completed or has failed. The completed operation returns aConfigurationSnapshot.
-
getSnapshot
Get aConfigurationSnapshotby given the snapshot name.Code Samples
String snapshotName = "{snapshotName}"; client.getSnapshot(snapshotName).subscribe( getSnapshot -> { System.out.printf("Snapshot name=%s is created at %s, snapshot status is %s.%n", getSnapshot.getName(), getSnapshot.getCreatedAt(), getSnapshot.getStatus()); } );- Parameters:
snapshotName- the snapshot name.- Returns:
- A
MonoofConfigurationSnapshot.
-
getSnapshotWithResponse
public Mono<com.azure.core.http.rest.Response<ConfigurationSnapshot>> getSnapshotWithResponse(String snapshotName, List<SnapshotFields> fields) Get aConfigurationSnapshotby given the snapshot name.Code Samples
String snapshotName = "{snapshotName}"; client.getSnapshotWithResponse(snapshotName, Arrays.asList(SnapshotFields.NAME, SnapshotFields.CREATED_AT, SnapshotFields.STATUS, SnapshotFields.FILTERS)) .subscribe( response -> { ConfigurationSnapshot getSnapshot = response.getValue(); // Only properties `name`, `createAt`, `status` and `filters` have value, and expect null or // empty value other than the `fields` specified in the request. System.out.printf("Snapshot name=%s is created at %s, snapshot status is %s.%n", getSnapshot.getName(), getSnapshot.getCreatedAt(), getSnapshot.getStatus()); List<ConfigurationSettingsFilter> filters = getSnapshot.getFilters(); for (ConfigurationSettingsFilter filter : filters) { System.out.printf("Snapshot filter key=%s, label=%s.%n", filter.getKey(), filter.getLabel()); } });- Parameters:
snapshotName- The snapshot name.fields- Used to select what fields are present in the returned resource(s).- Returns:
- A
MonoofResponseofConfigurationSnapshot.
-
archiveSnapshot
Update a snapshot status fromConfigurationSnapshotStatus.READYtoConfigurationSnapshotStatus.ARCHIVED.Code Samples
String snapshotName = "{snapshotName}"; client.archiveSnapshot(snapshotName).subscribe( archivedSnapshot -> { System.out.printf("Archived snapshot name=%s is created at %s, snapshot status is %s.%n", archivedSnapshot.getName(), archivedSnapshot.getCreatedAt(), archivedSnapshot.getStatus()); } );- Parameters:
snapshotName- The snapshot name.- Returns:
- A
MonoofConfigurationSnapshot.
-
archiveSnapshotWithResponse
public Mono<com.azure.core.http.rest.Response<ConfigurationSnapshot>> archiveSnapshotWithResponse(String snapshotName, com.azure.core.http.MatchConditions matchConditions) Update a snapshot status fromConfigurationSnapshotStatus.READYtoConfigurationSnapshotStatus.ARCHIVED.To turn on using 'if-match' header, set the second parameter 'ifUnchanged' to true. It used to perform an operation only if the targeted resource's ETag matches the value provided. Otherwise, it will throw an exception '412 Precondition Failed'.
Code Samples
String snapshotName = "{snapshotName}"; MatchConditions matchConditions = new MatchConditions().setIfMatch("{etag}"); client.archiveSnapshotWithResponse(snapshotName, matchConditions) .subscribe( response -> { ConfigurationSnapshot archivedSnapshot = response.getValue(); System.out.printf("Archived snapshot name=%s is created at %s, snapshot status is %s.%n", archivedSnapshot.getName(), archivedSnapshot.getCreatedAt(), archivedSnapshot.getStatus()); } );- Parameters:
snapshotName- The snapshot name.matchConditions- Specifies HTTP options for conditional requests.- Returns:
- A
MonoofConfigurationSnapshot.
-
recoverSnapshot
Update a snapshot status fromConfigurationSnapshotStatus.ARCHIVEDtoConfigurationSnapshotStatus.READY.Code Samples
String snapshotName = "{snapshotName}"; client.recoverSnapshot(snapshotName).subscribe( recoveredSnapshot -> { System.out.printf("Recovered snapshot name=%s is created at %s, snapshot status is %s.%n", recoveredSnapshot.getName(), recoveredSnapshot.getCreatedAt(), recoveredSnapshot.getStatus()); } );- Parameters:
snapshotName- The snapshot name.- Returns:
- A
MonoofConfigurationSnapshot.
-
recoverSnapshotWithResponse
public Mono<com.azure.core.http.rest.Response<ConfigurationSnapshot>> recoverSnapshotWithResponse(String snapshotName, com.azure.core.http.MatchConditions matchConditions) Update a snapshot status fromConfigurationSnapshotStatus.ARCHIVEDtoConfigurationSnapshotStatus.READY.To turn on using 'if-match' header, set the second parameter 'ifUnchanged' to true. It used to perform an operation only if the targeted resource's ETag matches the value provided. Otherwise, it will throw an exception '412 Precondition Failed'.
Code Samples
String snapshotName = "{snapshotName}"; MatchConditions matchConditions = new MatchConditions().setIfMatch("{etag}"); client.recoverSnapshotWithResponse(snapshotName, matchConditions).subscribe( response -> { ConfigurationSnapshot recoveredSnapshot = response.getValue(); System.out.printf("Recovered snapshot name=%s is created at %s, snapshot status is %s.%n", recoveredSnapshot.getName(), recoveredSnapshot.getCreatedAt(), recoveredSnapshot.getStatus()); } );- Parameters:
snapshotName- The snapshot name.matchConditions- Specifies HTTP options for conditional requests.- Returns:
- A
MonoofConfigurationSnapshot.
-
listSnapshots
public com.azure.core.http.rest.PagedFlux<ConfigurationSnapshot> listSnapshots(SnapshotSelector selector) List snapshots by givenSnapshotSelector.Code Samples
String snapshotNameFilter = "{snapshotNamePrefix}*"; client.listSnapshots(new SnapshotSelector().setNameFilter(snapshotNameFilter)) .subscribe(recoveredSnapshot -> { System.out.printf("Recovered snapshot name=%s is created at %s, snapshot status is %s.%n", recoveredSnapshot.getName(), recoveredSnapshot.getCreatedAt(), recoveredSnapshot.getStatus()); });- Parameters:
selector- Optional. Used to filterConfigurationSnapshotfrom the service.- Returns:
- A
PagedFluxofConfigurationSnapshot.
-
updateSyncToken
Adds an external synchronization token to ensure service requests receive up-to-date values.- Parameters:
token- an external synchronization token to ensure service requests receive up-to-date values.- Throws:
NullPointerException- if the given token is null.
-