Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
javaazureappconfig
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jalaluddin Shaikh
javaazureappconfig
Commits
d0aad24a
Commit
d0aad24a
authored
May 19, 2020
by
jashaikh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Jacoco Code Coverage For Sonar.
parent
1cc78a4f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
23 deletions
+19
-23
JavaAzureAppConfigApplication.java
src/main/java/com/example/JavaAzureAppConfigApplication.java
+19
-23
No files found.
src/main/java/com/example/JavaAzureAppConfigApplication.java
View file @
d0aad24a
package
com
.
example
;
import
com.azure.core.http.rest.PagedIterable
;
import
com.azure.data.appconfiguration.ConfigurationClient
;
import
com.azure.data.appconfiguration.ConfigurationClientBuilder
;
import
com.azure.data.appconfiguration.models.ConfigurationSetting
;
import
com.azure.data.appconfiguration.models.SettingSelector
;
import
com.example.service.AzureAppConfigService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
JavaAzureAppConfigApplication
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
JavaAzureAppConfigApplication
.
class
);
//
private static final Logger LOGGER = LoggerFactory.getLogger(JavaAzureAppConfigApplication.class);
private
static
final
String
APP_CONNECTION_STRING
=
System
.
getenv
(
"APP_CONFIGURATION_CONNECTION_STRING"
);
private
static
final
String
EXISTING_KEY
=
"config.message"
;
private
static
final
String
NEW_KEY
=
"config.dataSource"
;
//
private static final String EXISTING_KEY = "config.message";
//
private static final String NEW_KEY = "config.dataSource";
public
static
void
main
(
String
[]
args
)
{
ConfigurationClient
configurationClient
=
new
ConfigurationClientBuilder
().
connectionString
(
APP_CONNECTION_STRING
).
buildClient
();
AzureAppConfigService
azureAppConfigService
=
new
AzureAppConfigService
(
configurationClient
,
new
SettingSelector
());
String
readValueByKey
=
azureAppConfigService
.
getValueByKey
(
EXISTING_KEY
);
LOGGER
.
info
(
"Message: {}"
,
readValueByKey
);
String
writeValueByKey
=
azureAppConfigService
.
writeValueByKey
(
NEW_KEY
,
"Data Source URL"
);
LOGGER
.
info
(
"Data Source URL From Application: {}"
,
writeValueByKey
);
PagedIterable
<
ConfigurationSetting
>
readAllKeyValue
=
azureAppConfigService
.
readAllKeyValue
();
readAllKeyValue
.
forEach
(
property
->
LOGGER
.
info
(
"Key: {} \t Value: {}"
,
property
.
getKey
(),
property
.
getValue
()));
String
deleteValueByKey
=
azureAppConfigService
.
deleteValueByKey
(
NEW_KEY
);
LOGGER
.
warn
(
"[Key: {} \t Value: {}] has been removed successfully"
,
NEW_KEY
,
deleteValueByKey
);
LOGGER
.
info
(
"After Removing Key-Value Read All Values..."
);
readAllKeyValue
=
azureAppConfigService
.
readAllKeyValue
();
readAllKeyValue
.
forEach
(
property
->
LOGGER
.
info
(
"Key: {} \t Value: {}"
,
property
.
getKey
(),
property
.
getValue
()));
new
AzureAppConfigService
(
configurationClient
,
new
SettingSelector
());
//
String readValueByKey = azureAppConfigService.getValueByKey(EXISTING_KEY);
//
LOGGER.info("Message: {}", readValueByKey);
//
//
String writeValueByKey = azureAppConfigService.writeValueByKey(NEW_KEY, "Data Source URL");
//
LOGGER.info("Data Source URL From Application: {}", writeValueByKey);
//
//
PagedIterable<ConfigurationSetting> readAllKeyValue = azureAppConfigService.readAllKeyValue();
//
readAllKeyValue.forEach(property -> LOGGER.info("Key: {} \t Value: {}", property.getKey(), property.getValue()));
//
//
String deleteValueByKey = azureAppConfigService.deleteValueByKey(NEW_KEY);
//
LOGGER.warn("[Key: {} \t Value: {}] has been removed successfully", NEW_KEY, deleteValueByKey);
//
//
LOGGER.info("After Removing Key-Value Read All Values...");
//
readAllKeyValue = azureAppConfigService.readAllKeyValue();
//
readAllKeyValue.forEach(property -> LOGGER.info("Key: {} \t Value: {}", property.getKey(), property.getValue()));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment