ConfigurationClient.addConfigurationSettingWithResponse(ConfigurationSetting setting, Context context) Method

Definition

Adds a configuration value in the service if that key and label does not exist. The label value of the ConfigurationSetting is optional.

Code Samples

Add a setting with the key "prodDBConnection", label "westUS", and value "db_connection".

Response<ConfigurationSetting> responseResultSetting = configurationClient
     .addConfigurationSettingWithResponse(
         new ConfigurationSetting()
             .setKey("prodDBConnection").setLabel("westUS").setValue("db_connection"),
         new Context(key1, value1));
 final ConfigurationSetting resultSetting = responseResultSetting.getValue();
 System.out.printf("Key: %s, Label: %s, Value: %s", resultSetting.getKey(), resultSetting.getLabel(),
     resultSetting.getValue());
public Response<ConfigurationSetting> addConfigurationSettingWithResponse(ConfigurationSetting setting, Context context)

Parameters

setting
ConfigurationSetting

The setting to add based on its key and optional label combination.

context
Context

Additional context that is passed through the Http pipeline during the service call.

Returns

A REST response containing the the ConfigurationSetting that was created, or null, if a key collision occurs or the key is an invalid value (which will also throw ServiceRequestException described below).

Applies to